Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.java.gui > #226

problem with setting a pa

From "Adam Sandler" <adam.sandler@THRWHITE.remove-dii-this>
Subject problem with setting a pa
Message-ID <1164729419.208051.309040@h54g2000cwb.googlegroups.com> (permalink)
Newsgroups comp.lang.java.gui
Date 2011-04-27 15:26 +0000
Organization TDS.net

Show all headers | View raw


  To: comp.lang.java.gui
Hello,

I'm trying to make a GUI which looks like this:

|----------------------------|
|Please Wait...        o O X |
|----------------------------|
|                            |
|  |----------------------|  |
|  |                      |  | <--- centerPanel
|  |----------------------|  |
|                            |
|----------------------------|

|____________________________|
            |
            |
          frame

Here's the code:

public class MyFrame extends JFrame
{
  private static final long serialVersionUID = 1L;

  public void showFrame()
  {
      setTitle( "Please Wait..." );
      setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

      JPanel centerPanel = new JPanel();
      centerPanel.setBorder(BorderFactory.createLoweredBevelBorder());
      centerPanel.setSize(new Dimension(50, 25));

      Dimension screenDim =
Toolkit.getDefaultToolkit().getScreenSize();
      Rectangle winRect = getBounds();
      setLocation((screenDim.width - winRect.width) /
2,(screenDim.height - winRect.height) / 2);

      getContentPane().add(centerPanel);
      setSize(225, 100);
      setVisible(true);
  }
}

The problem is that centerPanel is taking on the same dimensions as the
frame.  I've read in this NG that setPreferredSize can be problematic
and my use of "centerPanel.setSize(new Dimension(50, 25));" seems to be
either ignored or overridden somehow.  How can I size centerPanel to my
needs?

I also tried creating another panel without setting the size, putting
it in the frame and then putting centerPanel in that other panel.  I
got the same results.

Suggestions are greatly appreciated!

Thanks.

---
 * 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

Back to comp.lang.java.gui | Previous | NextNext in thread | Find similar


Thread

problem with setting a pa "Adam Sandler" <adam.sandler@THRWHITE.remove-dii-this> - 2011-04-27 15:26 +0000
  Re: problem with setting "Michael Dunn" <michael.dunn@THRWHITE.remove-dii-this> - 2011-04-27 15:26 +0000
  Re: problem with setting "Adam Sandler" <adam.sandler@THRWHITE.remove-dii-this> - 2011-04-27 15:26 +0000
    Re: problem with setting "Michael Dunn" <michael.dunn@THRWHITE.remove-dii-this> - 2011-04-27 15:26 +0000
      Re: problem with setting "Adam Sandler" <adam.sandler@THRWHITE.remove-dii-this> - 2011-04-27 15:26 +0000
    Re: problem with setting "Oliver Wong" <oliver.wong@THRWHITE.remove-dii-this> - 2011-04-27 15:26 +0000
    Re: problem with setting "Fred Kleinschmidt" <fred.kleinschmidt@THRWHITE.remove-dii-this> - 2011-04-27 15:26 +0000
  Re: problem with setting "Andrew Thompson" <andrew.thompson@THRWHITE.remove-dii-this> - 2011-04-27 15:26 +0000
  Re: problem with setting "Andrew Thompson" <andrew.thompson@THRWHITE.remove-dii-this> - 2011-04-27 15:26 +0000
  Re: problem with setting "Adam Sandler" <adam.sandler@THRWHITE.remove-dii-this> - 2011-04-27 15:26 +0000
  Re: problem with setting "Andrew Thompson" <andrew.thompson@THRWHITE.remove-dii-this> - 2011-04-27 15:26 +0000
    Re: problem with setting "Adam Sandler" <adam.sandler@THRWHITE.remove-dii-this> - 2011-04-27 15:26 +0000

csiph-web