Tips for heathy life

Tips for heathy life

Kamis, 30 Oktober 2008

CARD LAYOUT in J2SE



I want to share how to CARD LAYOUT in J2SE. You can use this code but if you copy this code and paste in your blog/website, please insert this link of article.

import java.awt.BorderLayout;
import java.awt.FlowLayout;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.JTabbedPane;
import javax.swing.JTextArea;

public class Main {


// public Main() {
//}

public static void main(String[] args) {

JFrame frame =new JFrame("Card Layout with Tabbed Pane");

JPanel panel1=new JPanel();
JPanel panel2=new JPanel();
JTextArea text=new JTextArea("Text on panel number 2");
JButton btn=new JButton("Button on panel number 1");

panel1.add(btn);
panel2.add(text);

JTabbedPane tab=new JTabbedPane();
tab.add(panel1,"Tab 1");
tab.add(panel2,"Tab 2");
frame.getContentPane().add(tab,BorderLayout.NORTH);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.pack();
frame.show();
}
}

0 komentar:

Posting Komentar