menembus batas impian


/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/

/*
* pasaran.java
*
* Created on Jul 20, 2013, 5:39:16 PM
*/
package sikeysa.form;

import java.util.Calendar;
import java.util.Date;
import javax.swing.JOptionPane;
import javax.swing.event.ListSelectionEvent;
import javax.swing.event.ListSelectionListener;
import java.text.DateFormat;
import java.text.DecimalFormat;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.logging.Level;
import java.util.logging.Logger;

/**
*
* @author nk
*/
public class pasaran extends javax.swing.JInternalFrame {
// private Object df;

/** Creates new form pasaran */
public pasaran() {
initComponents();tgl1.setText(“2013-01-01”);
}

/** 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”)
//
private void initComponents() {

tgl2 = new javax.swing.JFormattedTextField();
jButton1 = new javax.swing.JButton();
tgl1 = new javax.swing.JFormattedTextField();
tgl3 = new javax.swing.JFormattedTextField();
fmodal = new formattedfields.FormattedDoubleField();
jLabel1 = new javax.swing.JLabel();

setName(“Form”); // NOI18N

tgl2.setFormatterFactory(new javax.swing.text.DefaultFormatterFactory(new javax.swing.text.DateFormatter(new java.text.SimpleDateFormat(“yyyy-MM-dd”))));
tgl2.setName(“tgl2”); // NOI18N
tgl2.setValue(new java.util.Date());

jButton1.setName(“jButton1”); // NOI18N
jButton1.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButton1ActionPerformed(evt);
}
});

tgl1.setFormatterFactory(new javax.swing.text.DefaultFormatterFactory(new javax.swing.text.DateFormatter(new java.text.SimpleDateFormat(“yyyy-MM-dd”))));
tgl1.setEnabled(false);
tgl1.setName(“tgl1”); // NOI18N
tgl1.setValue(new java.util.Date());
tgl1.addKeyListener(new java.awt.event.KeyAdapter() {
public void keyPressed(java.awt.event.KeyEvent evt) {
tgl1KeyPressed(evt);
}
});

tgl3.setEnabled(false);
tgl3.setName(“tgl3”); // NOI18N
tgl3.setValue(new java.util.Date());

fmodal.setEnabled(false);
fmodal.setName(“fmodal”); // NOI18N
fmodal.addKeyListener(new java.awt.event.KeyAdapter() {
public void keyPressed(java.awt.event.KeyEvent evt) {
fmodalKeyPressed(evt);
}
});

jLabel1.setName(“jLabel1”); // NOI18N

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()
.addGap(142, 142, 142)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addComponent(jButton1, javax.swing.GroupLayout.PREFERRED_SIZE, 117, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(jLabel1, javax.swing.GroupLayout.PREFERRED_SIZE, 83, javax.swing.GroupLayout.PREFERRED_SIZE))
.addComponent(tgl1, javax.swing.GroupLayout.PREFERRED_SIZE, 100, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(tgl2, javax.swing.GroupLayout.PREFERRED_SIZE, 100, javax.swing.GroupLayout.PREFERRED_SIZE)))
.addGroup(layout.createSequentialGroup()
.addContainerGap()
.addComponent(tgl3, javax.swing.GroupLayout.PREFERRED_SIZE, 100, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGroup(layout.createSequentialGroup()
.addGap(122, 122, 122)
.addComponent(fmodal, javax.swing.GroupLayout.PREFERRED_SIZE, 150, javax.swing.GroupLayout.PREFERRED_SIZE)))
.addContainerGap(40, Short.MAX_VALUE))
);
layout.setVerticalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
.addContainerGap(45, Short.MAX_VALUE)
.addComponent(tgl3, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(tgl1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(18, 18, 18)
.addComponent(tgl2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(fmodal, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(9, 9, 9)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
.addGroup(layout.createSequentialGroup()
.addComponent(jLabel1, javax.swing.GroupLayout.PREFERRED_SIZE, 24, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(65, 65, 65))
.addGroup(layout.createSequentialGroup()
.addComponent(jButton1, javax.swing.GroupLayout.PREFERRED_SIZE, 26, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(46, 46, 46))))
);

pack();
}//

private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {
// double hasil = 0;
try{
DateFormat df7 = new SimpleDateFormat(“dd-MM-yyyy”);
//tgl1.setText(“2013-01-01″);
String x1=tgl1.getText().substring(8,10);
String x2=tgl1.getText().substring(5,7);
String x3=tgl1.getText().substring(0,4);
String v1=tgl2.getText().substring(8,10);
String v2=tgl2.getText().substring(5,7);
String v3=tgl2.getText().substring(0,4);

System.out.println(x3+”/”+x2+”/”+x1);
Date TanggalPinjam =df7.parse(x1+”-“+x2+”-“+x3);
Date TanggalKembali = df7.parse(v1+”-“+v2+”-“+v3);
double l=(24 * 60 * 60 * 1000);
//Tgl di konversi ke milidetik
double Hari1 = TanggalPinjam.getTime();
double Hari2 = TanggalKembali.getTime();
double Lama=3;
double ll= (Hari2-Hari1);
double lll= (ll/l);
double lx=lll/5;

int b= (int) lx;
double hasil=lx-b;

fmodal.setValue(hasil);
DecimalFormat df = new DecimalFormat(“###.#”);
String hasils =df.format(hasil);

System.out.println((hasils+”–“+b));
if(hasils.equals(“0”)){jLabel1.setText(“KLIWON”);}
else if(hasils.equals(“0.2”)){jLabel1.setText(“LEGI”);}
else if(hasils.equals(“0.4”)){jLabel1.setText(“PAING”);}
else if(hasils.equals(“0.6”)){jLabel1.setText(“PON”);}
else if(hasils.equals(“0.8”)){jLabel1.setText(“WAGE”);}
else if(hasils.equals(“-0.2”)){jLabel1.setText(“WAGE”);}
else if(hasils.equals(“-0.4”)){jLabel1.setText(“PON”);}
else if(hasils.equals(“-0.6”)){jLabel1.setText(“PAING”);}
else if(hasils.equals(“-0.8”)){jLabel1.setText(“LEGI”);}

} catch (ParseException e)
{
e.printStackTrace();
}
}

private void tgl1KeyPressed(java.awt.event.KeyEvent evt) {
// if (evt.getKeyChar() == KeyEvent.VK_ENTER) {
// fmodal.requestFocusInWindow(); } // TODO add your handling code here:
}

private void fmodalKeyPressed(java.awt.event.KeyEvent evt) {
// if (evt.getKeyChar() == KeyEvent.VK_ENTER) {if(fjangka.getText().equals(“0”)){
// JOptionPane.showMessageDialog(this, “Jangka Waktu Belum di isi”); fjangka.requestFocusInWindow();}
// else{
// if(((String)cjnsjangka.getSelectedItem()).substring(0,1).equals(“4”)){
// Double c1 =Double.parseDouble(fjangka.getText())*5;
// Double c2 =Double.parseDouble(fmodal.getText());
// c= c2/c1;}else{
// Double c1 =Double.parseDouble(fjangka.getText());
// Double c2 =Double.parseDouble(fmodal.getText());
// c= c2/c1;}
// fangspok.setValue(c); fbmf.requestFocusInWindow();}
// }
}

// Variables declaration – do not modify
private formattedfields.FormattedDoubleField fmodal;
private javax.swing.JButton jButton1;
private javax.swing.JLabel jLabel1;
private javax.swing.JFormattedTextField tgl1;
private javax.swing.JFormattedTextField tgl2;
private javax.swing.JFormattedTextField tgl3;
// End of variables declaration
}

Tinggalkan Balasan

Isikan data di bawah atau klik salah satu ikon untuk log in:

Logo WordPress.com

You are commenting using your WordPress.com account. Logout / Ubah )

Gambar Twitter

You are commenting using your Twitter account. Logout / Ubah )

Foto Facebook

You are commenting using your Facebook account. Logout / Ubah )

Foto Google+

You are commenting using your Google+ account. Logout / Ubah )

Connecting to %s

%d blogger menyukai ini: