PDA

View Full Version : Writing In Java



pcbrainbuster
02-25-2007, 02:52 PM
Hello all:),

I am a complete begginner to java and don't know the first thing about it ...
If I wanted to write Hello Juice Bomber in a java program how would i do it/what's the code???

Thanks:)

Twey
02-25-2007, 03:02 PM
What sort of a Java program?

To write it to the console,
class Hello {
public static void main(String[] argv) {
System.out.println("Hello Juice Bomber");
}
}Or with a Swing GUI:
import java.swing.JFrame;
import java.swing.JLabel;
import java.swing.JPanel;

class Hello extends JFrame {
public Hello() {
super("Hello");
setSize(150, 100);
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
((JPanel)getContentPane()).add(new JLabel("Hello Juice Bomber"));
setVisible(true);
}

public static void main(String[] argv) {
new Hello();
}
}Or as an applet:
import java.swing.JApplet;
import java.swing.JLabel;
import java.swing.JPanel;

class Hello extends JApplet {
public void start() {
((JPanel)getContentPane()).add(new JLabel("Hello Juice Bomber"));
}
}

nareshgovindaswamy
04-13-2007, 02:12 PM
class Simple
{
public static void method()
{
System.out.println("Hello Juice Bomber");
}
public static void main(String Str[])
{
Simple.method();
}
}

Twey
04-13-2007, 04:49 PM
Um... that's nice? :p