Java help. How to set background color in JFrame? - swing a frame blue prints
This is what we have:
import javax.swing.JFrame;
import java.awt.Color;
public class Picture Viewer
(
public static void main (String [] args)
(
JFrame frame = new JFrame ();
frame.setSize (800800);
frame.setBackground (Color.blue);
frame.setTitle ( "Drawing");
(frame.setDefaultCloseOperation JFrame.EX ...
Component component = new Component ();
frame.add (component);
setVisible (true);
)
)
Here is the code for the component:
import java.net .*;
import java.util .*;
Component public class JComponent
(
public void paint (Graphics g)
(
Graphics2D g2 = (Graphics2D) g;
Rectangle r = new Rectangle (0,0, this.getWidth () this.getHeight ());
g2.setColor (Color.blue);
g2.fill (R);
Drawings.drawDrawings (G2);
)
)
I know I amto doing something wrong. What is
2 comments:
Import declaration to use to:
import java.util .*;
this corrects the problem.
Hello,
Normally, the color of the contentPane set () as follows:
() GetContentPane. setBackground (
Color.Blue);
Regards,
TgTips
Post a Comment