Belajar Swing (java)

Buad yang malez ngetik.
Buad yang pura2 sibuk sampe2 gak sempet untuk ngetik.
Buad yang hobby-nya copy-paste.
Buad yang lebih mentingin hasil daripada proses.
Buad yang gak mau tau apa yang lagi dipelajari.
check this page…!!!


Just Kidding Maz Brooo.
Silahkan Copy-Paste ajah.
Disini gak ada yang namanya etika copy-paste.



import javax.swing.*;
import java.awt.*;
public class BelajarSwing extends javax.swing.JFrame{
public BelajarSwing() {
initComponents();
setLocation(400,100);
}
private void initComponents(){

jFrame1= new javax.swing.JFrame();
lbl1=new javax.swing.JLabel();
lbl2=new javax.swing.JLabel();
lbl3=new javax.swing.JLabel();
lbl4=new javax.swing.JLabel();
lbl5=new javax.swing.JLabel();
lbl6=new javax.swing.JLabel();
lbl7=new javax.swing.JLabel();
txtNIM=new javax.swing.JTextField();
txtNama=new javax.swing.JTextField();
jScrollPanel=new javax.swing.JScrollPane();
jTextArea1=new javax.swing.JTextArea();
rbt1=new javax.swing.JRadioButton();
rbt2=new javax.swing.JRadioButton();
cboProdi=new javax.swing.JComboBox();
cboProdi1=new javax.swing.JComboBox();
cmdSave=new javax.swing.JButton();
cmdRead=new javax.swing.JButton();
cmdExit=new javax.swing.JButton();

javax.swing.GroupLayout jFrame1Layout=new
javax.swing.GroupLayout(jFrame1.getContentPane());
jFrame1.getContentPane().setLayout(jFrame1Layout);
jFrame1Layout.setHorizontalGroup(

jFrame1Layout.createParallelGroup(
javax.swing.GroupLayout.Alignment.LEADING)
.addGap(0,400,Short.MAX_VALUE));

jFrame1Layout.setVerticalGroup(
jFrame1Layout.createParallelGroup(
javax.swing.GroupLayout.Alignment.LEADING)
.addGap(0,300,Short.MAX_VALUE));

setDefaultCloseOperation(
javax.swing.WindowConstants.EXIT_ON_CLOSE);
setTitle(“FORM BIODATA MAHASISWA by maz ipan“);
setName(“frm1”);
lbl1.setFont(new java.awt.Font(“Andale Mono”,1,24));
lbl1.setText(“BIODATA MAHASISWA”);
lbl1.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);

lbl2.setFont(new java.awt.Font(“Andale Mono”,0,18));
lbl2.setText(“NIM:”);

lbl3.setFont(new java.awt.Font(“Andale Mono”,0,18));
lbl3.setText(“Nama:”);

lbl4.setFont(new java.awt.Font(“Andale Mono”,0,18));
lbl4.setText(“Alamat:”);

lbl5.setFont(new java.awt.Font(“Andale Mono”,0,18));
lbl5.setText(“JenisKelamin:”);

lbl6.setFont(new java.awt.Font(“Andale Mono”,0,18));
lbl6.setText(“Program Studi:”);

lbl7.setFont(new java.awt.Font(“Andale Mono”,0,18));
lbl7.setText(“Jurusan:”);

txtNIM.setBackground(java.awt.Color.white);
txtNIM.setFont(new java.awt.Font(“Andale Mono”,0,18));

txtNama.setBackground(java.awt.Color.white);
txtNama.setFont(new java.awt.Font(“Andale Mono”,0,18));

jTextArea1.setColumns(20);
jTextArea1.setFont(new java.awt.Font(“Andale Mono”,0,18));
jTextArea1.setRows(5);
jScrollPanel.setViewportView(jTextArea1);

rbt1.setFont(new java.awt.Font(“Andale Mono”,0,18));
rbt1.setText(“Wanita”);

rbt2.setFont(new java.awt.Font(“Andale Mono”,0,18));
rbt2.setText(“Pria”);

cboProdi.setFont(new java.awt.Font(“Andale Mono”,0,18));
cboProdi.setModel(new javax.swing.DefaultComboBoxModel(
new String[]{“Diploma(D3)”,”Sarjana(S1)”}));

cboProdi1.setFont(new java.awt.Font(“Andale Mono”,0,18));
cboProdi1.setModel(new javax.swing.DefaultComboBoxModel(
new String[]{“Teknik Arsitektur”,”Teknik Elektro”,
“Teknik Informatika”,”Teknik Industri”,”Teknik Mesin”}));

cmdSave.setFont(new java.awt.Font(“Andale Mono”,0,18));
cmdSave.setText(“Simpan Data”);
cmdRead.setFont(new java.awt.Font(“Andale Mono”,0,18));
cmdRead.setText(“Lihat Data”);
cmdExit.setFont(new java.awt.Font(“Andale Mono”,0,18));
cmdExit.setText(“Keluar”);

javax.swing.GroupLayout layout=new
javax.swing.GroupLayout(getContentPane());
getContentPane().setLayout(layout);
layout.setHorizontalGroup(

layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addContainerGap()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)

.addComponent(cmdSave,javax.swing.GroupLayout.Alignment.LEADING,
javax.swing.GroupLayout.DEFAULT_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)

.addComponent(lbl2,javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(lbl3,javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(lbl4,javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(lbl5,javax.swing.GroupLayout.Alignment.LEADING,
javax.swing.GroupLayout.DEFAULT_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)

.addComponent(lbl6,javax.swing.GroupLayout.Alignment.LEADING,
javax.swing.GroupLayout.DEFAULT_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)

.addComponent(lbl7,javax.swing.GroupLayout.Alignment.LEADING))
.addGap(28,28,28)

.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)

.addGroup(javax.swing.GroupLayout.Alignment.TRAILING,
layout.createSequentialGroup()

.addGap(10,10,10)
.addComponent(cmdRead,javax.swing.GroupLayout.PREFERRED_SIZE,163,
javax.swing.GroupLayout.PREFERRED_SIZE)

.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED,
37,Short.MAX_VALUE)

.addComponent(cmdExit,javax.swing.GroupLayout.PREFERRED_SIZE,163,
javax.swing.GroupLayout.PREFERRED_SIZE))
.addComponent(jScrollPanel,javax.swing.GroupLayout.DEFAULT_SIZE,373,Short.MAX_VALUE)
.addComponent(txtNama,javax.swing.GroupLayout.DEFAULT_SIZE,373,Short.MAX_VALUE)
.addComponent(txtNIM,javax.swing.GroupLayout.PREFERRED_SIZE,167,
javax.swing.GroupLayout.PREFERRED_SIZE)

.addComponent(cboProdi,0,373,Short.MAX_VALUE)

.addGroup(layout.createSequentialGroup()
.addComponent(rbt2)
.addGap(27,27,27)
.addComponent(rbt1))

.addComponent(cboProdi1,0,373,Short.MAX_VALUE))
.addContainerGap())
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING,layout.createSequentialGroup()
.addGap(165,165,165)
.addComponent(lbl1,javax.swing.GroupLayout.DEFAULT_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE,Short.MAX_VALUE)
.addGap(159,159,159)));

layout.setVerticalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING,
layout.createSequentialGroup()
.addContainerGap()
.addComponent(lbl1,javax.swing.GroupLayout.DEFAULT_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE,Short.MAX_VALUE)
.addGap(29,29,29)

.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(lbl2)
.addComponent(txtNIM,javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE,
javax.swing.GroupLayout.PREFERRED_SIZE))
.addGap(18,18,18)

.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(lbl3)
.addComponent(txtNama,javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE,
javax.swing.GroupLayout.PREFERRED_SIZE))
.addGap(18,18,18)

.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(lbl4)
.addComponent(jScrollPanel,javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE,
javax.swing.GroupLayout.PREFERRED_SIZE))
.addGap(21,21,21)

.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(lbl5)
.addComponent(rbt1)
.addComponent(rbt2))
.addGap(18,18,18)

.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(lbl6)
.addComponent(cboProdi,javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE,
javax.swing.GroupLayout.PREFERRED_SIZE))
.addGap(18,18,18)

.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(lbl7)
.addComponent(cboProdi1,javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE,
javax.swing.GroupLayout.PREFERRED_SIZE))
.addGap(30,30,30)

.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)

.addComponent(cmdSave,javax.swing.GroupLayout.PREFERRED_SIZE,44,
javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(cmdExit,javax.swing.GroupLayout.PREFERRED_SIZE,44,
javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(cmdRead,javax.swing.GroupLayout.PREFERRED_SIZE,44,
javax.swing.GroupLayout.PREFERRED_SIZE))
.addContainerGap())
);
pack();
}
public static void main(String args[]){
java.awt.EventQueue.invokeLater(new Runnable(){
public void run(){
new BelajarSwing().setVisible(true);
}
});
}

private javax.swing.JComboBox cboProdi;
private javax.swing.JComboBox cboProdi1;
private javax.swing.JButton cmdExit;
private javax.swing.JButton cmdRead;
private javax.swing.JButton cmdSave;
private javax.swing.JFrame jFrame1;
private javax.swing.JScrollPane jScrollPanel;
private javax.swing.JTextArea jTextArea1;
private javax.swing.JLabel lbl1;
private javax.swing.JLabel lbl2;
private javax.swing.JLabel lbl3;
private javax.swing.JLabel lbl4;
private javax.swing.JLabel lbl5;
private javax.swing.JLabel lbl6;
private javax.swing.JLabel lbl7;
private javax.swing.JRadioButton rbt1;
private javax.swing.JRadioButton rbt2;
private javax.swing.JTextField txtNIM;
private javax.swing.JTextField txtNama;}

*Nb :
1. Syntax bisa diketik di notepad,notepad++,tau bisa juga pake aplikasi IDE-nya java kaya eclipse,JCreator,Netbeans,dll.
2. Disimpan dengan nama BelajarSwing.java
3. Buad yang pake notepad atau notepad++,
berikut cara compile :
javac BelajarSwing.java

berikut cara Run :
java BelajarSwing


5 thoughts on “Belajar Swing (java)

  1. I think it is a very valid point about the comments with a valid point to make. If all you are trying to do is build a truck full of backlinks with nothing to offer, what will make the reader come to your site whether no1 comment or no102. The idea of commenting has become a single battlefield for pro marketers to build their backlinks without using any brain power against people who are genuinely interested in getting their point across in a constructive way so the reader wants to visit their site to see what makes them tick.I have only been involved in the blogging sphere for a very short time, and I must say, I find the comments part of increasing frustration when just spammy trash is entered. However I think it works both ways.The blogger has to have the same comitment to reading the replies as to the original blog post, and to that end should ensure the replies are as valid as the content. The atmosphere is changing rapidly out in the consumer search arena, and if the bloggers don’t run with the virtues extolled, then they will find themselves disappearing as quickly as they rose.

    Like

  2. I love your blog, you should add an RSS feed feature so I can get automatic notifications of new blogs. If you set one up please email me! i will bookmark you for now. Again Excellent Blog!

    Like

  3. Comment writing is something of a new art form, and as many people who get comments will tell you, some are great and some are horrible. In fact, I’ve embedded a hilarious video at the bottom of this article of some girls from YouTube doing a rap song about the awful comments they get on their videos. It’s called “Yo Comments are Whack,” and it’s worth the time. It’s good to know your blog is much better than these and will never end up being made fun of.

    Like

Be a good reader, leave your comment please.

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s