in the below code i am trying to create tabs.
1-according to the code below, the jlabel the contains the word "Demo", at run time, it does not show up! why that is happening and how to force that jlabel to appear?
2-as you see in the code, the function createTab1() should create jTextField and JPasswordField. at run time they are appearing but they are alligined horizontally, what i want is, to display the JTextField and its jlabel beside each other horizontally and the second jlabel and the JpassworfField beside each other but under the jTextField and its jLabel, as shown below:
Labe jtextField
label jPasswordField
but the code below result the GUI shown in
Code:
private void setUpGUI() {
// TODO Auto-generated method stub
jFrame_Main = new JFrame("Main Window");
jPanel_ContainerPanel = new JPanel(new BorderLayout());
jPanel_ContainerPanel.setBorder(BorderFactory.createLoweredBevelBorder());
jLabel_ContainerLabel = new JLabel("Demo");
jLabel_ContainerLabel.setHorizontalAlignment(SwingConstants.CENTER);
jPanel_ContainerPanel.add(jLabel_ContainerLabel, BorderLayout.NORTH);
createTab1();
//createTab2();
jTabbedPane = new JTabbedPane();
jTabbedPane.add("tab1", jPanel1);
jFrame_Main.getContentPane().add(jPanel_ContainerPanel);
jFrame_Main.getContentPane().add(jTabbedPane);
jFrame_Main.pack();
jFrame_Main.setVisible(true);
}
private void createTab1() {
// TODO Auto-generated method stub
jPanel1 = new JPanel();
jPanel1.setBounds(10, 15, 150, 20);
jLabel1 = new JLabel("userName");
jPanel1.add(jLabel1);
JTextField field = new JTextField();
field.setBounds( 10, 35, 150, 50 );
jPanel1.add( field );
JLabel label2 = new JLabel( "Password:" );
label2.setBounds( 10, 60, 150, 20 );
jPanel1.add( label2 );
JPasswordField fieldPass = new JPasswordField();
fieldPass.setBounds( 10, 80, 150, 20 );
jPanel1.add( fieldPass );
}
public static void main(String[] args) {
GUITabs guiTabs = new GUITabs();
}
}