MEMBUAT APLIKASI PENGHITUNGAN SUHU DENGAN JAVA GUI (GRAPHICUSER INTERFACE)
Yah, langsung aja ya, tanpa banyak bacot, ini list program :
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package merubahsuhu_komplit;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.ImageIcon;
import sun.org.mozilla.javascript.internal.ast.CatchClause;
/**
*
* @author WILDAN
*/
public class coba_lagi_bos extends javax.swing.JFrame implements ActionListener{
/**
* Creates new form coba_lagi_bos
*/
public coba_lagi_bos() {
initComponents();
setIconImage(new ImageIcon(getClass().getResource("Letter-W-icon.png")).getImage() );
setLocationRelativeTo(null);//untuk menentukan frame muncul di tengah layar monitor
}
/**
* 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() {
tab_Farenhet = new javax.swing.JTabbedPane();
jPanel2 = new javax.swing.JPanel();
text_reamur = new javax.swing.JTextField();
judul_reamur = new javax.swing.JLabel();
label_reamur = new javax.swing.JLabel();
reset2 = new javax.swing.JButton();
jComboBox1_reamur = new javax.swing.JComboBox();
jLabel2_hasil_a = new javax.swing.JLabel();
jLabel2_hasil_b = new javax.swing.JLabel();
pesan_eror2 = new javax.swing.JLabel();
jPanel3 = new javax.swing.JPanel();
judul_kelfin = new javax.swing.JLabel();
text_kelfin = new javax.swing.JTextField();
label_kelfin = new javax.swing.JLabel();
reset3 = new javax.swing.JButton();
jComboBox1_kelfin = new javax.swing.JComboBox();
jLabel3_hasil_a = new javax.swing.JLabel();
jLabel3_hasil_b = new javax.swing.JLabel();
pesan_eror3 = new javax.swing.JLabel();
jPanel4 = new javax.swing.JPanel();
judul_farenhet = new javax.swing.JLabel();
text_farenhet = new javax.swing.JTextField();
label_farenhet = new javax.swing.JLabel();
reset4 = new javax.swing.JButton();
jComboBox1_farenhet = new javax.swing.JComboBox();
jLabel4_hasil_a = new javax.swing.JLabel();
jLabel4_hasil_b = new javax.swing.JLabel();
pesan_eror4 = new javax.swing.JLabel();
jPanel1 = new javax.swing.JPanel();
judul_celcius = new javax.swing.JLabel();
label_celcius = new javax.swing.JLabel();
text_celcius = new javax.swing.JTextField();
jComboBox1_Celcius = new javax.swing.JComboBox();
jLabel1_hasil_b = new javax.swing.JLabel();
reset1 = new javax.swing.JButton();
jLabel1_hasil_a = new javax.swing.JLabel();
pesan_eror1 = new javax.swing.JLabel();
setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
setTitle("Program Penghitungan Suhu (Vol : Wildan 1.0)");
setResizable(false);
addWindowListener(new java.awt.event.WindowAdapter() {
public void windowActivated(java.awt.event.WindowEvent evt) {
formWindowActivated(evt);
}
});
tab_Farenhet.setFont(new java.awt.Font("Times New Roman", 1, 11)); // NOI18N
judul_reamur.setFont(new java.awt.Font("Times New Roman", 1, 11)); // NOI18N
judul_reamur.setText(" User Memilih Menu Reamur ");
label_reamur.setFont(new java.awt.Font("Times New Roman", 1, 11)); // NOI18N
label_reamur.setText("Reamur");
reset2.setFont(new java.awt.Font("Times New Roman", 1, 11)); // NOI18N
reset2.setText("Reset");
reset2.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
reset2ActionPerformed(evt);
}
});
jComboBox1_reamur.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Celcius", "Kelfin", "Farenhet" }));
jComboBox1_reamur.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jComboBox1_reamurActionPerformed(evt);
}
});
jLabel2_hasil_a.setText("???");
jLabel2_hasil_b.setFont(new java.awt.Font("Times New Roman", 1, 11)); // NOI18N
jLabel2_hasil_b.setText("???");
pesan_eror2.setFont(new java.awt.Font("Times New Roman", 1, 12)); // NOI18N
pesan_eror2.setForeground(new java.awt.Color(255, 102, 102));
pesan_eror2.setText("Pesan Error : ");
javax.swing.GroupLayout jPanel2Layout = new javax.swing.GroupLayout(jPanel2);
jPanel2.setLayout(jPanel2Layout);
jPanel2Layout.setHorizontalGroup(
jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel2Layout.createSequentialGroup()
.addContainerGap()
.addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(reset2, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(judul_reamur, javax.swing.GroupLayout.DEFAULT_SIZE, 486, Short.MAX_VALUE)
.addGroup(jPanel2Layout.createSequentialGroup()
.addComponent(text_reamur, javax.swing.GroupLayout.PREFERRED_SIZE, 93, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addComponent(label_reamur, javax.swing.GroupLayout.PREFERRED_SIZE, 52, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(27, 27, 27)
.addComponent(jComboBox1_reamur, javax.swing.GroupLayout.PREFERRED_SIZE, 89, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(28, 28, 28)
.addComponent(jLabel2_hasil_a, javax.swing.GroupLayout.PREFERRED_SIZE, 80, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(jLabel2_hasil_b, javax.swing.GroupLayout.PREFERRED_SIZE, 74, javax.swing.GroupLayout.PREFERRED_SIZE))
.addComponent(pesan_eror2, javax.swing.GroupLayout.DEFAULT_SIZE, 486, Short.MAX_VALUE))
.addContainerGap())
);
jPanel2Layout.setVerticalGroup(
jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel2Layout.createSequentialGroup()
.addContainerGap()
.addComponent(judul_reamur, javax.swing.GroupLayout.PREFERRED_SIZE, 27, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(text_reamur, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(label_reamur, javax.swing.GroupLayout.PREFERRED_SIZE, 20, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jComboBox1_reamur, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jLabel2_hasil_a, javax.swing.GroupLayout.PREFERRED_SIZE, 21, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jLabel2_hasil_b, javax.swing.GroupLayout.PREFERRED_SIZE, 20, javax.swing.GroupLayout.PREFERRED_SIZE))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 57, Short.MAX_VALUE)
.addComponent(pesan_eror2, javax.swing.GroupLayout.PREFERRED_SIZE, 24, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(reset2)
.addContainerGap())
);
tab_Farenhet.addTab("Reamur", jPanel2);
judul_kelfin.setFont(new java.awt.Font("Times New Roman", 1, 11)); // NOI18N
judul_kelfin.setText(" User Memilih Menu Kelfin ");
label_kelfin.setFont(new java.awt.Font("Times New Roman", 1, 11)); // NOI18N
label_kelfin.setText("Kelfin");
reset3.setFont(new java.awt.Font("Times New Roman", 1, 11)); // NOI18N
reset3.setText("Reset");
reset3.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
reset3ActionPerformed(evt);
}
});
jComboBox1_kelfin.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Celcius", "Reamur", "Farenhet" }));
jComboBox1_kelfin.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jComboBox1_kelfinActionPerformed(evt);
}
});
jLabel3_hasil_a.setText("???");
jLabel3_hasil_b.setFont(new java.awt.Font("Times New Roman", 1, 11)); // NOI18N
jLabel3_hasil_b.setText("???");
pesan_eror3.setFont(new java.awt.Font("Times New Roman", 1, 12)); // NOI18N
pesan_eror3.setForeground(new java.awt.Color(255, 102, 102));
pesan_eror3.setText("Pesan Error : ");
javax.swing.GroupLayout jPanel3Layout = new javax.swing.GroupLayout(jPanel3);
jPanel3.setLayout(jPanel3Layout);
jPanel3Layout.setHorizontalGroup(
jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel3Layout.createSequentialGroup()
.addContainerGap()
.addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(reset3, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(judul_kelfin, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addGroup(jPanel3Layout.createSequentialGroup()
.addComponent(text_kelfin, javax.swing.GroupLayout.PREFERRED_SIZE, 93, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addComponent(label_kelfin, javax.swing.GroupLayout.PREFERRED_SIZE, 48, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(31, 31, 31)
.addComponent(jComboBox1_kelfin, javax.swing.GroupLayout.PREFERRED_SIZE, 89, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(28, 28, 28)
.addComponent(jLabel3_hasil_a, javax.swing.GroupLayout.PREFERRED_SIZE, 84, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(29, 29, 29)
.addComponent(jLabel3_hasil_b, javax.swing.GroupLayout.PREFERRED_SIZE, 59, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(0, 0, Short.MAX_VALUE))
.addComponent(pesan_eror3, javax.swing.GroupLayout.DEFAULT_SIZE, 486, Short.MAX_VALUE))
.addContainerGap())
);
jPanel3Layout.setVerticalGroup(
jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel3Layout.createSequentialGroup()
.addContainerGap()
.addComponent(judul_kelfin, javax.swing.GroupLayout.PREFERRED_SIZE, 27, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(text_kelfin, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(label_kelfin, javax.swing.GroupLayout.PREFERRED_SIZE, 20, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jComboBox1_kelfin, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jLabel3_hasil_a, javax.swing.GroupLayout.PREFERRED_SIZE, 21, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jLabel3_hasil_b, javax.swing.GroupLayout.PREFERRED_SIZE, 20, javax.swing.GroupLayout.PREFERRED_SIZE))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 57, Short.MAX_VALUE)
.addComponent(pesan_eror3, javax.swing.GroupLayout.PREFERRED_SIZE, 24, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(reset3)
.addContainerGap())
);
tab_Farenhet.addTab("Kelfin", jPanel3);
judul_farenhet.setFont(new java.awt.Font("Times New Roman", 1, 11)); // NOI18N
judul_farenhet.setText(" User Memilih Menu Farenhet ");
label_farenhet.setFont(new java.awt.Font("Times New Roman", 1, 11)); // NOI18N
label_farenhet.setText("Farenhet");
reset4.setFont(new java.awt.Font("Times New Roman", 1, 11)); // NOI18N
reset4.setText("Reset");
reset4.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
reset4ActionPerformed(evt);
}
});
jComboBox1_farenhet.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Celcius", "Reamur", "Kelfin" }));
jComboBox1_farenhet.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jComboBox1_farenhetActionPerformed(evt);
}
});
jLabel4_hasil_a.setText("???");
jLabel4_hasil_b.setFont(new java.awt.Font("Times New Roman", 1, 11)); // NOI18N
jLabel4_hasil_b.setText("???");
pesan_eror4.setFont(new java.awt.Font("Times New Roman", 1, 12)); // NOI18N
pesan_eror4.setForeground(new java.awt.Color(255, 102, 102));
pesan_eror4.setText("Pesan Error : ");
javax.swing.GroupLayout jPanel4Layout = new javax.swing.GroupLayout(jPanel4);
jPanel4.setLayout(jPanel4Layout);
jPanel4Layout.setHorizontalGroup(
jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel4Layout.createSequentialGroup()
.addContainerGap()
.addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(reset4, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(judul_farenhet, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addGroup(jPanel4Layout.createSequentialGroup()
.addComponent(text_farenhet, javax.swing.GroupLayout.PREFERRED_SIZE, 93, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addComponent(label_farenhet, javax.swing.GroupLayout.PREFERRED_SIZE, 48, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(31, 31, 31)
.addComponent(jComboBox1_farenhet, javax.swing.GroupLayout.PREFERRED_SIZE, 89, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(28, 28, 28)
.addComponent(jLabel4_hasil_a, javax.swing.GroupLayout.PREFERRED_SIZE, 79, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(34, 34, 34)
.addComponent(jLabel4_hasil_b, javax.swing.GroupLayout.PREFERRED_SIZE, 53, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(0, 0, Short.MAX_VALUE))
.addComponent(pesan_eror4, javax.swing.GroupLayout.DEFAULT_SIZE, 486, Short.MAX_VALUE))
.addContainerGap())
);
jPanel4Layout.setVerticalGroup(
jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel4Layout.createSequentialGroup()
.addContainerGap()
.addComponent(judul_farenhet, javax.swing.GroupLayout.PREFERRED_SIZE, 27, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(text_farenhet, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(label_farenhet, javax.swing.GroupLayout.PREFERRED_SIZE, 20, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jComboBox1_farenhet, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jLabel4_hasil_a, javax.swing.GroupLayout.PREFERRED_SIZE, 21, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jLabel4_hasil_b, javax.swing.GroupLayout.PREFERRED_SIZE, 20, javax.swing.GroupLayout.PREFERRED_SIZE))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 57, Short.MAX_VALUE)
.addComponent(pesan_eror4, javax.swing.GroupLayout.PREFERRED_SIZE, 24, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(reset4)
.addContainerGap())
);
tab_Farenhet.addTab("Farenhet", jPanel4);
judul_celcius.setFont(new java.awt.Font("Times New Roman", 1, 11)); // NOI18N
judul_celcius.setText(" User Memilih Menu Celcius ");
label_celcius.setFont(new java.awt.Font("Times New Roman", 1, 11)); // NOI18N
label_celcius.setText("Celcius");
text_celcius.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
text_celciusActionPerformed(evt);
}
});
jComboBox1_Celcius.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Reamur", "Kelfin", "Farenhet" }));
jComboBox1_Celcius.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jComboBox1_CelciusActionPerformed(evt);
}
});
jLabel1_hasil_b.setFont(new java.awt.Font("Times New Roman", 1, 11)); // NOI18N
jLabel1_hasil_b.setText("???");
reset1.setFont(new java.awt.Font("Times New Roman", 1, 11)); // NOI18N
reset1.setText("Reset");
reset1.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
reset1ActionPerformed(evt);
}
});
jLabel1_hasil_a.setText("???");
pesan_eror1.setFont(new java.awt.Font("Times New Roman", 1, 12)); // NOI18N
pesan_eror1.setForeground(new java.awt.Color(255, 102, 102));
pesan_eror1.setText("Pesan Error : ");
javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
jPanel1.setLayout(jPanel1Layout);
jPanel1Layout.setHorizontalGroup(
jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel1Layout.createSequentialGroup()
.addContainerGap()
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
.addComponent(reset1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addGroup(javax.swing.GroupLayout.Alignment.LEADING, jPanel1Layout.createSequentialGroup()
.addComponent(text_celcius, javax.swing.GroupLayout.PREFERRED_SIZE, 93, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addComponent(label_celcius, javax.swing.GroupLayout.PREFERRED_SIZE, 53, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(26, 26, 26)
.addComponent(jComboBox1_Celcius, javax.swing.GroupLayout.PREFERRED_SIZE, 89, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(28, 28, 28)
.addComponent(jLabel1_hasil_a, javax.swing.GroupLayout.PREFERRED_SIZE, 95, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(18, 18, 18)
.addComponent(jLabel1_hasil_b, javax.swing.GroupLayout.PREFERRED_SIZE, 69, javax.swing.GroupLayout.PREFERRED_SIZE))
.addComponent(pesan_eror1, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(judul_celcius, javax.swing.GroupLayout.DEFAULT_SIZE, 486, Short.MAX_VALUE))
.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
);
jPanel1Layout.setVerticalGroup(
jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel1Layout.createSequentialGroup()
.addContainerGap()
.addComponent(judul_celcius, javax.swing.GroupLayout.PREFERRED_SIZE, 27, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(text_celcius, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(label_celcius, javax.swing.GroupLayout.PREFERRED_SIZE, 20, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jComboBox1_Celcius, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jLabel1_hasil_a, javax.swing.GroupLayout.PREFERRED_SIZE, 21, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jLabel1_hasil_b, javax.swing.GroupLayout.PREFERRED_SIZE, 20, javax.swing.GroupLayout.PREFERRED_SIZE))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 57, Short.MAX_VALUE)
.addComponent(pesan_eror1, javax.swing.GroupLayout.PREFERRED_SIZE, 24, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(reset1)
.addContainerGap())
);
tab_Farenhet.addTab("Celcius", jPanel1);
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
getContentPane().setLayout(layout);
layout.setHorizontalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addGap(10, 10, 10)
.addComponent(tab_Farenhet, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
);
layout.setVerticalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addGap(11, 11, 11)
.addComponent(tab_Farenhet, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
);
pack();
}// </editor-fold>
private void jComboBox1_CelciusActionPerformed(java.awt.event.ActionEvent evt) {
jLabel1_hasil_a.setText(text_celcius.getText());
int pilih=jComboBox1_Celcius.getSelectedIndex();
double hasil_1;
//celcus ke remur
if(pilih==0){
try{
hasil_1 = (double)((Double.parseDouble(text_celcius.getText()))* 0.8);
jLabel1_hasil_a.setText(hasil_1 + " ");
jLabel1_hasil_b.setText("Reamur");
pesan_eror1.setText("Tidak Ada Kesalahan");
}
catch(NumberFormatException a){
jLabel1_hasil_a.setText("???");
jLabel1_hasil_b.setText("???");
pesan_eror1.setText("Pesan Error : Yang anda inputkan tipe data yang bukan angka");
}
}
//celcius ke kelfin
else if(pilih==1){
try{
hasil_1=(double)((Double.parseDouble(text_celcius.getText()))+273.15);
jLabel1_hasil_a.setText(hasil_1+ " ");
jLabel1_hasil_b.setText("Kelfin");
}
catch(NumberFormatException a){
jLabel1_hasil_a.setText("???");
jLabel1_hasil_b.setText("???");
pesan_eror1.setText("Pesan Error : Yang anda inputkan tipe data yang bukan angka");
}
}
//celcius ke farenhet
else if(pilih==2){
try{
hasil_1 = (double)(((Double.parseDouble(text_celcius.getText()))* 1.8)+ 32);
jLabel1_hasil_a.setText(hasil_1 + " ");
jLabel1_hasil_b.setText("Farenhet");
pesan_eror1.setText("Tidak Ada Kesalahan");
}
catch(NumberFormatException a){
jLabel1_hasil_a.setText("???");
jLabel1_hasil_b.setText("???");
pesan_eror1.setText("Pesan Error : Yang anda inputkan tipe data yang bukan angka");
}
}
}
private void reset1ActionPerformed(java.awt.event.ActionEvent evt) {
pesan_eror1.setText("Pesan Error : ");
text_celcius.setText(" ");
jLabel1_hasil_a.setText("???");
jLabel1_hasil_b.setText("???");
}
private void reset2ActionPerformed(java.awt.event.ActionEvent evt) {
pesan_eror2.setText("Pesan Error : ");
text_reamur.setText(" ");
jLabel2_hasil_a.setText("???");
jLabel2_hasil_b.setText("???");
}
private void reset3ActionPerformed(java.awt.event.ActionEvent evt) {
pesan_eror3.setText("Pesan Error : ");
text_kelfin.setText(" ");
jLabel3_hasil_a.setText("???");
jLabel3_hasil_b.setText("???");
}
private void reset4ActionPerformed(java.awt.event.ActionEvent evt) {
pesan_eror4.setText("Pesan Error : ");
text_kelfin.setText(" ");
jLabel4_hasil_a.setText("???");
jLabel4_hasil_b.setText("???");
}
private void jComboBox1_reamurActionPerformed(java.awt.event.ActionEvent evt) {
jLabel2_hasil_a.setText(text_reamur.getText());
int pilih=jComboBox1_reamur.getSelectedIndex();
double hasil_2;
// remur ke celcus
if(pilih==0){
try{
hasil_2 = (double)((Double.parseDouble(text_reamur.getText()))/ 0.8);
jLabel2_hasil_a.setText(hasil_2 + " ");
jLabel2_hasil_b.setText("Celcius");
pesan_eror2.setText("Tidak Ada Kesalahan");
}
catch(NumberFormatException a){
jLabel2_hasil_a.setText("???");
jLabel2_hasil_b.setText("???");
pesan_eror2.setText("Pesan Error : Yang anda inputkan tipe data yang bukan angka");
}
}
//reamur ke kelfin
else if(pilih==1){
try{
hasil_2=(double)(((Double.parseDouble(text_celcius.getText()))/0.8)+273.15);
jLabel2_hasil_a.setText(hasil_2+ " ");
jLabel2_hasil_b.setText("Kelfin");
}
catch(NumberFormatException a){
jLabel2_hasil_a.setText("???");
jLabel2_hasil_b.setText("???");
pesan_eror2.setText("Pesan Error : Yang anda inputkan tipe data yang bukan angka");
}
}
//reamur ke farenhet
else if(pilih==2){
try{
hasil_2 = (double)(((Double.parseDouble(text_celcius.getText()))* 2.25)+ 32);
jLabel2_hasil_a.setText(hasil_2 + " ");
jLabel2_hasil_b.setText("Farenhet");
pesan_eror2.setText("Tidak Ada Kesalahan");
}
catch(NumberFormatException a){
jLabel2_hasil_a.setText("???");
jLabel2_hasil_b.setText("???");
pesan_eror2.setText("Pesan Error : Yang anda inputkan tipe data yang bukan angka");
}
}
}
private void jComboBox1_kelfinActionPerformed(java.awt.event.ActionEvent evt) {
jLabel3_hasil_a.setText(text_kelfin.getText());
int pilih=jComboBox1_kelfin.getSelectedIndex();
double hasil3;
//kelfin ke celcius
if(pilih==0){
try {
hasil3=(double)((Double.parseDouble(text_kelfin.getText()))-273.15);
jLabel3_hasil_a.setText(hasil3+" ");
jLabel3_hasil_b.setText("Celcius");
pesan_eror3.setText("Tidak Ada Kesalahan");
}
catch (Exception e) {
jLabel3_hasil_a.setText("???");
jLabel3_hasil_b.setText("???");
pesan_eror3.setText("Pesan Error : Yang anda inputkan tipe data yang bukan angka");
}
}
//kelfin ke reamur
else if(pilih==1){
try {
hasil3=(double)(((Double.parseDouble(text_kelfin.getText()))-273.15)*0.8);
jLabel3_hasil_a.setText(hasil3+" ");
jLabel3_hasil_b.setText("Reamur");
pesan_eror3.setText("Tidak Ada Kesalahan");
} catch (Exception e) {
jLabel3_hasil_a.setText("???");
jLabel3_hasil_b.setText("???");
pesan_eror3.setText("Pesan Error : Yang anda inputkan tipe data yang bukan angka");
}
}
//kelfin ke farenhet
else if(pilih==2){
try {
hasil3=(double)(((Double.parseDouble(text_kelfin.getText()))*1.8)-459.67);
jLabel3_hasil_a.setText(hasil3+" ");
jLabel3_hasil_b.setText("Reamur");
pesan_eror3.setText("Tidak Ada Kesalahan");
} catch (Exception e) {
jLabel3_hasil_a.setText("???");
jLabel3_hasil_b.setText("???");
pesan_eror3.setText("Pesan Error : Yang anda inputkan tipe data yang bukan angka");
}
}
}
private void jComboBox1_farenhetActionPerformed(java.awt.event.ActionEvent evt) {
jLabel4_hasil_a.setText(text_farenhet.getText());
int pilih=jComboBox1_farenhet.getSelectedIndex();
double hasil4;
//farenhet ke celcius
if(pilih==0){
try {
hasil4=(double)(((Double.parseDouble(text_farenhet.getText()))-32)/1.8);
jLabel4_hasil_a.setText(hasil4+" ");
jLabel4_hasil_b.setText("Celcius");
pesan_eror4.setText("Tidak Ada Kesalahan");
} catch (Exception e) {
jLabel4_hasil_a.setText("???");
jLabel4_hasil_a.setText("???");
pesan_eror4.setText("Pesan Error : Yang anda inputkan tipe data yang bukan angka");
}
}
//farenhet ke reamur
else if(pilih==1){
try {
hasil4=(double)(((Double.parseDouble(text_farenhet.getText()))-32)/2.25);
jLabel4_hasil_a.setText(hasil4+" ");
jLabel4_hasil_b.setText("Reamur");
pesan_eror4.setText("Tidak Ada Kesalahan");
} catch (Exception e) {
jLabel4_hasil_a.setText("???");
jLabel4_hasil_a.setText("???");
pesan_eror4.setText("Pesan Error : Yang anda inputkan tipe data yang bukan angka");
}
}
//farehet ke kelfin
else if(pilih==2){
try{
hasil4=(double)(((Double.parseDouble(text_farenhet.getText()))+459.67)/1.8);
jLabel4_hasil_a.setText(hasil4+" ");
jLabel4_hasil_b.setText("Kelfin");
pesan_eror4.setText("Tidak Ada Kesalahan");
}catch(Exception a){
jLabel4_hasil_a.setText("???");
jLabel4_hasil_a.setText("???");
pesan_eror4.setText("Pesan Error : Yang anda inputkan tipe data yang bukan angka");
}
}
}
private void formWindowActivated(java.awt.event.WindowEvent evt) {
}
private void text_celciusActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
}
/**
* @param args the command line arguments
*/
public static void main(String args[]) {
/*
* Set the Nimbus look and feel
*/
//<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
/*
* If Nimbus (introduced in Java SE 6) is not available, stay with the
* default look and feel. For details see
* http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html
*/
try {
for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
if ("Nimbus".equals(info.getName())) {
javax.swing.UIManager.setLookAndFeel(info.getClassName());
break;
}
}
} catch (ClassNotFoundException ex) {
java.util.logging.Logger.getLogger(coba_lagi_bos.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
} catch (InstantiationException ex) {
java.util.logging.Logger.getLogger(coba_lagi_bos.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
} catch (IllegalAccessException ex) {
java.util.logging.Logger.getLogger(coba_lagi_bos.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
} catch (javax.swing.UnsupportedLookAndFeelException ex) {
java.util.logging.Logger.getLogger(coba_lagi_bos.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
}
//</editor-fold>
/*
* Create and display the form
*/
java.awt.EventQueue.invokeLater(new Runnable() {
public void run() {
coba_lagi_bos aa=new coba_lagi_bos();
aa.setVisible(true);
//aa.setLocation(400,230);
}
});
}
// Variables declaration - do not modify
private javax.swing.JComboBox jComboBox1_Celcius;
private javax.swing.JComboBox jComboBox1_farenhet;
private javax.swing.JComboBox jComboBox1_kelfin;
private javax.swing.JComboBox jComboBox1_reamur;
private javax.swing.JLabel jLabel1_hasil_a;
private javax.swing.JLabel jLabel1_hasil_b;
private javax.swing.JLabel jLabel2_hasil_a;
private javax.swing.JLabel jLabel2_hasil_b;
private javax.swing.JLabel jLabel3_hasil_a;
private javax.swing.JLabel jLabel3_hasil_b;
private javax.swing.JLabel jLabel4_hasil_a;
private javax.swing.JLabel jLabel4_hasil_b;
private javax.swing.JPanel jPanel1;
private javax.swing.JPanel jPanel2;
private javax.swing.JPanel jPanel3;
private javax.swing.JPanel jPanel4;
private javax.swing.JLabel judul_celcius;
private javax.swing.JLabel judul_farenhet;
private javax.swing.JLabel judul_kelfin;
private javax.swing.JLabel judul_reamur;
private javax.swing.JLabel label_celcius;
private javax.swing.JLabel label_farenhet;
private javax.swing.JLabel label_kelfin;
private javax.swing.JLabel label_reamur;
private javax.swing.JLabel pesan_eror1;
private javax.swing.JLabel pesan_eror2;
private javax.swing.JLabel pesan_eror3;
private javax.swing.JLabel pesan_eror4;
private javax.swing.JButton reset1;
private javax.swing.JButton reset2;
private javax.swing.JButton reset3;
private javax.swing.JButton reset4;
private javax.swing.JTabbedPane tab_Farenhet;
private javax.swing.JTextField text_celcius;
private javax.swing.JTextField text_farenhet;
private javax.swing.JTextField text_kelfin;
private javax.swing.JTextField text_reamur;
// End of variables declaration
@Override
public void actionPerformed(ActionEvent e) {
throw new UnsupportedOperationException("Not supported yet.");
}
}
Dan berikut adalah secuil gambaran dari hasil program Ane :
yang mau Copas, Atau Dipelajari, Atau Mau ditambahin fitur-fiturnya, Atau yang lain, Atau terserah panjenengan lah Mau di apain . :D
I Love Coding. Aseeek.