天天看點

JFrame背景顔色的設定

在使用JFrame.setBackground(new Color);是發現這個方法調用後并沒有改變JFrame視窗的背景顔色,這展現了點JFrame和Frame的差別:

JFrame要用:

JFrame.getContentPane().setBackground(new Color);

來改變JFrame的背景顔色;

Frame中則可以直接使用:

Frame.setBackground(new Color);

JFrame透明度設定

  java.awt.EventQueue.invokeLater(new Runnable() {

   public void run() {

    AAA a = new AAA();

    a.setVisible(true);

//    com.sun.awt.AWTUtilities.setWindowShape(a, new Ellipse2D.Double(0, 0, a.getWidth(), a.getHeight()));

    com.sun.awt.AWTUtilities.setWindowOpacity(a, 0.80f);

   }

  });

a為JFrame 0.80F為透明度系數