[Java] 자바 이클립스 설치
HelloWorld
public class HelloWorldApp {
public static void main(String[] args) {
System.out.println("Hello World!!");
}
}
HelloWorldApp은 HelloWorldApp.java 파일명과 동일
Java의 동작원리
Java Source code.java
↓ compile
Java Application.class
↓
Java Virtual Machine
↓
computer
Java로 데스크탑 앱 만들기
import javax.swing.*;
import java.awt.Dimension;
import java.awt.Toolkit;
public class HelloWorldGUIApp{
public static void main(String[] args){
javax.swing.SwingUtilities.invokeLater(new Runnable() {
public void run() {
JFrame frame = new JFrame("HelloWorld GUI");
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setPreferredSize(new Dimension(800, 300));
JLabel label = new JLabel("Hello World!!", SwingConstants.CENTER);
frame.getContentPane().add(label);
Dimension dim = Toolkit.getDefaultToolkit().getScreenSize();
frame.setLocation(dim.width/2-400/2, dim.height/2-300/2);
frame.pack();
frame.setVisible(true);
}
});
}
}
Leave a comment