This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes Swing / AWT / SWT and the fly likes How to add a Status Bar in a frame(at the Bottom ofcourse) Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "How to add a Status Bar in a frame(at the Bottom ofcourse)" Watch "How to add a Status Bar in a frame(at the Bottom ofcourse)" New topic

How to add a Status Bar in a frame(at the Bottom ofcourse)

Murali Obla
Ranch Hand

Joined: Nov 18, 2001
Posts: 40
Hello Folks,
How would I add a Status Bar at the Bottom of the frame in Swings.Is there any component.
Thanks in Advance,

"Excellence is never an accident; it is always the result of high intention, sincere effort, intelligent direction, skillful execution, and the vision to see obstacles as opportunities"
Peter Phung
Ranch Hand

Joined: Dec 06, 2001
Posts: 138
Use JProgressBar. Check API for details

Pete<br />"Reality is an illusion <br />brought on by a lack of <br />drink, drugs and smut"
Rajendar Goud
Ranch Hand

Joined: Mar 06, 2002
Posts: 220
Hi murali,
here is an example on the statusBar.
import javax.swing.event.*;
import java.awt.event.*;
import javax.swing.*;
import java.awt.*;
public class Main extends JFrame
public Main()
getContentPane().setLayout(new BorderLayout());
JMenuBar menuBar = new JMenuBar();
JMenu menu = new JMenu("Sex");
JMenuItem menuItem1 = new JMenuItem("male");
JMenuItem menuItem2 = new JMenuItem("female");
JMenuItem menuItem3 = new JMenuItem("androgyne");
// add the MenuItems to the Menu
StatusBar statusBar = new StatusBar();
new JMenuItemHelpText(menuItem1, "The weak sex", statusBar);
new JMenuItemHelpText(menuItem2, "The strong sex", statusBar);
new JMenuItemHelpText(menuItem3, "The average sex, I guess", statusBar);
getContentPane().add(BorderLayout.SOUTH, statusBar);
addWindowListener(new WindowAdapter() {
public void windowClosing(WindowEvent event)
setSize(400, 400);
public static void main(String[] args)
(new Main()).show();
class JMenuItemHelpText implements ChangeListener
JMenuItem menuItem;
String helpText;
StatusBar statusBar;
JMenuItemHelpText(JMenuItem menuItem, String helpText, StatusBar statusBar)
this.menuItem = menuItem;
this.helpText = helpText;
this.statusBar = statusBar;
public void stateChanged(ChangeEvent evt)
if (menuItem.isArmed())

class StatusBar extends JPanel
private JLabel statusLabel;
public StatusBar()
setLayout(new BorderLayout(2, 2));
statusLabel = new JLabel("Ready");
add(BorderLayout.CENTER, statusLabel);
JLabel dummyLabel = new JLabel(" ");
add(BorderLayout.EAST, dummyLabel);
public void setStatus(String status)
if (status.equals(""))
public String getStatus()
return statusLabel.getText();
Murali Obla
Ranch Hand

Joined: Nov 18, 2001
Posts: 40
Thanks Pete
Thanks for ur code Rajendar,
Cool it is working,
I am really gainin' some Swings knowledge ,
I agree. Here's the link:
subject: How to add a Status Bar in a frame(at the Bottom ofcourse)
Similar Threads
frame decoration problem
How many chars in statusbar?
how to set statues of Dialog?
JFrame in applet
Status display