Answers for "java how to create a window"

10

java create window

//THIS IS A FIX OF THE ONE BY FRANCY FROG
//THEY FIXED THEIRS
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_CLOSE);
    frame.setTitle("Example Frame");
    frame.setVisible(true);
  }
}
Posted by: Guest on May-21-2020
0

java create window

public interface WindowConfigurer {
    void configure(JFrame window);
}

public class DefaultWindowConfigurer implements WindowConfigurer {

    private Font font = // Default font

    public void configure(JFrame window) {
        window.setFont(font);
    }

    public void setFont(Font font) {
        this.font = font;
    }
}

public class EntryPoint {
    public static void main(String[] args) {
        SwingUtilities.invokeLater(new Runnable() {
            public void run() {
                Something something = new Something();
                WindowConfigurer windowConfigurer = new DefaultWindowConfigurer();
                windowConfigurer.configure(something);
                something.setVisible(true);
            }
        });
    }
}

public class Something extends JFrame {
    public Something() {
        // .. add buttons, controls, etc.
    }
}
Posted by: Guest on February-21-2022
0

how to make window in java

//It is easy
//Don't forget to mention package or it will cause error
import javax.swing.*;

public class coder83 {
  public static void main(String[] args){
    JFrame firstFrame = new JFrame();
//x and y are your wish
    firstFrame.setsize(y,x);
    firstFrame.setTitle("Coder83");
//It is important or else your window won't clode
    firstFrame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
 
    firstFrame.setVisible(true);
  }}
Posted by: Guest on March-16-2022

Code answers related to "java how to create a window"

Code answers related to "Java"

Java Answers by Framework

Browse Popular Code Answers by Language