Results 1 to 9 of 9
Thread: Problem with layout manager
- 09-05-2011, 02:33 AM #1
Member
- Join Date
- Jul 2011
- Posts
- 76
- Rep Power
- 0
Problem with layout manager
I have been having this problem for quit a while which has force me to use the setBounds method. Whenever i use a layout manager sometime or most times the components are not displayed on screen. What is causing this?
Java Code://MSMsys Constructor public MSMsys () { setTitle ("Management System \tMSMsys"); setVisible (true); setSize (500,400); setDefaultCloseOperation (EXIT_ON_CLOSE); setLocation (300,200); setLayout (new FlowLayout ()); setMenuBar (); setUserLogInPanel (); }//end constructor //Displays logInPanel with login components public void setUserLogInPanel () { //Create Components JLabel userNameLabel = new JLabel ("User Name: "); JLabel passwordLabel = new JLabel ("Password: "); JPanel logInPane = new JPanel (); logInPane.setBorder(BorderFactory.createTitledBorder ("User Login")); logInPane.setLayout (null); //Initialize instance variables userNameTF = new JTextField (10); passwordTF = new JPasswordField (10); logInButt = new JButton ("Login"); add(logInPane); logInPane.add(logInButt); //logInPane.setBounds (50,20,280,200); //logInButt.setBounds (50,20,30,30); logInButt.addActionListener (new EventHandler ()); }//logInPanelLast edited by mDennis10; 09-05-2011 at 02:59 AM.
- 09-05-2011, 02:38 AM #2
Re: Problem with layout manager
Well obviously the answer to your problem is
-
Re: Problem with layout manager
You're not using the layout managers correctly.
For a more detailed answer, consider providing a more detailed question. Please see my links below for more on what we need.
- 09-05-2011, 02:40 AM #4
Re: Problem with layout manager
Problem with layout manager
Double posted with more information but still not a complete post.
-
- 09-05-2011, 02:50 AM #6
Member
- Join Date
- Jul 2011
- Posts
- 76
- Rep Power
- 0
Re: Problem with layout manager
sorry about that
-
Re: Problem with layout manager
I see that you've edited your post and now have added some code, but your code won't compile nor run for us. We don't want or need the whole program but it would be helpful for you post a small compilable runnable program that demonstrates your problem, an SSCCE. Also, read the layout manager tutorials thoroughly before using them as well as the api, and you'll see that you shouldn't be using setSize or setBounds on anything. Also, please inform us of any and all places where you've cross-posted this question. Not doing so is bad forum etiquette as we may be wasting time answering a question that has already been answered.
- 09-05-2011, 03:00 AM #8
Re: Problem with layout manager
I'm no swing expert but you might want to move the call to setVisible to be the last line.
-
Re: Problem with layout manager
Similar Threads
-
Simple GUI layout manager
By globo in forum New To JavaReplies: 3Last Post: 11-16-2010, 01:17 AM -
Layout Manager
By globo in forum New To JavaReplies: 8Last Post: 11-01-2010, 12:19 AM -
Layout manager
By Nicholas Jordan in forum Java AppletsReplies: 2Last Post: 11-24-2008, 03:02 PM -
Layout Manager of JApplet
By Peter_APIIT in forum Java AppletsReplies: 10Last Post: 07-19-2008, 05:37 AM -
MiG Layout Manager 2.4
By levent in forum Java SoftwareReplies: 0Last Post: 05-16-2007, 05:11 AM


2Likes
LinkBack URL
About LinkBacks
Reply With Quote

Bookmarks