Sunday, April 8, 2018
Background color of JFrame Java Swing.
package scm;
import java.awt.Color;
import javax.swing.ImageIcon;
import javax.swing.JFrame;
import java.awt.Container;
public class FrameDemo extends JFrame {
private ImageIcon icon;
private Container c;
FrameDemo(){
initComponents();
}
private void initComponents() {
c = this.getContentPane();
c.setBackground(Color.BLUE);
icon = new ImageIcon(getClass().getResource("anowar.png"));
this.setIconImage(icon.getImage());
}
public static void main (String[]args) {
FrameDemo frame =new FrameDemo () ;
frame.setVisible(true);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE );
frame.setBounds(100, 50, 400, 300);
frame.setTitle("Frame Demo");
frame.setResizable(false);
}
}
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment