Bonjour à tous !


je veux afficher pour les 3 onglés l'information de "createPage1",
mais dans l'éxécution de mon programme j'ai seulement un onglé "onglé 3" avec les informations de "createPage1".

donc je cherche une solution pour afficher l'information qui existe dans "createPage1", pour tous les JPanel.


Code : Sélectionner tout - Visualiser dans une fenêtre à part
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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
import java.awt.*;
import javax.swing.*;
 
class TabbedPaneExample
		extends 	JFrame
{
	private		JTabbedPane tabbedPane;
	private		JPanel		panel1;
	private		JPanel		panel2;
	private		JPanel		panel3;
 
 
	public TabbedPaneExample()
	{
		// NOTE: to reduce the amount of code in this example, it uses
		// panels with a NULL layout.  This is NOT suitable for
		// production code since it may not display correctly for
		// a look-and-feel.
 
		setTitle( "Tabbed Pane Application" );
		setSize( 300, 200 );
		setBackground( Color.gray );
 
		JPanel topPanel = new JPanel();
		topPanel.setLayout( new BorderLayout() );
		getContentPane().add( topPanel );
 
		// Create the tab pages
		createPage1();
 
 
		// Create a tabbed pane
		tabbedPane = new JTabbedPane();
		tabbedPane.addTab( "Page 1", panel1 );
		tabbedPane.addTab( "Page 2", panel1 );
		tabbedPane.addTab( "Page 3", panel1 );
		topPanel.add( tabbedPane, BorderLayout.CENTER );
	}
 
	public void createPage1()
	{
		panel1 = new JPanel();
		panel1.setLayout( null );
 
		JLabel label1 = new JLabel( "Username:" );
		label1.setBounds( 10, 15, 150, 20 );
		panel1.add( label1 );
 
		JTextField field = new JTextField();
		field.setBounds( 10, 35, 150, 20 );
		panel1.add( field );
 
		JLabel label2 = new JLabel( "Password:" );
		label2.setBounds( 10, 60, 150, 20 );
		panel1.add( label2 );
 
		JPasswordField fieldPass = new JPasswordField();
		fieldPass.setBounds( 10, 80, 150, 20 );
		panel1.add( fieldPass );
	}
 
 
 
    // Main method to get things started
	public static void main( String args[] )
	{
		// Create an instance of the test application
		TabbedPaneExample mainFrame	= new TabbedPaneExample();
		mainFrame.setVisible( true );
	}
}