示例#1
0
  public void addClient() {
    client =
        new Canvas() {
          public void paint(Graphics g) {
            super.paint(g);
          }
        };
    client.setBackground(new Color(30, 220, 40));
    clientCont.add(client);
    clientCont.validate();
    final ComponentAccessor acc = AWTAccessor.getComponentAccessor();
    WindowIDProvider pid = (WindowIDProvider) acc.getPeer(client);
    log.fine("Added XEmbed server(Canvas) with X window ID " + pid.getWindow());
    Rectangle toFocusBounds = toFocus.getBounds();
    toFocusBounds.setLocation(toFocus.getLocationOnScreen());
    f.validate();

    // KDE doesn't accept clicks on title as activation - click below title
    Rectangle fbounds = f.getBounds();
    fbounds.y += f.getInsets().top;
    fbounds.height -= f.getInsets().top;

    Process proc =
        startClient(
            new Rectangle[] {
              fbounds,
              dummy.getBounds(),
              toFocusBounds,
              new Rectangle(b_modal.getLocationOnScreen(), b_modal.getSize()),
              new Rectangle(10, 130, 20, 20)
            },
            pid.getWindow());
    new ClientWatcher(client, proc, clientCont).start();
  }
 // Konstruktordefinition
 public InnereKlassemitmainMethode() {
   super("Programmaufruf über eine innere Klasse");
   setBounds(10, 10, 250, 150);
   getContentPane().setLayout(new BorderLayout());
   malflaeche = new Canvas();
   malflaeche.setBackground(Color.pink);
   malflaeche.setSize(100, 100);
   setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
   malflaeche.addMouseMotionListener(this);
   status = new JLabel(" ");
   getContentPane().add(status, BorderLayout.SOUTH);
   // Eine lokale Referenz vom Typ des Interface Action zeigt auf
   // ein Objekt vom Typ der inneren Klasse SelectColorAction
   Action select = new SelectColorAction();
   // Zu einer JToolBar-Komponente wird eine JButton-Komponente,
   // welche die vorher definierte Aktion ausführt, hinzugefügt
   JToolBar toolbar = new JToolBar("Farbe wählen");
   JButton b = toolbar.add(select);
   getContentPane().add(toolbar, BorderLayout.WEST);
   getContentPane().add(malflaeche, BorderLayout.EAST);
   setVisible(true);
   // Den Graphikkontext des Canvas ermitteln
   g = malflaeche.getGraphics();
 }
示例#3
0
 /**
  * Sets the background color.
  *
  * @param backgroundColor the new background color.
  * @see #getBackgroundColor
  */
 public static void setBackgroundColor(Color backgroundColor) {
   if (backgroundColor == null) {
     throw new IllegalArgumentException("backgroundColor must not be null.");
   }
   canvas.setBackground(backgroundColor);
 }