Created
March 20, 2014 18:26
-
-
Save saltlakeryan/9670545 to your computer and use it in GitHub Desktop.
Hello World for Swing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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