how to set a background color for the jframe ???
+2
A:
Retrieve the content pane for the frame and use the setBackground() method inherited from Component to change the color.
Example:
myJFrame.getContentPane().setBackground( desiredColor );
Brandon E Taylor
2009-07-04 04:30:18
A:
You can use a container like so:
Container c = JFrame.getContentPane();
c.setBackground(Color.red);
You must of course import java.awt.Color for the red color constant.
John T
2009-07-04 04:32:33
A:
To set the background color for JFrame:
getContentPane().setBackground(Color.YELLOW); //Whatever color
iwanttoprogram
2009-07-04 04:33:49
A:
That's another method:
private void RenkMouseClicked(java.awt.event.MouseEvent evt) {
renk=JColorChooser.showDialog(null,"Arka plan rengini buradan seçiniz",renk);
Container a=this.getContentPane();
a.setBackground(renk);
}
I'm using netbeans ide. So JFrame.getContentPane()
didn't run. I used JFrame.getContentPane()
's class equivalent this.getContentPane
method.
Abdullah
2009-11-25 02:11:09