JAVA JSwing Tutorials
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);
}
}
Java Swing Image Icon Settnig in JFrame Java code.
Image Icon Settnig in JFrame Java code.
package scm;
import javax.swing.ImageIcon;
import javax.swing.JFrame;
public class FrameDemo extends JFrame {
private ImageIcon icon;
FrameDemo(){
initComponents();
}
private void initComponents() {
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);
}
}
package scm;
import javax.swing.ImageIcon;
import javax.swing.JFrame;
public class FrameDemo extends JFrame {
private ImageIcon icon;
FrameDemo(){
initComponents();
}
private void initComponents() {
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);
}
}
Saturday, April 7, 2018
Creating and setting up JFrame
System 1:
package scm;
import javax.swing.JFrame;
public class FrameDemo extends JFrame {
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);
}
}
System 2:
package scm;
import javax.swing.JFrame;
public class FrameDemo extends JFrame {
FrameDemo(){
initComponents();
}
private void initComponents() {
}
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:
Posts (Atom)