1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54
| import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.JTabbedPane;
import javax.swing.JScrollPane;
import javax.swing.JButton;
import java.io.*;
public class TabbedPane
{
public static void main(String args[]) throws Exception
{
JFrame frame = new JFrame("Essai");
JPanel panel = new JPanel();
panel.setLayout(null);
panel.setSize(300, 300);
// On ajoute le panel dans la Frame
frame.setContentPane(panel);
// On ajoute un TabbedPane au panel
JTabbedPane tabbed = new JTabbedPane();
panel.add(tabbed);
tabbed.setBounds(0, 0, 200, 200);
// On crée le Panel contenu dans le TabbedPane
JPanel toto = new JPanel();
toto.setLayout(null);
JScrollPane totoScroll = new JScrollPane(toto);
tabbed.addTab("Essai", totoScroll );
JButton button = new JButton("Mon bouton tout beau");
totoScroll.add(button);
button.setBounds(100,10,200,20);
frame.setSize(300, 300);
frame.show();
BufferedReader entree = new BufferedReader(new InputStreamReader(System.in));
String val = entree.readLine();
while (val.equals("q") == false)
{
try
{
val = entree.readLine();
}
catch( IOException e )
{
e.printStackTrace();
}
}
System.exit(0);
}
} |
Partager