Paint your own status bar : Status Bar « Swing Components « Java

Paint your own status bar


import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Container;
import java.awt.Dimension;
import java.awt.Graphics;

import javax.swing.JFrame;
import javax.swing.JPanel;

class JStatusBar extends JPanel {

  public JStatusBar() {
    setLayout(new BorderLayout());
    setPreferredSize(new Dimension(10, 23));

    JPanel rightPanel = new JPanel(new BorderLayout());

    add(rightPanel, BorderLayout.EAST);

  protected void paintComponent(Graphics g) {

    int y = 0;
    g.setColor(new Color(156, 154, 140));
    g.drawLine(0, y, getWidth(), y);
    g.setColor(new Color(196, 194, 183));
    g.drawLine(0, y, getWidth(), y);

public class Main {
  public static void main(String[] args) {
    JFrame frame = new JFrame();
    frame.setSize(600, 200);

    Container contentPane = frame.getContentPane();
    contentPane.setLayout(new BorderLayout());

    JStatusBar statusBar = new JStatusBar();
    contentPane.add(statusBar, BorderLayout.SOUTH);





Related examples in the same category

1.Status Bar Demo
2.Statusbar component
3.Single instance status bar
4.A status bar is made of multiple zones