Answers for "how to create a JFrame in java"

8

java create jframe

import javax.swing.JFrame;

public class example {
  public static void main(String[] args){
    JFrame frame = new JFrame();
    frame.setSize(100,100);
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOES);
    frame.setTitle("Example Frame");
    frame.setVisible(true);
  }
}
Posted by: Guest on April-17-2020
3

how to create a JFrame in java

import javax.swing.JFrame;
import java.awt.Rectangle;
import javax.swing.JComponent;
import java.awt.Graphics2D;
import java.awt.Graphics;
import java.awt.Color;

public class ChrismasTree {
    public static void main(String[] args) {
        JFrame window = new JFrame();
        window.setTitle("Christmas Tree");
        window.setSize(800, 1000);
        window.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        window.setVisible(true);
        DrawingComponent DC = new DrawingComponent();
        window.add(DC);
    }
}

class DrawingComponent extends JComponent{
    public void paint(Graphics graph0){
        Graphics2D graph = (Graphics2D) graph0;

        graph.setColor(Color.LIGHT_GRAY);
        graph.draw(new Rectangle(0, 710, 70, 60));

        graph.setColor(Color.BLUE);
        graph.draw(new Rectangle(70, 600, 50, 100));

        graph.setColor(Color.BLACK);
    }
}
Posted by: Guest on January-10-2020
1

create jframe java

public JFrame frame = new JFrame();//creating jframe

Class main(){
public static void main(String[] args){
  frame.setSize(200,200); //setting size
  frame.setVisable(true); //sets visability 
  frame.setDefaultCloseOperation.(JFrame.EXIT_ON_CLOSE); //allow jframe to close when clicked

}
  }
Posted by: Guest on October-01-2020
0

make a jframe

There is a typo CLOSE not CLOES :)
Posted by: Guest on January-02-2021

Code answers related to "Java"

Java Answers by Framework

Browse Popular Code Answers by Language