Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.java.gui > #1986 > unrolled thread
| Started by | "sirke.pippig" <sirke.pippig@THRWHITE.remove-dii-this> |
|---|---|
| First post | 2011-04-27 15:36 +0000 |
| Last post | 2011-04-27 15:36 +0000 |
| Articles | 7 — 5 participants |
Back to article view | Back to comp.lang.java.gui
Strange resizeing with Gr "sirke.pippig" <sirke.pippig@THRWHITE.remove-dii-this> - 2011-04-27 15:36 +0000
Re: Strange resizeing wit "Andrew Thompson" <andrew.thompson@THRWHITE.remove-dii-this> - 2011-04-27 15:36 +0000
Re: Strange resizeing wit "Roedy Green" <roedy.green@THRWHITE.remove-dii-this> - 2011-04-27 15:36 +0000
Re: Strange resizeing wit "Tom Hawtin" <tom.hawtin@THRWHITE.remove-dii-this> - 2011-04-27 15:36 +0000
Re: OT: Strange resizeing "Thomas Fritsch" <thomas.fritsch@THRWHITE.remove-dii-this> - 2011-04-27 15:36 +0000
Re: Strange resizeing wit "Roedy Green" <roedy.green@THRWHITE.remove-dii-this> - 2011-04-27 15:36 +0000
Re: Strange resizeing wit "Roedy Green" <roedy.green@THRWHITE.remove-dii-this> - 2011-04-27 15:36 +0000
| From | "sirke.pippig" <sirke.pippig@THRWHITE.remove-dii-this> |
|---|---|
| Date | 2011-04-27 15:36 +0000 |
| Subject | Strange resizeing with Gr |
| Message-ID | <1183977869.068626.322760@k79g2000hse.googlegroups.com> |
To: comp.lang.java.gui
Hi,
I'm using GridBagLayout to organize my components. Everything is
working fine.But if I resize the Frame I detected a strange behavior.
I have one panel on the left side and one panel on the right side.The
left panel should be 1/3 and the right on 2/3 of the frame size. If
the frame ist small (200X200) the size is ok. But if I resize the
frame to 800 X 600 the devision is nearly 1/2 to 1/2.
This hapends only if I have scrollPanels with tables in each panel.
Does anybody know this behavior.
Here is the source code:
import java.awt.Color;
import java.awt.GridBagConstraints;
import java.awt.GridBagLayout;
import java.awt.Insets;
import java.awt.event.ActionEvent;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JTable;
public class TestPanel extends JPanel {
GridBagLayout gridBagLayout1 = new GridBagLayout();
JPanel ofPanel2 = new JPanel();
JPanel ofPanel3 = new JPanel();
GridBagLayout gridBagLayout2 = new GridBagLayout();
GridBagLayout gridBagLayout3 = new GridBagLayout();
JScrollPane jScrollPane1 = new JScrollPane();
JScrollPane jScrollPane2 = new JScrollPane();
JTable jTable1 = new JTable();
JTable jTable2 = new JTable();
/** Konstruktor */
public TestPanel() {
super();
try {
jbInit();
}
catch(RuntimeException l_ex) {
throw l_ex;
}
catch(Exception l_ex) {
l_exception.printStackTrace(System.out);
}
}
public void eventAction(ActionEvent p_event, Object[] p_eventInfo) {
}
void jbInit() throws Exception {
this.setLayout(gridBagLayout1);
setComponentName();
ofPanel2.setBackground(Color.green);
ofPanel2.setLayout(gridBagLayout2);
ofPanel3.setBackground(Color.yellow);
ofPanel3.setLayout(gridBagLayout3);
jScrollPane2.getViewport().setBackground(Color.blue);
jScrollPane1.getViewport().setBackground(Color.cyan);
this.add(ofPanel2, new GridBagConstraints(0, 0, 1, 1, 0.5, 1.0
,GridBagConstraints.CENTER, GridBagConstraints.BOTH, new
Insets(0, 0, 0, 0), 0, 0));
ofPanel2.add(jScrollPane1, new GridBagConstraints(0, 0, 1, 1, 1,
1.0
,GridBagConstraints.CENTER, GridBagConstraints.BOTH, new
Insets(0, 0, 0, 0), 0, 0));
jScrollPane1.getViewport().add(jTable1, null);
this.add(ofPanel3, new GridBagConstraints(1, 0, 1, 1, 1.0, 1.0
,GridBagConstraints.CENTER, GridBagConstraints.BOTH, new
Insets(0, 0, 0, 0), 0, 0));
ofPanel3.add(jScrollPane2, new GridBagConstraints(0, 0, 1, 1,
1.0, 1.0
,GridBagConstraints.CENTER, GridBagConstraints.BOTH, new
Insets(0, 0, 0, 0), 0, 0));
jScrollPane2.getViewport().add(jTable2, null);
}
public static void main(String[] p_args) {
try {
JFrame l_frame = new JFrame();
TestPanel l_ctl;
l_ctl = new TestPanel();
l_frame.setContentPane(l_ctl);
l_frame.setSize(l_ctl.getSize());
l_frame.addWindowListener(new WindowAdapter() {
public void windowClosing(WindowEvent p_event) {
System.exit(0);
}
;
});
l_frame.setVisible(true);
l_frame.pack();
} catch (Throwable l_exception) {
l_exception.printStackTrace(System.out);
}
}
private void setComponentName() {
}
}
---
* Synchronet * The Whitehouse BBS --- whitehouse.hulds.com --- check it out free usenet!
--- Synchronet 3.15a-Win32 NewsLink 1.92
Time Warp of the Future BBS - telnet://time.synchro.net:24
[toc] | [next] | [standalone]
| From | "Andrew Thompson" <andrew.thompson@THRWHITE.remove-dii-this> |
|---|---|
| Date | 2011-04-27 15:36 +0000 |
| Subject | Re: Strange resizeing wit |
| Message-ID | <74e998be0c707@uwe> |
| In reply to | #1986 |
To: comp.lang.java.gui sirke.pippig@gmx.de wrote: .. >I'm using GridBagLayout to organize my components. GBL breaks down for components with no minimum size defined, or it might be that the problem occurs when components simply 'get too small'. I avoid GBL generally, and am a bit hazy on the details. In any case, I did a quick test changing (the one line needed changing to make that compilable &) the JTables with no data, for JTrees (which get default data automatically) and noted that the layout starts to behave as you describe you want. The left area has around 1/3, the right 2/3 - all the way from minimum size to full screen (1024x768). If you need this UI to behave even when those tables are empty, I suggest you look into setting not just preferred size, but also minimum and (go the hat trick) maximum sizes for the JTables or the JScrollPanes. HTH -- Andrew Thompson http://www.athompson.info/andrew/ Message posted via http://www.javakb.com --- * Synchronet * The Whitehouse BBS --- whitehouse.hulds.com --- check it out free usenet! --- Synchronet 3.15a-Win32 NewsLink 1.92 Time Warp of the Future BBS - telnet://time.synchro.net:24
[toc] | [prev] | [next] | [standalone]
| From | "Roedy Green" <roedy.green@THRWHITE.remove-dii-this> |
|---|---|
| Date | 2011-04-27 15:36 +0000 |
| Subject | Re: Strange resizeing wit |
| Message-ID | <j21593l6qarojdru5g0985hebu1c30kd59@4ax.com> |
| In reply to | #1986 |
To: comp.lang.java.gui
Code makes no sense
catch ( RuntimeException l_ex )
{
throw l_ex;
}
catch ( Exception l_ex )
{
l_ex.printStackTrace(System.out);
}
Just leave out the first catch . It does nothing.
--
Roedy Green Canadian Mind Products
The Java Glossary
http://mindprod.com
---
* Synchronet * The Whitehouse BBS --- whitehouse.hulds.com --- check it out free usenet!
--- Synchronet 3.15a-Win32 NewsLink 1.92
Time Warp of the Future BBS - telnet://time.synchro.net:24
[toc] | [prev] | [next] | [standalone]
| From | "Tom Hawtin" <tom.hawtin@THRWHITE.remove-dii-this> |
|---|---|
| Date | 2011-04-27 15:36 +0000 |
| Subject | Re: Strange resizeing wit |
| Message-ID | <4692875c$0$8741$ed2619ec@ptn-nntp-reader02.plus.net> |
| In reply to | #1995 |
To: comp.lang.java.gui
Roedy Green wrote:
> Code makes no sense
>
> catch ( RuntimeException l_ex )
> {
> throw l_ex;
> }
> catch ( Exception l_ex )
> {
> l_ex.printStackTrace(System.out);
> }
>
> Just leave out the first catch . It does nothing.
Not true. Both catches catch over the try block only. The throw bypasses
the second catch. OTOH, I've no idea why jbInit (hopeless method name,
btw) is declared to throw Exception.
Tom Hawtin
---
* Synchronet * The Whitehouse BBS --- whitehouse.hulds.com --- check it out free usenet!
--- Synchronet 3.15a-Win32 NewsLink 1.92
Time Warp of the Future BBS - telnet://time.synchro.net:24
[toc] | [prev] | [next] | [standalone]
| From | "Thomas Fritsch" <thomas.fritsch@THRWHITE.remove-dii-this> |
|---|---|
| Date | 2011-04-27 15:36 +0000 |
| Subject | Re: OT: Strange resizeing |
| Message-ID | <newscache$npjykj$ing$1@news.ops.de> |
| In reply to | #1999 |
To: comp.lang.java.gui Tom Hawtin wrote: > OTOH, I've no idea why jbInit (hopeless method name, > btw) is declared to throw Exception. jbInit is just the idiosyncratic method from JBuilder's (hence "jb") GUI-Code-Generator. I remember one can safely remove that silly "throws Exception" from the method; JBuilder will not regenerate it. -- Thomas --- * Synchronet * The Whitehouse BBS --- whitehouse.hulds.com --- check it out free usenet! --- Synchronet 3.15a-Win32 NewsLink 1.92 Time Warp of the Future BBS - telnet://time.synchro.net:24
[toc] | [prev] | [next] | [standalone]
| From | "Roedy Green" <roedy.green@THRWHITE.remove-dii-this> |
|---|---|
| Date | 2011-04-27 15:36 +0000 |
| Subject | Re: Strange resizeing wit |
| Message-ID | <36159353jb8rt7ph87rvgac3c21h7t4oje@4ax.com> |
| In reply to | #1986 |
To: comp.lang.java.gui
On Mon, 09 Jul 2007 03:44:29 -0700, sirke.pippig@gmx.de wrote, quoted
or indirectly quoted someone who said :
> catch(Exception l_ex) {
> l_exception.printStackTrace(System.out);
> }
this does not even compile.
--
Roedy Green Canadian Mind Products
The Java Glossary
http://mindprod.com
---
* Synchronet * The Whitehouse BBS --- whitehouse.hulds.com --- check it out free usenet!
--- Synchronet 3.15a-Win32 NewsLink 1.92
Time Warp of the Future BBS - telnet://time.synchro.net:24
[toc] | [prev] | [next] | [standalone]
| From | "Roedy Green" <roedy.green@THRWHITE.remove-dii-this> |
|---|---|
| Date | 2011-04-27 15:36 +0000 |
| Subject | Re: Strange resizeing wit |
| Message-ID | <p815939r66acpld520cmqtab1g2994u0ge@4ax.com> |
| In reply to | #1986 |
To: comp.lang.java.gui On Mon, 09 Jul 2007 03:44:29 -0700, sirke.pippig@gmx.de wrote, quoted or indirectly quoted someone who said : > >I have one panel on the left side and one panel on the right side.The >left panel should be 1/3 and the right on 2/3 of the frame size. If >the frame ist small (200X200) the size is ok. But if I resize the >frame to 800 X 600 the devision is nearly 1/2 to 1/2. Strange . On my machine the panels stay roughly 1/3.: 2/3 at any size. I am using JDK 1.6.0_01 -- Roedy Green Canadian Mind Products The Java Glossary http://mindprod.com --- * Synchronet * The Whitehouse BBS --- whitehouse.hulds.com --- check it out free usenet! --- Synchronet 3.15a-Win32 NewsLink 1.92 Time Warp of the Future BBS - telnet://time.synchro.net:24
[toc] | [prev] | [standalone]
Back to top | Article view | comp.lang.java.gui
csiph-web