0% found this document useful (0 votes)
96 views6 pages

Modul 1:: Tujuan: Mengenal Java Net Beans Java 2 Di Bagi Atas Tiga Paket, Yaitu

The document introduces Java NetBeans and how to create a simple "Hello World" application using it. It discusses the three editions of Java 2, how to install NetBeans, how to create and save a project, and generate a GUI with labels and buttons. It then provides sample code for a Java application with a label and button that changes the label text when clicked. The code is compiled into an executable JAR file.

Uploaded by

Rizka Ardina
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
96 views6 pages

Modul 1:: Tujuan: Mengenal Java Net Beans Java 2 Di Bagi Atas Tiga Paket, Yaitu

The document introduces Java NetBeans and how to create a simple "Hello World" application using it. It discusses the three editions of Java 2, how to install NetBeans, how to create and save a project, and generate a GUI with labels and buttons. It then provides sample code for a Java application with a label and button that changes the label text when clicked. The code is compiled into an executable JAR file.

Uploaded by

Rizka Ardina
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd

Modul 1:

Tujuan : Mengenal Java Net Beans

Java 2 di bagi atas tiga paket, yaitu :


1.J2EE ( Java 2 Enterprise Edition ) : digunakan untuk aplikasi server atau aplikasi web server.
2.J2SE ( Java 2 Standard Edition ) : digunakan untuk aplikasi desktop.
3.J2ME ( Java 2 Micro Edition ) : digunakan untuk aplikasi wireless device atau mobile device.

Instalasi NetBeans:

Membuat dan Penyimpan Project:


[Link] Folder untuk Project dengan nama : java1
[Link] Project.

[Link] Java Application

[Link] Project : Modul 1 dan Folder : Java1

Write Once, Run Everywhere


Rahmadi, S.E, [Link]
Page |1
[Link] GUI ( AWT dan SWING ):

[Link] Desain Form Hello Word by Java:

[Link] Form Hello Word:


/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/

/*
* java_frame.java
*
* Created on Jun 15, 2009, [Link] PM
Write Once, Run Everywhere
Rahmadi, S.E, [Link]
Page |2
*/
//import komponen java awt untuk perataan form center
import [Link];
import [Link];
import [Link];
/**
*
* @author Acer
* */
public class java_frame extends [Link] {
/** Creates new form java_frame */
public java_frame() {
initComponents();
}
/** This method is called from within the constructor to
* initialize the form.
* WARNING: Do NOT modify this code. The content of this method is
* always regenerated by the Form Editor.
*/
@SuppressWarnings("unchecked")
// <editor-fold defaultstate="collapsed" desc="Generated Code">
private void initComponents() {
jDialog1 = new [Link]();
lbl_helloswing = new [Link]();
btn_helloswing = new [Link]();

[Link] jDialog1Layout = new


[Link]([Link]());
[Link]().setLayout(jDialog1Layout);
[Link](
[Link]([Link])
.addGap(0, 400, Short.MAX_VALUE)
);
[Link](
[Link]([Link])
.addGap(0, 300, Short.MAX_VALUE)
);

setDefaultCloseOperation([Link].EXIT_ON_CLOSE);
setTitle("Form Hello Word...!");
setAlwaysOnTop(true);
addWindowListener(new [Link]() {
public void windowActivated([Link] evt) {
formWindowActivated(evt);
}
});

Write Once, Run Everywhere


Rahmadi, S.E, [Link]
Page |3
lbl_helloswing.setBackground(new [Link](0, 255, 255));
lbl_helloswing.setFont(new [Link]("Arial Black", 3, 48)); // NOI18N
lbl_helloswing.setForeground(new [Link](0, 0, 255));
lbl_helloswing.setText("Klik Button di Bawah..!");

btn_helloswing.setFont(new [Link]("Algerian", 3, 24)); // NOI18N


btn_helloswing.setText("Hello Swing");
btn_helloswing.setToolTipText("Button Hello Swing");
btn_helloswing.addMouseListener(new [Link]() {
public void mouseClicked([Link] evt) {
btn_helloswingMouseClicked(evt);
}
public void mouseExited([Link] evt) {
btn_helloswingMouseExited(evt);
}
});

[Link] layout = new [Link](getContentPane());


getContentPane().setLayout(layout);
[Link](
[Link]([Link])
.addGroup([Link]()
.addContainerGap()
.addGroup([Link]([Link])
.addComponent(lbl_helloswing)
.addGroup([Link]()
.addGap(10, 10, 10)
.addComponent(btn_helloswing)))
.addContainerGap(83, Short.MAX_VALUE))
);
[Link](
[Link]([Link])
.addGroup([Link]()
.addContainerGap()
.addComponent(lbl_helloswing)
.addPreferredGap([Link])
.addComponent(btn_helloswing)
.addContainerGap(174, Short.MAX_VALUE))
);

pack();
}// </editor-fold>

private void btn_helloswingMouseClicked([Link] evt) {


// TODO add your handling code here:
lbl_helloswing.setText("Hello Swing");
}

Write Once, Run Everywhere


Rahmadi, S.E, [Link]
Page |4
private void formWindowActivated([Link] evt) {
// TODO add your handling code here:
lbl_helloswing.setText("Hello Word");
// Center in the screen
Dimension screenSize = [Link]().getScreenSize();
Dimension frameSize = getSize();
setLocation(new Point(([Link] - [Link]) / 2,
([Link] - [Link]) / 2));
}

private void btn_helloswingMouseExited([Link] evt) {


// TODO add your handling code here:
lbl_helloswing.setText("Hello Word");
}

/**
* @param args the command line arguments
*/
public static void main(String args[]) {
[Link](new Runnable() {
public void run() {
new java_frame().setVisible(true);
}
});
}

// Variables declaration - do not modify


private [Link] btn_helloswing;
private [Link] jDialog1;
private [Link] lbl_helloswing;
// End of variables declaration

[Link] berupa file Execuble Jar File:

Write Once, Run Everywhere


Rahmadi, S.E, [Link]
Page |5
[Link]:

Write Once, Run Everywhere


Rahmadi, S.E, [Link]
Page |6

You might also like