| | |
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 23 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; 23 Days Ago at 7:51 am.
•
•
Join Date: Sep 2009
Posts: 28
Reputation:
Solved Threads: 0
0
#7 21 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; 21 Days Ago at 5:11 pm.
•
•
Join Date: Oct 2009
Posts: 18
Reputation:
Solved Threads: 0
0
#8 21 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 |
add android api applet application applications array arrays automation bank binary bluetooth chat class clear client code codesnippet collections component converter database development dice digit eclipse equation error event formatingtextintooltipjava fractal functiontesting game givemetehcodez graphics gui health html hyper ide idea image infinite input int integer j2me java javame javaprojects jni jpanel julia linux list loop looping main map method methods mobile myregfun mysql netbeans newbie nonstatic openjavafx parameter pearl php print problem program programming project recursion repositories scanner scrollbar server set size sms sort sorting spamblocker sql sqlserver state storm string superclass swing swt text-file thread threads tree windows





