Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / GUI / January 2004

Tip: Looking for answers? Try searching our database.

Moving JButton

Thread view: 
W. - 19 Jan 2004 17:36 GMT
Why the Button's moving while editing text in a TextArea ?

public class Walker extends JApplet {
    public void init() {
        Container cp= getContentPane();
        cp.setLayout(new BoxLayout(cp, BoxLayout.PAGE_AXIS));
        cp.add(new JButton("Walker"));
        cp.add(new JTextArea(10,10));
    }
}

Signature

Best regards,
W.

Andrew Thompson - 19 Jan 2004 21:51 GMT
| Why the Button's moving while editing text in a TextArea ?
|
[quoted text clipped - 6 lines]
|      }
| }

I have not used BoxLayout before,
but I suspect it is because..
"Similarly, for a vertical layout, BoxLayout
attempts to make all components in the column
as wide as the widest component. If that fails,
it aligns them horizontally according to their X
alignments."

As the JTextArea grows, the layout grows
and the JButton remains centered within it..

Have you considered using other layouts?

--
Andrew Thompson
* http://www.PhySci.org/ PhySci software suite
* http://www.1point1C.org/ 1.1C - Superluminal!
* http://www.AThompson.info/andrew/ personal site
W. - 20 Jan 2004 09:30 GMT
> | Why the Button's moving while editing text in a TextArea ?
> |
[quoted text clipped - 6 lines]
> |      }
> | }

> As the JTextArea grows, the layout grows
> and the JButton remains centered within it..

But, typing text in JTextArea does't change
its size, X alignment, does it?

> Have you considered using other layouts?

I know I can stop it but was just testing the BoxLayout
and it came with something like that.

Signature

Regards,
W.

Gregory A. Swarthout - 19 Jan 2004 22:12 GMT
> Why the Button's moving while editing text in a TextArea ?
>
[quoted text clipped - 6 lines]
>      }
> }

Because its not in a JScrollPane.

cp.add(new JScrollPane(new JTextArea(10,10)));

Greg


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2009 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.