/* * To change this template, choose Tools | Templates * and open the template in the editor. */ /* * SimpleNettoApplet.java * * Created on 21-mei-2009, 16:52:39 */ package Hypotheek; import java.awt.Color; import static Hypotheek.Util.* ; /** * * @author Wishnu Prasetya */ public class SimpleNettoApplet extends javax.swing.JApplet { /** Initializes the applet SimpleNettoApplet */ public void init() { try { java.awt.EventQueue.invokeAndWait(new Runnable() { public void run() { initComponents(); } }); } catch (Exception ex) { ex.printStackTrace(); } } /** This method is called from within the init() method to * initialize the form. * WARNING: Do NOT modify this code. The content of this method is * always regenerated by the Form Editor. */ @SuppressWarnings("unchecked") // //GEN-BEGIN:initComponents private void initComponents() { HeaderPane = new javax.swing.JPanel(); jSeparator2 = new javax.swing.JSeparator(); title = new javax.swing.JLabel(); author = new javax.swing.JLabel(); jSeparator3 = new javax.swing.JSeparator(); CenterPane = new javax.swing.JPanel(); InputPane = new javax.swing.JPanel(); jLabel1 = new javax.swing.JLabel(); bruto_field = new javax.swing.JTextField(); jLabel3 = new javax.swing.JLabel(); jLabel2 = new javax.swing.JLabel(); age_field = new javax.swing.JTextField(); jLabel4 = new javax.swing.JLabel(); bereken_button = new javax.swing.JButton(); OutputPane = new javax.swing.JScrollPane(); output_area = new javax.swing.JTextArea(); setBackground(new java.awt.Color(204, 204, 255)); HeaderPane.setBackground(new java.awt.Color(102, 102, 255)); HeaderPane.setLayout(new java.awt.GridLayout(4, 0)); jSeparator2.setBackground(new java.awt.Color(102, 102, 255)); jSeparator2.setForeground(new java.awt.Color(102, 102, 255)); HeaderPane.add(jSeparator2); title.setFont(new java.awt.Font("Arial", 1, 14)); title.setForeground(new java.awt.Color(204, 204, 255)); title.setText(" Bruto-naar-Netto X-press-Calculator (2009)"); HeaderPane.add(title); author.setFont(new java.awt.Font("Arial", 0, 10)); author.setForeground(new java.awt.Color(204, 204, 204)); author.setText(" Copyright (c) W. Prasetya, 2009"); HeaderPane.add(author); jSeparator3.setBackground(new java.awt.Color(102, 102, 255)); jSeparator3.setForeground(new java.awt.Color(102, 102, 255)); HeaderPane.add(jSeparator3); getContentPane().add(HeaderPane, java.awt.BorderLayout.NORTH); InputPane.setBackground(new java.awt.Color(204, 204, 255)); InputPane.setMinimumSize(new java.awt.Dimension(300, 50)); InputPane.setPreferredSize(new java.awt.Dimension(300, 50)); jLabel1.setFont(new java.awt.Font("Arial", 0, 12)); jLabel1.setText(" Bruto jaarinkomen "); jLabel1.setToolTipText("Uw jaarlijksbruto inkomen, exclusief de verplichte bijdrage van uw werkgever voor de zorgverzekeringen."); bruto_field.setColumns(9); bruto_field.setHorizontalAlignment(javax.swing.JTextField.RIGHT); bruto_field.setText("10000"); bruto_field.setToolTipText("Uw jaarlijksbruto inkomen, exclusief de verplichte bijdrage van uw werkgever voor de zorgverzekeringen."); jLabel3.setFont(new java.awt.Font("Arial", 0, 12)); jLabel3.setText(" euro"); jLabel2.setFont(new java.awt.Font("Arial", 0, 12)); jLabel2.setText(" Leeftijd "); age_field.setColumns(3); age_field.setHorizontalAlignment(javax.swing.JTextField.RIGHT); age_field.setText("30"); jLabel4.setFont(new java.awt.Font("Arial", 0, 12)); jLabel4.setText(" jaar"); bereken_button.setBackground(new java.awt.Color(204, 204, 255)); bereken_button.setFont(new java.awt.Font("Arial", 1, 12)); bereken_button.setForeground(new java.awt.Color(102, 102, 102)); bereken_button.setText("Bereken netto"); bereken_button.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { bereken_buttonActionPerformed(evt); } }); javax.swing.GroupLayout InputPaneLayout = new javax.swing.GroupLayout(InputPane); InputPane.setLayout(InputPaneLayout); InputPaneLayout.setHorizontalGroup( InputPaneLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(InputPaneLayout.createSequentialGroup() .addGroup(InputPaneLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, InputPaneLayout.createSequentialGroup() .addComponent(jLabel1, javax.swing.GroupLayout.DEFAULT_SIZE, 116, Short.MAX_VALUE) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(bruto_field, javax.swing.GroupLayout.PREFERRED_SIZE, 83, javax.swing.GroupLayout.PREFERRED_SIZE) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(jLabel3, javax.swing.GroupLayout.PREFERRED_SIZE, 83, javax.swing.GroupLayout.PREFERRED_SIZE)) .addGroup(InputPaneLayout.createSequentialGroup() .addComponent(jLabel2, javax.swing.GroupLayout.PREFERRED_SIZE, 83, javax.swing.GroupLayout.PREFERRED_SIZE) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 81, Short.MAX_VALUE) .addComponent(age_field, javax.swing.GroupLayout.PREFERRED_SIZE, 39, javax.swing.GroupLayout.PREFERRED_SIZE) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(jLabel4, javax.swing.GroupLayout.PREFERRED_SIZE, 83, javax.swing.GroupLayout.PREFERRED_SIZE)) .addGroup(InputPaneLayout.createSequentialGroup() .addContainerGap() .addComponent(bereken_button))) .addContainerGap()) ); InputPaneLayout.setVerticalGroup( InputPaneLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(InputPaneLayout.createSequentialGroup() .addGroup(InputPaneLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(InputPaneLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(jLabel3, javax.swing.GroupLayout.PREFERRED_SIZE, 33, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(bruto_field, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) .addComponent(jLabel1, javax.swing.GroupLayout.PREFERRED_SIZE, 33, javax.swing.GroupLayout.PREFERRED_SIZE)) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addGroup(InputPaneLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addComponent(jLabel2, javax.swing.GroupLayout.PREFERRED_SIZE, 33, javax.swing.GroupLayout.PREFERRED_SIZE) .addGroup(InputPaneLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(jLabel4, javax.swing.GroupLayout.PREFERRED_SIZE, 33, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(age_field, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))) .addGap(18, 18, 18) .addComponent(bereken_button) .addContainerGap(85, Short.MAX_VALUE)) ); OutputPane.setMinimumSize(new java.awt.Dimension(300, 200)); OutputPane.setPreferredSize(new java.awt.Dimension(300, 200)); output_area.setColumns(50); output_area.setEditable(false); output_area.setFont(new java.awt.Font("Monospaced", 0, 12)); output_area.setRows(5); OutputPane.setViewportView(output_area); javax.swing.GroupLayout CenterPaneLayout = new javax.swing.GroupLayout(CenterPane); CenterPane.setLayout(CenterPaneLayout); CenterPaneLayout.setHorizontalGroup( CenterPaneLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(CenterPaneLayout.createSequentialGroup() .addComponent(InputPane, javax.swing.GroupLayout.PREFERRED_SIZE, 280, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(OutputPane, javax.swing.GroupLayout.PREFERRED_SIZE, 360, javax.swing.GroupLayout.PREFERRED_SIZE)) ); CenterPaneLayout.setVerticalGroup( CenterPaneLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addComponent(InputPane, javax.swing.GroupLayout.PREFERRED_SIZE, 200, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(OutputPane, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) ); getContentPane().add(CenterPane, java.awt.BorderLayout.CENTER); }// //GEN-END:initComponents Netto nettoLogic = new Netto() ; private void bereken_buttonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_bereken_buttonActionPerformed output_area.setText("") ; try { //System.out.println(">>>" + age_field.getText()) ; nettoLogic.bruto = euro2cent(Integer.parseInt(bruto_field.getText())) ; if (nettoLogic.bruto<0) { output_area.setForeground(Color.RED) ; output_area.setText("** FOUT: negatieve inkomen.") ; return ; } if (nettoLogic.bruto>=Netto.BRUTO_MAX) { output_area.setForeground(Color.RED) ; output_area.setText("** FOUT: inkomen te groot (voor deze applet :).") ; return ; } } catch(NumberFormatException e) { output_area.setForeground(Color.RED) ; output_area.setText("** FOUT in de dataformaat van inkomen.") ; //System.out.println(">>> FOUT.") ; return ; } try { nettoLogic.age = Integer.parseInt(age_field.getText()) ; if (nettoLogic.age<0) { output_area.setForeground(Color.RED) ; output_area.setText("** FOUT: negatieve leeftijd.") ; return ; } if (nettoLogic.age>=Netto.AGE_MAX) { output_area.setForeground(Color.RED) ; output_area.setText("** FOUT: leeftijd te groot (voor deze applet :).") ; return ; } } catch(NumberFormatException e) { output_area.setForeground(Color.RED) ; output_area.setText("** FOUT in de dataformaat van leeftijd.") ; return ; } String output = nettoLogic.printResult(nettoLogic.calc()) ; output_area.setForeground(Color.BLACK) ; output_area.setText(output) ; }//GEN-LAST:event_bereken_buttonActionPerformed // Variables declaration - do not modify//GEN-BEGIN:variables private javax.swing.JPanel CenterPane; private javax.swing.JPanel HeaderPane; private javax.swing.JPanel InputPane; private javax.swing.JScrollPane OutputPane; private javax.swing.JTextField age_field; private javax.swing.JLabel author; private javax.swing.JButton bereken_button; private javax.swing.JTextField bruto_field; private javax.swing.JLabel jLabel1; private javax.swing.JLabel jLabel2; private javax.swing.JLabel jLabel3; private javax.swing.JLabel jLabel4; private javax.swing.JSeparator jSeparator2; private javax.swing.JSeparator jSeparator3; private javax.swing.JTextArea output_area; private javax.swing.JLabel title; // End of variables declaration//GEN-END:variables }