package javaapplication3;
public class Converter extends javax.swing.JFrame {
public Converter() {
initComponents();
}
@SuppressWarnings("unchecked")
// <editor-fold defaultstate="collapsed" desc="Generated Code">
private void initComponents() {
Group = new javax.swing.ButtonGroup();
buttonGroup1 = new javax.swing.ButtonGroup();
Hasil = new javax.swing.JTextField();
Pixel = new javax.swing.JLabel();
jLabel1 = new javax.swing.JLabel();
BPixel = new javax.swing.JButton();
jSeparator1 = new javax.swing.JSeparator();
Hasil3 = new javax.swing.JTextField();
CM1 = new javax.swing.JLabel();
jLabel2 = new javax.swing.JLabel();
pc = new javax.swing.JButton();
setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
Pixel.setText("Pixel");
jLabel1.setText("Aplikasi Convert Pixel ke CM");
BPixel.setText("CM ke Pixel");
BPixel.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
BPixelActionPerformed(evt);
}
});
Hasil3.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
Hasil3ActionPerformed(evt);
}
});
CM1.setText("CM");
jLabel2.setText("Aplikasi Convert CM ke Pixel");
pc.setText("Pixel ke CM");
pc.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
pcActionPerformed(evt);
}
});
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
getContentPane().setLayout(layout);
layout.setHorizontalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addContainerGap()
.addComponent(pc)
.addGap(18, 18, 18)
.addComponent(Hasil, javax.swing.GroupLayout.PREFERRED_SIZE, 79, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(10, 10, 10)
.addComponent(Pixel))
.addGroup(layout.createSequentialGroup()
.addGap(20, 20, 20)
.addComponent(jLabel1)))
.addContainerGap(37, Short.MAX_VALUE))
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
.addContainerGap()
.addComponent(BPixel, javax.swing.GroupLayout.DEFAULT_SIZE, 87, Short.MAX_VALUE)
.addGap(18, 18, 18)
.addComponent(Hasil3, javax.swing.GroupLayout.PREFERRED_SIZE, 76, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addComponent(CM1)
.addGap(47, 47, 47))
.addGroup(layout.createSequentialGroup()
.addGap(20, 20, 20)
.addComponent(jLabel2)
.addGap(109, 109, 109))
.addComponent(jSeparator1, javax.swing.GroupLayout.DEFAULT_SIZE, 263, Short.MAX_VALUE)
);
layout.setVerticalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addComponent(jLabel1)
.addGap(18, 18, 18)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(pc)
.addComponent(Hasil, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(Pixel))
.addGap(19, 19, 19)
.addComponent(jSeparator1, javax.swing.GroupLayout.PREFERRED_SIZE, 10, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(jLabel2)
.addGap(18, 18, 18)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(BPixel)
.addComponent(Hasil3, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(CM1))
.addContainerGap(26, Short.MAX_VALUE))
);
pack();
}// </editor-fold>
private void BPixelActionPerformed(java.awt.event.ActionEvent evt) {
double fahrenheit = Double.parseDouble(Hasil3.getText()) * 28;
Hasil3.setText(fahrenheit + " ");
CM1.setText("Pixel");
}
private void Hasil3ActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
}
private void pcActionPerformed(java.awt.event.ActionEvent evt) {
double fahrenheit = Double.parseDouble(Hasil.getText()) * 0.04;
Hasil.setText(fahrenheit + " ");
Pixel.setText("CM");
}
/**
* @param args the command line arguments
*/
public static void main(String args[]) {
java.awt.EventQueue.invokeLater(new Runnable() {
public void run() {
new Converter().setVisible(true);
}
});
}
// Variables declaration - do not modify
private javax.swing.JButton BPixel;
private javax.swing.JLabel CM1;
private javax.swing.ButtonGroup Group;
private javax.swing.JTextField Hasil;
private javax.swing.JTextField Hasil3;
private javax.swing.JLabel Pixel;
private javax.swing.ButtonGroup buttonGroup1;
private javax.swing.JLabel jLabel1;
private javax.swing.JLabel jLabel2;
private javax.swing.JSeparator jSeparator1;
private javax.swing.JButton pc;
// End of variables declaration
}
Output:
Tidak ada komentar:
Posting Komentar