Win a copy of Cross-Platform Desktop Applications: Using Node, Electron, and NW.js this week in the JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Problem with setLayout  RSS feed

 
Mary Connolly
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The commented line below is not working. I am getting a cannot resolve symbol error. Can anyone give me any help!!! I have tried SearchPanel and SearchFrame.getContentPane() instead of SearchFrame in the commented out line.
thanks!

public SearchGUI()
{ SearchFrame = new JFrame ("Search Blood Results");
SearchFrame.setDefaultCloseOperation (JFrame.EXIT_ON_CLOSE);
SearchNHSNumberLabel = new JLabel("NHS Number");
SearchNHSNumberText = new JTextField(10);
SearchButton = new JButton ("Search");
SearchButton.addActionListener (new ButtonListener());
SearchPanel = new JPanel();
SearchPanel.setPreferredSize(new Dimension(800, 600));
SearchPanel.add (SearchNHSNumberLabel);
SearchPanel.add (SearchNHSNumberText);
SearchPanel.add (SearchButton);
SearchFrame.getContentPane().add(SearchPanel);
//setLayout (new BoxLayout (SearchFrame, BoxLayout.Y_AXIS));
}
 
Nathan Pruett
Bartender
Posts: 4121
IntelliJ IDE Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It should probably be something like :


It looks like the problem is that you are trying to set a layout on the SearchGUI class, which (I'm guessing) isn't really a Container.
 
Consider Paul's rocket mass heater.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!