import javax.swing.*; import java.io.*; import java.awt.*; import java.awt.event.*; class sacreate extends JFrame implements ActionListener { JLabel l1,l2,l3,l4,a,b,c; Container pane; JPanel p1,p2,p3; JTextField t1; JComboBox c1,c2; JCheckBox m1; JButton b1,b2,b3; public sacreate() { try { pane=getContentPane(); l1=new JLabel("FieldName"); a=new JLabel(" "); l2=new JLabel("DataType"); b=new JLabel(" "); l3=new JLabel("NotNull"); c=new JLabel(" "); l4=new JLabel("Null"); t1=new JTextField(15); c1=new JComboBox(); c1.addItem("VARCHAR"); c1.addItem("INTEGER"); c1.addItem("CHARACTER"); c2=new JComboBox(); c2.addItem("PrimaryKey"); c2.addItem("ForignKey"); m1=new JCheckBox(); b3=new JButton("Done"); b1=new JButton("+"); b2=new JButton("-"); p1=new JPanel(); p2=new JPanel(); p3=new JPanel(); p1.add(l1); p1.add(a); p1.add(l2); p1.add(b); p1.add(l3); p1.add(c); p1.add(l4); p2.add(t1); p2.add(c1); p2.add(c2); p2.add(m1); p2.add(b3); p2.add(b1); p2.add(b2); p3.add(p1); p3.add(p2); pane.add(p3); p1.setLayout(new FlowLayout(FlowLayout.LEFT)); p2.setLayout(new FlowLayout(FlowLayout.LEFT)); p3.setLayout(new BorderLayout()); p3.add(p1,BorderLayout.NORTH); p3.add(p2,BorderLayout.SOUTH); setLayout(new FlowLayout()); b1.addActionListener(this); b2.addActionListener(this); } catch(Exception e) { System.out.println(e.toString()); } } public void actionPerformed(ActionEvent ae) { JPanel p = new JPanel(); Dimension size=p.getSize(); System.out.println(size); p.setPreferredSize(new Dimension(1600,35)); JTextField t=new JTextField(15); JComboBox m=new JComboBox(); m.addItem("VARCHAR"); m.addItem("INTEGER"); m.addItem("CHARACTER"); JComboBox n=new JComboBox(); n.addItem("PrimaryKey"); n.addItem("ForignKey"); JCheckBox c=new JCheckBox(); JButton o=new JButton("Done"); JButton r=new JButton("+");/*after pressing this '+' button i have to get next panel with some components but by clicking '+' and by minimizing and maximizing the window only i am able to see the next panel why?*/ r.addActionListener(this); JButton q=new JButton("-"); q.addActionListener(this); if(ae.getActionCommand()=="+") { pane.add(p); p.add(t); p.add(m); p.add(n); p.add(c); p.add(o); p.add(r); p.add(q); p.revalidate(); p.setLayout(new FlowLayout()); } if(ae.getActionCommand()=="-") { /*p.remove(t); p.remove(m); p.remove(n); p.remove(c); p.remove(o); p.remove(r); p.remove(q);*/ pane.remove(p); pane.revalidate(); pane.repaint(); } } public static void main(String args[]) { sacreate a=new sacreate(); a.setSize(300,300); a.setVisible(true); a.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); a.setLocationRelativeTo(null); } }