Nama                          : Urianus Gombo
Npm                            : 181010042
Mata Kuliah / SKS       : Pemrog. Visual
Dosen Penguji             : Tony Sugiarso, SE, M.Kom
Hari / Tanggal              : Sabtu, 11 April 2020
Kelas / Semester        : Reguler B / IV
Waktu Ujian                 : 100 menit


-         desain ui


-         Run Program
 






























-         Source code

 import java.awt.event.KeyEvent;
import javax.swing.JOptionPane;

/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

/**
 *
 * @author nus
 */
public class konversi_suhu extends javax.swing.JFrame {

    /**
     * Creates new form konversi_suhu
     */
    public konversi_suhu() {
        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() {

        jLabel1 = new javax.swing.JLabel();
        jLabel2 = new javax.swing.JLabel();
        txtcelcius = new javax.swing.JTextField();
        txtfahrenheit = new javax.swing.JTextField();
        btncount = new javax.swing.JButton();
        btndelete = new javax.swing.JButton();
        jLabel3 = new javax.swing.JLabel();
        jLabel4 = new javax.swing.JLabel();
        txtreamur = new javax.swing.JTextField();
        txtkelvin = new javax.swing.JTextField();
        jLabel5 = new javax.swing.JLabel();
        btnback = new javax.swing.JButton();

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
        setBackground(new java.awt.Color(255, 51, 0));
        setCursor(new java.awt.Cursor(java.awt.Cursor.DEFAULT_CURSOR));

        jLabel1.setFont(new java.awt.Font("MS PGothic", 1, 18)); // NOI18N
        jLabel1.setText("CODINGAN MENGHITUNG NILAI KONVERSI");

        jLabel2.setFont(new java.awt.Font("Corbel", 1, 11)); // NOI18N
        jLabel2.setText("Celcius");

        txtcelcius.setBackground(new java.awt.Color(255, 255, 0));
        txtcelcius.setForeground(new java.awt.Color(153, 204, 255));

        txtfahrenheit.setBackground(new java.awt.Color(255, 255, 0));
        txtfahrenheit.setForeground(new java.awt.Color(153, 204, 255));

        btncount.setBackground(new java.awt.Color(51, 102, 255));
        btncount.setText("Count");
        btncount.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btncountActionPerformed(evt);
            }
        });

        btndelete.setBackground(new java.awt.Color(51, 102, 255));
        btndelete.setText("Delete");
        btndelete.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btndeleteActionPerformed(evt);
            }
        });

        jLabel3.setFont(new java.awt.Font("Corbel", 1, 11)); // NOI18N
        jLabel3.setText("Fahrenheit");

        jLabel4.setFont(new java.awt.Font("Corbel", 1, 11)); // NOI18N
        jLabel4.setText("Reamur");

        txtreamur.setBackground(new java.awt.Color(255, 255, 0));
        txtreamur.setForeground(new java.awt.Color(153, 204, 255));

        txtkelvin.setBackground(new java.awt.Color(255, 255, 0));
        txtkelvin.setForeground(new java.awt.Color(153, 204, 255));

        jLabel5.setFont(new java.awt.Font("Corbel", 1, 11)); // NOI18N
        jLabel5.setText("Kelvin");

        btnback.setBackground(new java.awt.Color(51, 102, 255));
        btnback.setText("Back");
        btnback.addFocusListener(new java.awt.event.FocusAdapter() {
            public void focusGained(java.awt.event.FocusEvent evt) {
                btnbackFocusGained(evt);
            }
        });
        btnback.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyPressed(java.awt.event.KeyEvent evt) {
                btnbackKeyPressed(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()
                .addGap(30, 30, 30)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jLabel1)
                    .addGroup(layout.createSequentialGroup()
                        .addComponent(jLabel2)
                        .addGap(47, 47, 47)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(btndelete)
                            .addComponent(btncount)
                            .addComponent(txtcelcius, javax.swing.GroupLayout.PREFERRED_SIZE, 216, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(btnback))))
                .addContainerGap(47, Short.MAX_VALUE))
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(txtfahrenheit, javax.swing.GroupLayout.PREFERRED_SIZE, 73, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel3))
                .addGap(40, 40, 40)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(txtreamur, javax.swing.GroupLayout.PREFERRED_SIZE, 73, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel4))
                .addGap(36, 36, 36)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jLabel5)
                    .addComponent(txtkelvin, javax.swing.GroupLayout.PREFERRED_SIZE, 73, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(0, 0, Short.MAX_VALUE))
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jLabel1)
                .addGap(18, 18, 18)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel2)
                    .addComponent(txtcelcius, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(btncount)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(btndelete)
                .addGap(11, 11, 11)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel4)
                    .addComponent(jLabel5)
                    .addComponent(jLabel3))
                .addGap(3, 3, 3)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                    .addComponent(txtkelvin, javax.swing.GroupLayout.DEFAULT_SIZE, 37, Short.MAX_VALUE)
                    .addComponent(txtreamur)
                    .addComponent(txtfahrenheit))
                .addGap(26, 26, 26)
                .addComponent(btnback)
                .addContainerGap(143, Short.MAX_VALUE))
        );

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

    private void btncountActionPerformed(java.awt.event.ActionEvent evt) {                                        
        // TODO add your handling code here:
        try{
            float c = Float.parseFloat(txtcelcius.getText());
            float f = (float) (c * 1.8 + 32);
            float r = (float) (c * 0.8);
            float k = (float) (c + 273.15);
            txtfahrenheit.setText(""+f);
            txtreamur.setText(""+r);
            txtkelvin.setText(""+k);
        }catch(NumberFormatException ex){
            JOptionPane.showMessageDialog(null, "Nilai codingan anda belum disi!!");
        }
    }                                       

    private void btndeleteActionPerformed(java.awt.event.ActionEvent evt) {                                         
        // TODO add your handling code here:
        txtcelcius.setText("");
        txtfahrenheit.setText("");
        txtreamur.setText("");
        txtkelvin.setText("");
    }                                         

    private void btnbackFocusGained(java.awt.event.FocusEvent evt) {                                   
        // TODO add your handling code here:
    }                                  

    private void btnbackKeyPressed(java.awt.event.KeyEvent evt) {                                  
        // TODO add your handling code here:
        if(evt.getKeyCode()==KeyEvent.VK_ENTER){
            txtcelcius.requestFocus();
        }
    }                                 

    /**
     * @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(konversi_suhu.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (InstantiationException ex) {
            java.util.logging.Logger.getLogger(konversi_suhu.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (IllegalAccessException ex) {
            java.util.logging.Logger.getLogger(konversi_suhu.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (javax.swing.UnsupportedLookAndFeelException ex) {
            java.util.logging.Logger.getLogger(konversi_suhu.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() {
                new konversi_suhu().setVisible(true);
            }
        });
    }

    // Variables declaration - do not modify                    
    private javax.swing.JButton btnback;
    private javax.swing.JButton btncount;
    private javax.swing.JButton btndelete;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel jLabel3;
    private javax.swing.JLabel jLabel4;
    private javax.swing.JLabel jLabel5;
    private javax.swing.JTextField txtcelcius;
    private javax.swing.JTextField txtfahrenheit;
    private javax.swing.JTextField txtkelvin;
    private javax.swing.JTextField txtreamur;
    // End of variables declaration                  
}

Komentar

Postingan populer dari blog ini

lirik lagu wa nombae

Lirik Lagu Bahasa Sub Allah Byana