aspose file tools*
The moose likes Swing / AWT / SWT and the fly likes FlowLayout issue Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "FlowLayout issue" Watch "FlowLayout issue" New topic
Author

FlowLayout issue

Jeff Burel
Greenhorn

Joined: Jan 14, 2009
Posts: 12
I am looking for some assistance with two questions.
1. How do I make the 'About' button show in the 'bowling prices' window and then 'launch in another frame' frame open when clicking 'About' from the 'Bowling Prices' window.
2. FlowLayout isn't showing all my fields as I need it to. The "Bowler Type" field has data that is not showing.

I don't have to use flowlayout, if another layout would work better please advise.

pete stein
Bartender

Joined: Feb 23, 2007
Posts: 1561
Does your current code compile?

In particular, do these lines compile?



Also, you seem to be trying to add the same components to a JPanel and to the contentPane both at the same time. Why?

You shouldn't have a FlowLayout() statement when adding a component as you've done above, and also, it almost appears as if you are trying to call the FlowLayout constructor without new which is never done in Java much less in Swing.

I strongly advise you to read the layout manager section of the Swing tutorials with attention to the FlowLayout, the BorderLayout, and the GridLayout. Later I'd add the BoxLayout, and much later the GridBagLayout. After reading this section, consider using nested JPanels to hold your components with each JPanel using its own layout manager. For instance you could let the contentPane use its default BorderLayout, then have a top panel that holds your jlabel, your jtextfield (though a jspinner that uses a spinnernumbermodel may work better here), and your jcheckbox. This could be placed in the contentPane BorderLayout.NORTH. Then add your jtextarea to a jscrollpane and add it BorderLayout.CENTER, and finally place whatever buttons you need, including the about button in its own JPanel that uses the default FlowLayout or GridLayout, and place it in the contentPane BorderLayout.SOUTH. Good luck, and YMMV.

Pete
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 36514
    
  16
Pete Stein is right. It might be worthwhile looking for MigLayout too (Google). Also find the Java Tutorials on the Sun website, and there is a section about different layouts.
Jeff Burel
Greenhorn

Joined: Jan 14, 2009
Posts: 12
My code does not compile, sorry I thought I included the errors. We have not covered MigLayout in my class. I have to use BorderLayout, FlowLayout, or Boxlayout in this project. Here are the errors I get when compiling right now.

Project01b.java:33: cannot find symbol
symbol : method FlowLayout()
location: class Project01b
panel.add(choice, FlowLayout());
^
Project01b.java:35: cannot find symbol
symbol : method FlowLayout()
location: class Project01b
panel.add(choice, FlowLayout());
^
Project01b.java:38: cannot find symbol
symbol : method FlowLayout()
location: class Project01b
panel.add(choice, FlowLayout());
^
3 errors
Suraj Chandran
Ranch Hand

Joined: May 20, 2008
Posts: 53
I think you are using it the wrong way,. Try something like this:
panel.setLayout(new FlowLayout());
panel.add(choice);

OR

panel.setLayout(new BorderLayout());
panel.add(choice, BorderLayout.SOUTH);

I guess there are couple of design issues in this classic software the GOD coded.
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 36514
    
  16
Suraj Chandran has given you the answer. You won't cover MigLayout in lectures; it is not a standard Java class, but its designers are trying to get it incorporated into Java. A lot of people say it is easier to use than GridBag or GroupLayout, but I have never tried it myself.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: FlowLayout issue
 
Similar Threads
values changed, math didnt.
Can't write collection back to disk
values changed, math didnt.
GUI problem
Help with getting program to compile.