import javax.swing.*; import javax.swing.event.*; import java.awt.*; import java.awt.event.*; import java.io.*; public class BaseTab extends JFrame implements ActionListener { JButton ok; JLabel label1; JTextField text1; JTabbedPane jt; JPanel p7,p1,p2,p3,p4,p5; JMenuBar mb=new JMenuBar(); JMenu lg=new JMenu("Logout"); JMenu hm=new JMenu("Home"); BaseTab() { //window appearence setTitle("BaseTab"); setSize(this.getMaximumSize()); setDefaultCloseOperation(EXIT_ON_CLOSE); setVisible(true); setJMenuBar(mb); mb.add(hm); mb.setSelected(hm); mb.add(Box.createHorizontalGlue()); mb.add(lg); p7=new JPanel(); p7.setPreferredSize(new Dimension(1600,1450)); p7.setLayout(new BorderLayout()); getContentPane().add(p7); createPage(); jt=new JTabbedPane(); jt.addTab("CREATE",p1); jt.addTab("INSERT",p2); jt.addTab("UPDATE",p3); jt.addTab("VIEW",p4); p7.add(jt,BorderLayout.CENTER); } public void createPage() { label1 = new JLabel(); label1.setText("TableName"); text1 = new JTextField(15); ok=new JButton("ok"); p1=new JPanel(); p1.setLayout( null ); p1.add(label1); p1.add(text1); p1.add(ok); p1.setLayout(new FlowLayout()); setLayout(new FlowLayout()); ok.addActionListener(this); } public void actionPerformed(ActionEvent ae) { if(ae.getActionCommand()=="ok") { String value1=text1.getText(); if (value1.equals("cse")) { /* here exits my problem that i need to get components of sacreate page when create tab is clicked*/ sacreate page=new sacreate(); page.add(p1); } } } public static void main(String args[])throws Exception { SwingUtilities.invokeLater(new Runnable() { public void run() { BaseTab bt=new BaseTab(); } } ); } }