Skip to content

Instantly share code, notes, and snippets.

@saltlakeryan
Created March 20, 2014 18:26
Show Gist options
  • Save saltlakeryan/9670545 to your computer and use it in GitHub Desktop.
Save saltlakeryan/9670545 to your computer and use it in GitHub Desktop.
Hello World for Swing
import java.awt.*;
import javax.swing.*;
import java.net.*;
import javax.jnlp.*;
import java.awt.event.ActionListener;
import java.awt.event.ActionEvent;
public class Hello {
static BasicService basicService = null;
public static void main(String args[]) {
JFrame frame = new JFrame("Hello World");
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
JLabel label = new JLabel();
Container content = frame.getContentPane();
content.add(label, BorderLayout.CENTER);
String message = "Hello World";
label.setText(message);
try {
basicService = (BasicService)
ServiceManager.lookup("javax.jnlp.BasicService");
} catch (UnavailableServiceException e) {
System.err.println("Lookup failed: " + e);
}
frame.pack();
frame.show();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment