Skip to content

Instantly share code, notes, and snippets.

@luchtech
Created August 21, 2018 06:17
Show Gist options
  • Save luchtech/88779c69af5dffea4aedca0b99e8a8a1 to your computer and use it in GitHub Desktop.
Save luchtech/88779c69af5dffea4aedca0b99e8a8a1 to your computer and use it in GitHub Desktop.
Simple JFrame Demo
import javax.swing.JFrame;
public class MyFirstJFrame extends JFrame {
public MyFirstJFrame() {
/*
* There are two ways to set the Windows title of the JFrame
* One is by passing a string to the "super constructor".
* The other one is using the "setTitle" method.
*/
super("Insert Title Here"); // --> JFrame Constructor
setTitle("Insert Title Here"); // --> Method from JFrame
setVisible(true); // --> Method from JFrame
setSize(500, 300); // --> Method from JFrame
setDefaultCloseOperation(EXIT_ON_CLOSE); // --> Method from JFrame
}
public static void main(String[] args) {
new MyFirstJFrame(); // --> instantiate Constructor from this class to run JFrame
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment