nea_iyut

Kamis, 30 April 2009

ketiga...

runnya....

Rabu, 29 April 2009

hmm.....

Bila Perempuan semakin cantik

seharusnya kejujurannya juga semakin cantik

Karena hanya melalui kejujurannya ia dapat mengatasi

Semua kerusakan yang dapat ditimbulkan oleh kecantikannya

Jumat, 17 April 2009

Tugas ke-3

import java.io.FileNotFoundException;
import java.util.Scanner;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.swing.JOptionPane;

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

/*
* tugas4.java
*
* Created on 17 Apr 09, 17:39:24
*/

/**
*
* @author Any one
*/
public class tugas4 extends javax.swing.JFrame {
int a,b;
String car = ";";
/** Creates new form tugas4 */
public tugas4() {
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")
//
private void initComponents() {

jLabel1 = new javax.swing.JLabel();
jLabel2 = new javax.swing.JLabel();
Arus = new javax.swing.JTextField();
Hambatan = new javax.swing.JTextField();
jLabel3 = new javax.swing.JLabel();
Hasil = new javax.swing.JLabel();
jButton1 = new javax.swing.JButton();
jButton2 = new javax.swing.JButton();
jToolBar1 = new javax.swing.JToolBar();
jButton3 = new javax.swing.JButton();
jButton4 = new javax.swing.JButton();

setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);

jLabel1.setText("Masukan Besar Arus");

jLabel2.setText("Masukan Besar Hambatan");

Arus.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
ArusActionPerformed(evt);
}
});

jLabel3.setText("Hasil Penghitungan");

jButton1.setText("Proses");
jButton1.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButton1ActionPerformed(evt);
}
});

jButton2.setText("Clear");
jButton2.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButton2ActionPerformed(evt);
}
});

jToolBar1.setRollover(true);

jButton3.setText("Save");
jButton3.setFocusable(false);
jButton3.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
jButton3.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
jButton3.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButton3ActionPerformed(evt);
}
});
jToolBar1.add(jButton3);

jButton4.setText("Load");
jButton4.setFocusable(false);
jButton4.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
jButton4.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
jButton4.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButton4ActionPerformed(evt);
}
});
jToolBar1.add(jButton4);

javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
getContentPane().setLayout(layout);
layout.setHorizontalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
.addGroup(layout.createSequentialGroup()
.addContainerGap()
.addComponent(jButton1)
.addGap(42, 42, 42)
.addComponent(jButton2))
.addGroup(layout.createSequentialGroup()
.addGap(47, 47, 47)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jLabel1)
.addComponent(jLabel2)
.addComponent(jLabel3))
.addGap(45, 45, 45)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(Hasil, javax.swing.GroupLayout.DEFAULT_SIZE, 104, Short.MAX_VALUE)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
.addComponent(Arus)
.addComponent(Hambatan, javax.swing.GroupLayout.PREFERRED_SIZE, 67, javax.swing.GroupLayout.PREFERRED_SIZE)))))
.addContainerGap(80, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGroup(layout.createSequentialGroup()
.addComponent(jToolBar1, javax.swing.GroupLayout.PREFERRED_SIZE, 100, javax.swing.GroupLayout.PREFERRED_SIZE)
.addContainerGap(300, Short.MAX_VALUE))
);
layout.setVerticalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addComponent(jToolBar1, javax.swing.GroupLayout.PREFERRED_SIZE, 25, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(45, 45, 45)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jLabel1)
.addComponent(Arus, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGap(35, 35, 35)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jLabel2)
.addComponent(Hambatan, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGap(52, 52, 52)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jLabel3)
.addComponent(Hasil, javax.swing.GroupLayout.PREFERRED_SIZE, 14, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGap(31, 31, 31)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jButton2)
.addComponent(jButton1))
.addContainerGap(35, Short.MAX_VALUE))
);

pack();
}//


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

private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) {
Arus.setText("");
Hambatan.setText("");
Hasil.setText("");// TODO add your handling code here:
}

private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {
a = Integer.parseInt(Arus.getText());
b = Integer.parseInt(Hambatan.getText());
int hasil = a * b;
Hasil.setText(""+hasil); // TODO add your handling code here:
}

private void jButton3ActionPerformed(java.awt.event.ActionEvent evt) {
java.io.File file = new java.io.File("Save.txt");
java.io.PrintWriter output = null;
try {
output = new java.io.PrintWriter(file);
} catch (FileNotFoundException ex) {
Logger.getLogger(tugas4.class.getName()).log(Level.SEVERE, null, ex);
}
output.print(Arus.getText()+car);
output.print(Hambatan.getText());
output.close();

//option pane
JOptionPane.showMessageDialog(null, "Saved Successfully","Success",JOptionPane.WARNING_MESSAGE); // TODO add your handling code here:
}

private void jButton4ActionPerformed(java.awt.event.ActionEvent evt) {
//event hand
int respon2 = JOptionPane.showConfirmDialog(null, "Are You Sure ?", "Tanya Dulu...", JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE);

java.io.File file = new java.io.File("Save.txt");
Scanner input = null;
try {
input = new Scanner(file);
} catch (FileNotFoundException ex) {
Logger.getLogger(tugas4.class.getName()).log(Level.SEVERE, null, ex);
}
input.useDelimiter(";");
while (input.hasNext()){
String m = input.next();
String p = input.next();
Arus.setText(m);
Hambatan.setText(p);
}
input.close();

// TODO add your handling code here:
}

/**
* @param args the command line arguments
*/
public static void main(String args[]) {
java.awt.EventQueue.invokeLater(new Runnable() {
public void run() {
new tugas4().setVisible(true);
}
});
}

// Variables declaration - do not modify
private javax.swing.JTextField Arus;
private javax.swing.JTextField Hambatan;
private javax.swing.JLabel Hasil;
private javax.swing.JButton jButton1;
private javax.swing.JButton jButton2;
private javax.swing.JButton jButton3;
private javax.swing.JButton jButton4;
private javax.swing.JLabel jLabel1;
private javax.swing.JLabel jLabel2;
private javax.swing.JLabel jLabel3;
private javax.swing.JToolBar jToolBar1;
// End of variables declaration

}

Rabu, 01 April 2009

Tugas Kedua

import java.awt.*;
import java.awt.event.*;
import javax.swing.*;

public class MyMenu extends JFrame {

public static void main(String args[]){
MyMenu myFrame = new MyMenu();

//membuat menu bar
JMenuBar menuBar = new JMenuBar();
myFrame.setJMenuBar(menuBar);

//membuat menu File
JMenu menuFile = new JMenu ("Menu");
menuFile.setMnemonic('M');
menuBar.add(menuFile);

//membuat menu item: biasa, radio button dan check box
JMenuItem itemExit = new JMenuItem("Menu PilihanMu");
menuFile.add(itemExit);
JRadioButtonMenuItem radioButton = new JRadioButtonMenuItem("Radio Button");
menuFile.add(radioButton);
JCheckBoxMenuItem checkBox = new JCheckBoxMenuItem("check Box");
menuFile.add(checkBox);

//membuat komponen tambahan lainnya
Container container = myFrame.getContentPane();
myFrame.setTitle("Tampilan Menu");
myFrame.setSize(200,200);
myFrame.setVisible(true);
myFrame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
}
}