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 / General / October 2005

Tip: Looking for answers? Try searching our database.

Status Bar or any swing component

Thread view: 
ffellico@inwind.it - 29 Oct 2005 07:17 GMT
Hi.

How I can obtain that a Status bar wil be showed always on the bottom
of a frame,  also when someone resize at the run time that Frame?

Same time this is a common problem also for other visual component.

I think that the use of Layouts can do this for me, but I was unable to
realize it, so I think that a sample code referred to a Status bar can
help me in understanding the whole problem. Consider that normally I
use XYLayout for my frames and I need to keep only the StatusBar always
on the bottom.

Thank you. Franco.
zero - 29 Oct 2005 12:40 GMT
ffellico@inwind.it wrote in news:1130566646.950666.6360
@g47g2000cwa.googlegroups.com:

> Hi.
>
[quoted text clipped - 10 lines]
>
> Thank you. Franco.

use a BorderLayout.

class MyClass extends JFrame
{
  JLabel lblStatusBar = new JLabel();

  public MyClass()
  {
     setLayoutManager(new BorderLayout());
     add(lbsStatusBar, BorderLayout.SOUTH);
  }

  // ...
}

More info:

http://java.sun.com/docs/books/tutorial/uiswing/layout/border.html
http://java.sun.com/docs/books/tutorial/uiswing/layout/using.html
ffellico@inwind.it - 29 Oct 2005 19:16 GMT
Thank you. I solved my problem but it was necessary to change the two
statement you suggest in:

 getContentPane().setLayout(new BorderLayout());
 getContentPane().add(statusBar, BorderLayout.SOUTH);

In that way it worked but any other component disappears from the
frame, so I create a Panel (jPanel1) in the NORTH part of the frame,
and I put all  other components in this Panel; after II add this other
statement:

 getContentPane().add(jPanel1, BorderLayout.CENTER);

Now when at run time I resize the frame, the statusbar remain always at
the bottom of the frame, jPanel1 expand itself in all the rest of the
space of the frame and the other components ar alway visible in the
location where I have put them.

Please, can you confirm that this is the way to work with Layouts to
solve all this kind of problems?

I am a beginner in Java (I worked until now in Delphi) so I need to
understant this different architecture.

Tank you again. Franco.
zero - 29 Oct 2005 19:31 GMT
ffellico@inwind.it wrote in news:1130609809.723572.190310
@g43g2000cwa.googlegroups.com:

> Thank you. I solved my problem but it was necessary to change the two
> statement you suggest in:
[quoted text clipped - 21 lines]
>
> Tank you again. Franco.

Yep that's exactly how it's done.  The JPanel can itself have any layout
you want, creating increasingly complex GUIs.  Have a look at the other
layout managers, and pick whatever is best for each specific situation.

For a good introduction in Swing layout managers I suggest the excellent
java swing tutorial, see the links in my previous post.
Roedy Green - 31 Oct 2005 04:28 GMT
>I think that the use of Layouts can do this for me,

see http://mindprod.com/jgloss/layout.html
for a intro to the various layouts and when you would use them.
Signature

Canadian Mind Products, Roedy Green.
http://mindprod.com Java custom programming, consulting and coaching.



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.