Meaningless Drivel is fun!
The moose likes Swing / AWT / SWT and the fly likes how to run sample swing program Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Java Interview Guide this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "how to run sample swing program" Watch "how to run sample swing program" New topic

how to run sample swing program

manju latha

Joined: Jul 04, 2002
Posts: 28
iam new to the swings.
can anybody tell how to start my swings
examples. For example to run this program below
what the directory like jdk(?) must i have to be.
and any classpath required to put for them.
also i request whats the procedure to run this program.
import java.awt.*;
import javax.swing.*;
public class JButtons extends JFrame {
public static void main(String[] args) {
new JButtons();
public JButtons() {
super("Using JButton");
addWindowListener(new ExitListener());
Container content = getContentPane();
content.setLayout(new FlowLayout());
JButton button1 = new JButton("Java");
ImageIcon cup = new ImageIcon("images/cup.gif");
JButton button2 = new JButton(cup);
JButton button3 = new JButton("Java", cup);
JButton button4 = new JButton("Java", cup);

Chantal Ackermann
Ranch Hand

Joined: Sep 28, 2000
Posts: 508
download the JDK Standard Edition Version 1.4 from follow the installation instructions.
(and the instructions on how to setup the classpath!)
go to the directory where you placed the sample file (on linux: console/xterm, on windows: dos/commandline)
$ javac
this will compile the file and create JButtons.class if successfull.
to run the example type:
$ java JButtons
remember to leave the class-ext off.
if you run into problems, post again.
Sayed Ibrahim Hashimi
Ranch Hand

Joined: May 17, 2001
Posts: 148
What Operating system are you using? And post any errors you are having.

SCJP 1.4<br /><a href="" target="_blank" rel="nofollow"></a>
I agree. Here's the link:
subject: how to run sample swing program
It's not a secret anymore!