Beispiel #1
0
 @Override
 public void removeNotify() {
   // This is a little kludgy.  Normally removeNotify would run on the
   // event thread, but in an applet context, when the applet
   // shuts down, removeNotify can run on some other thread. But
   // actually this stuff doesn't need to happen in the applet,
   // so we can just skip it in that context. - ST 10/12/03, 10/16/03
   if (java.awt.EventQueue.isDispatchThread()) {
     new org.nlogo.window.Events.RemoveJobEvent(this).raise(this);
   }
   super.removeNotify();
 }
 @Override
 public void paintComponent(java.awt.Graphics g) {
   super.paintComponent(g); // paint background
   java.awt.FontMetrics fm = g.getFontMetrics();
   int labelHeight = fm.getMaxDescent() + fm.getMaxAscent();
   java.awt.Dimension d = getSize();
   g.setColor(getForeground());
   String displayName = displayName();
   int boxHeight = (int) StrictMath.ceil(labelHeight * 1.4);
   g.drawString(
       displayName, LEFT_MARGIN, d.height - BOTTOM_MARGIN - boxHeight - fm.getMaxDescent() - 1);
   g.setColor(java.awt.Color.WHITE);
   g.fillRect(
       LEFT_MARGIN,
       d.height - BOTTOM_MARGIN - boxHeight,
       d.width - LEFT_MARGIN - RIGHT_MARGIN - 1,
       boxHeight);
   g.setColor(java.awt.Color.BLACK);
 }