Status Bar Demo : Status Bar « Swing Components « Java

Home
Java
1.2D Graphics GUI
2.3D
3.Advanced Graphics
4.Ant
5.Apache Common
6.Chart
7.Class
8.Collections Data Structure
9.Data Type
10.Database SQL JDBC
11.Design Pattern
12.Development Class
13.EJB3
14.Email
15.Event
16.File Input Output
17.Game
18.Generics
19.GWT
20.Hibernate
21.I18N
22.J2EE
23.J2ME
24.JavaFX
25.JDK 6
26.JDK 7
27.JNDI LDAP
28.JPA
29.JSP
30.JSTL
31.Language Basics
32.Network Protocol
33.PDF RTF
34.Reflection
35.Regular Expressions
36.Scripting
37.Security
38.Servlets
39.Spring
40.Swing Components
41.Swing JFC
42.SWT JFace Eclipse
43.Threads
44.Tiny Application
45.Velocity
46.Web Services SOA
47.XML
Java » Swing Components » Status Bar 




Status Bar Demo
    
       
/*
Swing Hacks Tips and Tools for Killer GUIs
By Joshua Marinacci, Chris Adamson
First Edition June 2005  
Series: Hacks
ISBN: 0-596-00907-0
Pages: 542
website: http://www.oreilly.com/catalog/swinghks/
*/
       
import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Component;
import java.awt.Container;
import java.awt.Dimension;
import java.awt.Graphics;
import java.awt.SystemColor;

import javax.swing.Icon;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.UIManager;

import com.sun.java.swing.plaf.windows.WindowsLookAndFeel;

public class StatusBarSimulator {

  public static void main(String[] args) {
    try {
      UIManager.setLookAndFeel(new WindowsLookAndFeel());
    catch (Exception e) {

    }

    JFrame frame = new JFrame();
    frame.setBounds(200200600200);
    frame.setTitle("Status bar simulator");

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

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

    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    frame.setVisible(true);
  }
}

class StatusBar extends JPanel {

  public StatusBar() {
    setLayout(new BorderLayout());
    setPreferredSize(new Dimension(1023));

    JPanel rightPanel = new JPanel(new BorderLayout());
    rightPanel.add(new JLabel(new AngledLinesWindowsCornerIcon()), BorderLayout.SOUTH);
    rightPanel.setOpaque(false);

    add(rightPanel, BorderLayout.EAST);
    setBackground(SystemColor.control);
  }

  protected void paintComponent(Graphics g) {
    super.paintComponent(g);

    int y = 0;
    g.setColor(new Color(156154140));
    g.drawLine(0, y, getWidth(), y);
    y++;
    g.setColor(new Color(196194183));
    g.drawLine(0, y, getWidth(), y);
    y++;
    g.setColor(new Color(218215201));
    g.drawLine(0, y, getWidth(), y);
    y++;
    g.setColor(new Color(233231217));
    g.drawLine(0, y, getWidth(), y);

    y = getHeight() 3;
    g.setColor(new Color(233232218));
    g.drawLine(0, y, getWidth(), y);
    y++;
    g.setColor(new Color(233231216));
    g.drawLine(0, y, getWidth(), y);
    y = getHeight() 1;
    g.setColor(new Color(221221220));
    g.drawLine(0, y, getWidth(), y);

  }

}

class AngledLinesWindowsCornerIcon implements Icon {
  private static final Color WHITE_LINE_COLOR = new Color(255255255);

  private static final Color GRAY_LINE_COLOR = new Color(172168153);
  private static final int WIDTH = 13;

  private static final int HEIGHT = 13;

  public int getIconHeight() {
    return WIDTH;
  }

  public int getIconWidth() {
    return HEIGHT;
  }

  public void paintIcon(Component c, Graphics g, int x, int y) {

    g.setColor(WHITE_LINE_COLOR);
    g.drawLine(012120);
    g.drawLine(512125);
    g.drawLine(10121210);

    g.setColor(GRAY_LINE_COLOR);
    g.drawLine(112121);
    g.drawLine(212122);
    g.drawLine(312123);

    g.drawLine(612126);
    g.drawLine(712127);
    g.drawLine(812128);

    g.drawLine(11121211);
    g.drawLine(12121212);

  }
}

           
         
    
    
    
  














Related examples in the same category
1.Paint your own status bar
2.Statusbar component
3.Single instance status bar
4.A status bar is made of multiple zones
java2s.com  | Contact Us | Privacy Policy
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.