Can't change the colors in my Frame
From: JS (dsa._at_asdf.com)
Date: 11/27/04
- Next message: Brett Foster: "Re: Can't change the colors in my Frame"
- Previous message: da Vinci: "Re: List ADT Question: Code Included"
- Next in thread: Brett Foster: "Re: Can't change the colors in my Frame"
- Reply: Brett Foster: "Re: Can't change the colors in my Frame"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Sat, 27 Nov 2004 21:24:18 +0100
I would like to get a blue background color in my frame. But I can only get
white.
import javax.swing.*;
import java.awt.*;
class Frame
{
public static void main(String[] args)
{
JFrame frame = new JFrame();
frame.getContentPane().add(new Panel());
frame.setTitle("Tegninger");
frame.setBackground(Color.blue);
frame.setSize(800, 600);
frame.setVisible(true);
}
}
class Panel extends JPanel
{
public void paintComponent(Graphics g)
{
//a) 4 concentric circles
g.drawOval(380,280,40,40);
g.drawOval(370,270,60,60);
g.drawOval(360,260,80,80);
g.drawOval(350,250,100,100);
//b) Transperant, 3-dimensional cube
g.drawRect(150,300,100,100);
g.drawRect(200,350,100,100);
g.drawLine(150,300,200,350);
g.drawLine(150,400,200,450);
g.drawLine(250,300,300,350);
g.drawLine(250,400,300,450);
//c) Three eggs, stacked on top of one another
g.drawOval(500,400,40,60);
g.drawOval(500,340,40,60);
g.drawOval(500,280,40,60);
//d) Snowman
g.drawOval(600,400,100,80);
g.drawOval(608,331,80,70);
g.drawOval(613,272,65,60);
g.drawRect(620,221,50,50);
g.drawLine(590,272,700,272);
}
}
JS
- Next message: Brett Foster: "Re: Can't change the colors in my Frame"
- Previous message: da Vinci: "Re: List ADT Question: Code Included"
- Next in thread: Brett Foster: "Re: Can't change the colors in my Frame"
- Reply: Brett Foster: "Re: Can't change the colors in my Frame"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]