| | |
Unable to expand window
![]() |
•
•
Join Date: Sep 2009
Posts: 28
Reputation:
Solved Threads: 0
I have a GUI window with a JFrame. On this JFrame, I have a JPanel that completely covers the JFrame. I then have another JPanel within this first JPanel that contains a text box and 3 buttons. Within an event handler, I want to expand the JFrame and 2 JPanels by a height of 20 px. I then want to move down the text box and 3 buttons, 20 px.
I can expand the JFrame and the first JPanel with the following code snip. But, it doesn't work on the second panel nor does it work to move the button down.
Appreciate your help. Thanks..
I can expand the JFrame and the first JPanel with the following code snip. But, it doesn't work on the second panel nor does it work to move the button down.
Appreciate your help. Thanks..
Java Syntax (Toggle Plain Text)
// Make room for an additional text box int heightInc = 20; Dimension frameSize = new Dimension(); Rectangle rectangle = new Rectangle(); // Adjust JFrame size (This Works) frameSize = this.getSize(); frameSize.height += heightInc; this.setSize(frameSize); // Adjust the bounding JPanel size (This Works) frameSize = jplFrame.getSize(); frameSize.height += heightInc; jplFrame.setPreferredSize(frameSize); // Adjust the AddSubtitle JPanel size (This doesn't work) frameSize = jplAddSubtitle.getSize(); frameSize.height += heightInc; jplAddSubtitle.setPreferredSize(frameSize); // Move the "Add Another" button down (This doesn't work) rectangle = btnAddAnother.getBounds(); rectangle.y += heightInc; btnAddAnother.setBounds(rectangle);
•
•
Join Date: Oct 2009
Posts: 18
Reputation:
Solved Threads: 0
0
#4 16 Days Ago
Ok then, netbeans uses free design witch actually is GroupLayout if you take a look in the generated code for components initialization.
You could change the layout to Absolute for the both Panels and then use:
You could change the layout to Absolute for the both Panels and then use:
Java Syntax (Toggle Plain Text)
// Adjust the AddSubtitle JPanel size rectangle = jplAddSubtitle.getBounds(); rectangle.height += heightInc; jplAddSubtitle.setBounds(rectangle); // Move the "Add Another" button down rectangle = btnAddAnother.getBounds(); rectangle.y += heightInc; btnAddAnother.setBounds(rectangle);
Last edited by AndreiDMS; 16 Days Ago at 7:51 am.
•
•
Join Date: Sep 2009
Posts: 28
Reputation:
Solved Threads: 0
0
#7 14 Days Ago
I was unable to set the layout to Absolute. I just don't know how to do it. I'm too new at the Java stuff. I ended up realizing I had no idea how to proceed. Do I delete everything I have layout with NetBeans "Free Design" and start over specifying Absolute layout? Or, can I insert some code that will over ride the GrouplLayout with the Absolute Layout. You can see, I really don't understand the mechanism of using any of the layout managers other then the "Free Design.: Maybe in a couple of months, I be "smarter."
So, I took the lazy way out and changed my design so I don't need to expand the dialog.
So, I took the lazy way out and changed my design so I don't need to expand the dialog.
Last edited by bruceaj; 14 Days Ago at 5:11 pm.
•
•
Join Date: Oct 2009
Posts: 18
Reputation:
Solved Threads: 0
0
#8 14 Days Ago
In your Design view, just select the Panel you want to set the layout for then right-click on it -> select Set Layout -> Absolute Layout (or any other layout you want to use).
Read this A Visual Guide to Layout Managers, I'm sure It will help you to get started
GL with your programming
Read this A Visual Guide to Layout Managers, I'm sure It will help you to get started
GL with your programming
![]() |
Similar Threads
- Gettin window dimension problems with onresize (JavaScript / DHTML / AJAX)
- Detail for StartupRepairV2 (Unable Access Window Vista) (Windows Vista and Windows 7)
- wx.lib.plot.py (Python)
- Last game q (I promise!) (Java)
- The Perfect Website (Site Layout and Usability)
- can`t open more than one window of internet explorer (Web Browsers)
- Trojan.Cachecachekit Help!! (Viruses, Spyware and other Nasties)
- white flickering lines - viewsonic crt (Monitors, Displays and Video Cards)
- Cleaning out Popup Problems on XP (Viruses, Spyware and other Nasties)
- hyperlink problem (Windows NT / 2000 / XP)
Other Threads in the Java Forum
- Previous Thread: Error Message
- Next Thread: public void close () VS. private void close ()
| Thread Tools | Search this Thread |
2dgraphics 3d @param affinetransform android api apple applet application arc arguments array arrays automation banking binary binarytree bluetooth chatprogramusingobjects class client code color compare component count database derby design detection eclipse eclipsedevelopment encryption error fractal game givemetehcodez graphics gridlayout gui guitesting helpwithhomework html ide if_statement image integer interface j2me java java.xls javadesktopapplications javaprojects jni jpanel julia keytool keyword linux list macintosh map method methods mobile netbeans object os pong problem producer program programming project projectideas property read recursion reference replaysolutions rim scanner server set size sms sort sql stop string swing terminal threads transforms tree ui unicode validation web windows





