Note that there are some explanatory texts on larger screens.

plurals
  1. POAdding new Tab with JTabbedPane through event
    primarykey
    data
    text
    <p>I have two classes here: MainScreen and QueryScreen. MainScreen has already implemented one JTabbedPane on int. QueryScreen extended the MainScreen. I tryed to add one tab calling one event through QueryScreen but its not coming up on the app. Checkout please the sample code:</p> <p>QuerryScreen:</p> <pre><code> public class QueryScreen extends MainScreen { private JSplitPane engineList; final JPanel queryList = new JPanel(); public QueryScreen(){ tabbedPane.addTab( "Query List", queryList ); add( tabbedPane, BorderLayout.CENTER ); } } </code></pre> <p>MainScreen:</p> <pre><code> public class MainScreen extends JFrame implements ActionListener { /** * */ JMenuBar bar; JMenu file, register; JMenuItem close, search; ImageIcon image1= new ImageIcon("rsc/img/logo.jpg"); JLabel lbImage1; JTabbedPane tabbedPane = new JTabbedPane(); final JPanel entrance = new JPanel(); /** * */ public MainScreen() { lbImage1= new JLabel(image1, JLabel.CENTER); entrance.add(lbImage1); tabbedPane.addTab( "Entrance", entrance ); add( tabbedPane, BorderLayout.CENTER ); bar= new JMenuBar(); file= new JMenu("File"); register= new JMenu("Search"); close= new JMenuItem("Close"); close.addActionListener(this); search= new JMenuItem("Request Query"); search.addActionListener(this); //Keyboard Shortcut register.setMnemonic(KeyEvent.VK_S); file.setMnemonic(KeyEvent.VK_F); search.setMnemonic(KeyEvent.VK_R); //Ibimage1.setVerticalTextPosition(SwingConstants.CENTER); bar.add(file); bar.add(register); file.add(close); register.add(search); setExtendedState(getExtendedState() | JFrame.MAXIMIZED_BOTH); // Maximized Window or setSize(getMaximumSize()); setTitle("SHST"); setJMenuBar(bar); setDefaultCloseOperation(0); WindowListener J=new WindowAdapter(){ public void windowClosing(WindowEvent e){ System.exit(0); } }; addWindowListener(J); } public void actionPerformed(ActionEvent e){ if(e.getSource()==close){ System.exit(0); } if(e.getSource()==search){ Search s= new Search(); s.setVisible(true); } } } </code></pre> <p>ps: the MainScreen object and the setVisible from it is coming from the run class which has only the call for this MainScreen.</p> <p>How am I able to add this new tab?</p> <p>Thanks in advance</p> <p><strong>Edit One:</strong></p> <p><img src="https://i.stack.imgur.com/xFtzg.png" alt="enter image description here"></p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload