Listing 1
JFrame menuFrame = new JFrame("MONITOR MENU");
NotifyMenu mainMenu = new NotifyMenu();
JPanel pPanel = new JPanel();
JLabel lLabel = new JLabel("MONITOR MENU");
Font lFont = new Font("Serif",Font.BOLD|Font.ITALIC,24);
lLabel.setFont(lFont);
lLabel.setForeground(Color.white);
pPanel.setBackground(Color.blue);
pPanel.add(lLabel);
menuFrame.setJMenuBar(mainMenu.getMenuBar());
menuFrame.getContentPane().add(pp);
menuFrame.pack();
menuFrame.show();
Listing 2
class ARenderer extends JLabel implements ListCellRenderer {
static Font f = new Font("Helvetica",Font.BOLD,10);
static SoftBevelBorder sbb = new SoftBevelBorder(Soft-
BevelBorder.RAISED);
static CompoundBorder cb = new CompoundBorder(new Matte-
Border(2,2,2,2,
Color.green),new SoftBevelBorder(SoftBevelBorder.RAISED));
public ARenderer() {
setOpaque(true);
setFont(f);
setForeground(Color.black);
}
public Component getListCellRendererComponent(JList l,
Object v, int i, boolean isSelected, boolean cellHasFocus) {
LocalEvent a = (LocalEvent)v;
setToolTipText(a.description);
setText(a.symbol);
if (a.severity == 0) {
setBackground(Color.gray);
} else if (a.severity == 1) {
setBackground(Color.cyan);
} else {
setBackground(Color.white);
}
}
// additional customization codeŠ
return this;
}
}
No comments:
Post a Comment