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 / November 2007

Tip: Looking for answers? Try searching our database.

JButton is incomplete

Thread view: 
felix - 26 Nov 2007 13:21 GMT
Hi All,

  I am new to java. Though I have written codes in C, Java is still
difficult to understand. Please help me ...

  I have placed a button in a gridBagLayout(1, 3). When I reduce the
size of the screen, the button is split. I do not want it to happen
this way.

  I have placed the code snippet below

/* Code starts here */
JPanel     p = new JPanel();
p.setLayout(new GridLayout(1,3));

p.add(new JLabel(""));
p.add(m_titleLabel);
p.add(m_refreshPan);

m_refreshPan.setLayout(new FlowLayout(FlowLayout.LEFT));
m_refreshPan.add(m_label);
m_refreshPan.add(m_button);
/*  Code ends here  */

--
Felix
hiwa - 28 Nov 2007 09:19 GMT
> Hi All,
>
[quoted text clipped - 22 lines]
> --
> Felix

Post a small demo code that is generally compilable, runnable and
could reproduce your problem. See: http://homepage1.nifty.com/algafield/sscce.html
and http://www.yoda.arachsys.com/java/newsgroups.html
Ian Shef - 28 Nov 2007 19:27 GMT
felix <ckpradip@gmail.com> wrote in news:2ab5cebf-5e80-476c-80f5-
4e74b9a54764@s36g2000prg.googlegroups.com:

<snip>
>    I have placed a button in a gridBagLayout(1, 3).
No.  You placed a button into something (perhaps a JPanel?) with a
FlowLayout.
The something was placed into a JPanel with a GridLayout (not
gridBagLayout, not even GridBagLayout).
Presumably, this JPanel was placed into something else unknown with an
unknown LayoutManager.

Words can be misleading.  Code can be misleading, but usually less so.  A
good example of why an SSCCE is important.

> When I reduce the
> size of the screen, the button is split. I do not want it to happen
[quoted text clipped - 5 lines]
> JPanel     p = new JPanel();
> p.setLayout(new GridLayout(1,3));
The JPanel has a GridLayout

> p.add(new JLabel(""));
> p.add(m_titleLabel);
> p.add(m_refreshPan);
Whatever m_refreshPan is, it has been added to the JPanel.

> m_refreshPan.setLayout(new FlowLayout(FlowLayout.LEFT));
m_refreshPan has a FlowLayout
> m_refreshPan.add(m_label);
> m_refreshPan.add(m_button);
Assuming that m_button is the button (Button?  JButton?) of interest, it is
in m_refreshPan which has a FlowLayout.
> /*  Code ends here  */
>
> --
> Felix

An SSCCE would really help.  So would a screen shot or other description of
the meaning of "the button is split."

I want to help, but need better to go on.

Signature

Ian Shef     805/F6      *    These are my personal opinions    
Raytheon Company         *    and not those of my employer.
PO Box 11337             *
Tucson, AZ 85734-1337    *



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



©2008 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.