forked from patniemeyer/learningjava
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathHelloJava.java
More file actions
48 lines (42 loc) · 1.01 KB
/
Copy pathHelloJava.java
File metadata and controls
48 lines (42 loc) · 1.01 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
/*
public class HelloJava
{
public static void main( String[] args ) {
System.out.println("Hello, Java!");
}
}
public class HelloJava
{
public static void main( String[] args ) {
javax.swing.JFrame frame = new javax.swing.JFrame( "Hello, Java!" );
frame.setSize( 300, 300 );
frame.setVisible( true );
}
}
import javax.swing.*;
public class HelloJava
{
public static void main( String[] args ) {
JFrame frame = new JFrame( "HelloJava" );
JLabel label = new JLabel("Hello, Java!", JLabel.CENTER );
frame.getContentPane().add( label );
frame.setSize( 300, 300 );
frame.setVisible( true );
}
}
*/
import javax.swing.*;
public class HelloJava
{
public static void main( String[] args ) {
JFrame frame = new JFrame( "HelloJava" );
frame.add( new HelloComponent() );
frame.setSize( 300, 300 );
frame.setVisible( true );
}
}
class HelloComponent extends JComponent {
public void paintComponent( java.awt.Graphics g ) {
g.drawString( "Hello, Java!", 125, 95 );
}
}