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


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

Re: JButton sizing ?

From "TonyB" <tonyb@THRWHITE.remove-dii-this>
Subject Re: JButton sizing ?
Message-ID <VzoFh.46174$ff2.12918@fe02.news.easynews.com> (permalink)
Newsgroups comp.lang.java.gui
References <newscache$y0n6ej$nej$1@news.ops.de>
Date 2011-04-27 15:31 +0000
Organization TDS.net

Show all headers | View raw


  To: comp.lang.java.gui
"Thomas Fritsch" <i.dont.like.spam@invalid.com> wrote in message 
news:newscache$y0n6ej$nej$1@news.ops.de...
> Tony B wrote:
>> Having got my cardlayout working (see earlier post), I am now trying to
>> understand layout of components better.
>>
>> I created a JPanel  with a JTextfield across the top of the panel, full
>> width, and one JButton below on the right. I'm using a borderlayout, with
>> the textfield set PAGE_START, and button set LINE_END.
>> The basic arrangement is as expected, with the textfield across the top,
>> and the button below on the right. My problem is the button vertically
>> fills the whole pane from below the textfield to the bottom of the pane.
>> What I want to is fix the height of the button so it's fixed. and doesn't
>> grow as the pane is resized.
>> I've tried using
>>         button.setMaximumSize(new Dimension (150,10)) ;
>>         button.setMinimumSize(new Dimension (150,10)) ;
>>         button.setPreferredSize(new Dimension (150,10)) ; to try to force
>> the size but these are ignored.
>>
>> Is this possible ?
> Yes, but not with BorderLayout alone. The trick is to use nested JPanels,
> each with its own different layout manager.
> A good tutorial describing this technic is
>  "Effective Layout Management: Short Course"
> 
> http://java.sun.com/developer/onlineTraining/GUI/AWTLayoutMgr/shortcourse.html
> With proper use of layout managers you should never need to call
> setMaximumSize/setMinimumSize/setPreferredSize
>
> -- 
> Thomas

Thanks Thomas. That article is good at explaining this topic.
Tony

---
 * 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 | NextPrevious in thread | Next in thread | Find similar


Thread

JButton sizing ? "Tony B" <tony.b@THRWHITE.remove-dii-this> - 2011-04-27 15:31 +0000
  Re: JButton sizing ? "Thomas Fritsch" <thomas.fritsch@THRWHITE.remove-dii-this> - 2011-04-27 15:31 +0000
    Re: JButton sizing ? "TonyB" <tonyb@THRWHITE.remove-dii-this> - 2011-04-27 15:31 +0000
  Re: JButton sizing ? "Ian Wilson" <ian.wilson@THRWHITE.remove-dii-this> - 2011-04-27 15:31 +0000
    Re: JButton sizing ? "TonyB" <tonyb@THRWHITE.remove-dii-this> - 2011-04-27 15:31 +0000
      Re: JButton sizing ? "Ian Wilson" <ian.wilson@THRWHITE.remove-dii-this> - 2011-04-27 15:31 +0000
        Re: JButton sizing ? "Tony B" <tony.b@THRWHITE.remove-dii-this> - 2011-04-27 15:31 +0000
  Re: JButton sizing ? "Karsten Lentzsch" <karsten.lentzsch@THRWHITE.remove-dii-this> - 2011-04-27 15:31 +0000

csiph-web