import javax.swing.JLabel;
import javax.swing.JProgressBar;
import org.jdesktop.swingx.JXStatusBar;
public class StatusBar extends JXStatusBar{
private static StatusBar INSTANCE = new StatusBar();
static final JLabel statusLabel = new JLabel("Listo");
static JProgressBar pbar = new JProgressBar();
static final JLabel hora = new JLabel();
private StatusBar() {
// Exists only to defeat instantiation.
}
public static StatusBar getInstance() {
INSTANCE.setSize(800,20);
JXStatusBar.Constraint c1 = new JXStatusBar.Constraint();
c1.setFixedWidth(200);
INSTANCE.add(statusLabel, c1); // Fixed width of 100 with no inserts
JXStatusBar.Constraint c2 = new JXStatusBar.Constraint(
JXStatusBar.Constraint.ResizeBehavior.FILL); // Fill with no inserts
INSTANCE.add(pbar, c2); // Fill with no inserts - will use remaining space
new Clock(hora);
hora.setSize(100,20);
JXStatusBar.Constraint c3 = new JXStatusBar.Constraint();
c3.setFixedWidth(90);
INSTANCE.add(hora,c3);
return INSTANCE;
}
public void setEstado(String estado){
statusLabel.setText(estado); // Fixed width of 100 with no inserts
INSTANCE.repaint();
}
}
miƩrcoles, 20 de diciembre de 2006
StatusBar
Un singleton con una JLabel que muestra el estado ("Listo" por defecto), una barra de progreso y un reloj a la derecha.
Suscribirse a:
Enviar comentarios (Atom)

1 comentario:
:) : ) :-)
Publicar un comentario