🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: borland.public.jbuilder.java.swing
Article #1390

Re: JButton auto resize??

#1390
From: Rudy
Date: Thu, 18 Dec 2003 22:10
44 lines
2562 bytes
I have fixed it, i used the xyLayout with x,y,-1-1 so the width and height
are resized....thatnks for the help
Rudy
"Rudy" <rhentzen@hotmail.com> wrote in message
news:3fca70a4$1@newsgroups.borland.com...
> I have the following code:
>
> public void add(final JButton component) {
>     component.addMouseListener(new MouseAdapter() {
>       public void mousePressed(MouseEvent e) {
>         mComponent = component;
>         //mComponent.setBackground(Color.BLUE);
>       }
>     });
>     mComponent = component;
>     mComponent.setSize(w, h);
>     mComponent.setLocation(x, y);
>     mComponent.setMinimumSize(new Dimension(120, 120));
>     mComponent.setMaximumSize(new Dimension(150, 150));
>     mComponent.setPreferredSize(new Dimension(130, 130));
>     mComponent.setFont(new Font("Dialog", 0, 9));
>     mComponent.setBorder(BorderFactory.createEmptyBorder());
>     mComponent.setBackground(Color.WHITE);
>     mComponent.setMargin(new Insets(1, 1, 1, 1));
>     mComponent.setText(text);
>     mComponent.setVerticalAlignment(SwingConstants.TOP);
>     mComponent.setHorizontalAlignment(SwingConstants.CENTER);
>     mComponent.setIcon(logo2);
>     super.add(mComponent);
>     repaint();
>   }
>
> the problem i am having is that i would like the button to resize
depending
> on what text is entered in the setText() method.  I find that the button
> uses the setSize method and always stays at this size but does not use the
> set...Size methods. However if i remove the setSize method then the button
> is not displayed.  How can i ensure the button is size around the text
> properly.
>
> Thanks
> Rudy
>
>
Technical Details
Message-ID: <3fe225f1$1@newsgroups.borland.com>
Path: arc1-ca.pugleaf.net!archiver1.google.com!news2.google.com!fu-berlin.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail
References: <3fca70a4$1@newsgroups.borland.com>

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: 111d45,d747d5f574c277f5
X-Google-Attributes: gid111d45,public
X-Google-ArrivalTime: 2003-12-18 14:40:19 PST
Reply-To: "Rudy" <rhentzen@hotmail.com>
From: "Rudy" <rhentzen@hotmail.com>
Newsgroups: borland.public.jbuilder.java.swing
References: <3fca70a4$1@newsgroups.borland.com>
Subject: Re: JButton auto resize??
Date: Thu, 18 Dec 2003 22:10:59 -0000
Lines: 46
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 6.00.2800.1158
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1165
NNTP-Posting-Host: 81.86.182.21
Message-ID: <3fe225f1$1@newsgroups.borland.com>
X-Trace: newsgroups.borland.com 1071785457 81.86.182.21 (18 Dec 2003 14:10:57 -0700)
Path: arc1-ca.pugleaf.net!archiver1.google.com!news2.google.com!fu-berlin.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail