Tag Archive


3D 3dprinting android ant BigData bitcoin Browsers C/C++ cryptocurrency CSS dd ddrescue dogecoin DOS editors find Games Git hadoop html html5 Java Linux litecoin node perl Postgres Programming Python scripting Shell SQL Swing TOTK Utilities utilization vi Video Web Web Design Wifi Windows Wordpress XML Zelda

Java: Great link to Swing Examples

Starting on my road to creating a Java based GUI I stumbled upon the following link within the “Creating a GUI with JFC/Swing” Train in the Java Tutorials from Oracle.

Using Swing Components: Examples

It has code examples and can really get you started on the road to a Java GUI interface.

Java: Creating a Window

This is the First of some basic articles about creating a GUI in Java. The following code is the basis of the following series of articles. I am using the Java Swing window toolkit.

import java.awt.*;
import java.swing.*;

class FirstWindow 
{

  public static void main(String[] args)
  {
      //Create Window object and set title bar text
      JFrame frame = new frame("First Window");

      // Set the Default operation when you close the window
      // This exits the program on closing the window
      // The default behavior is to HIDE_ON_CLOSE
      frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

      // Now we need to Display the window
      // The null argument will place the element in the center of the screen.
      frame.setLocationRelativeTo(null);
      frame.pack();
      frame.setVisible(true);
   }
}

This is enough to display a simple window, but it will probably not have any useful size associated with it and it does not do anything.

The next step will be to add some useful widgets and eventually functionality to make the window useful.

Helpful info:
Java: Great link to Swing Examples