Vous êtes sur la page 1sur 8

FONT COLOUR

private (java.awt.event.ActionEvent evt) {


// Red void jRadioButton1ActionPerformed
txtName.setForeground(new Color(255, 0, 0));
}
private void jRadioButton2ActionPerformed(java.awt.event.ActionEvent evt) {
// Green
txtName.setForeground(new Color(0, 255, 0));
}
private void jRadioButton3ActionPerformed(java.awt.event.ActionEvent evt) {
// Blue
txtName.setForeground(new Color(0, 0, 255));
}
private void jRadioButton4ActionPerformed(java.awt.event.ActionEvent evt) {
// Yellow
txtName.setForeground(new Color(255, 255, 0));
}
private void jCheckBox1ActionPerformed(java.awt.event.ActionEvent evt) {
txtName.setFont(new Font("Helvetica", Font.BOLD, 12));
}
private void jCheckBox2ActionPerformed(java.awt.event.ActionEvent evt) {
txtName.setFont(new Font("Helvetica", Font.ITALIC, 12));
}
private void jCheckBox3ActionPerformed(java.awt.event.ActionEvent evt) {
txtName.setFont(new Font("Helvetica", Font.BOLD + Font.ITALIC, 12));
}

private void jCheckBox4ActionPerformed(java.awt.event.ActionEvent evt) {


txtName.setFont(new Font("Helvetica", Font.PLAIN, 12));
}
private void btnExitActionPerformed(java.awt.event.ActionEvent evt) {
System.exit(0);
}
/**
* @param args the command line arguments
*/
public static void main(String args[]) {
java.awt.EventQueue.invokeLater(new Runnable() {
public void run() {
new FColorUI().setVisible(true);
}
});
}

HOTEL BILL
private void cmdClearActionPerformed(java.awt.event.ActionEvent evt) {
// Clearing textboxes,radio buttons and check boxes.
txtRate.setText("");
txtFacility.setText("");
txtAmount.setText("");
OptSingle.setSelected(false);
OptDouble.setSelected(false);
OptDelux.setSelected(false);
chkTour.setSelected(false);
chkGym.setSelected(false);
chkLaundry.setSelected(false);
}
private void formWindowGainedFocus(java.awt.event.WindowEvent evt) {
txtRate.enable(false);
txtAmount.enable(false);
txtFacility.enable(false);
}
private void cmdRateActionPerformed(java.awt.event.ActionEvent evt) {
// Assigning rate per day
if (OptSingle.isSelected())
txtRate.setText(Integer.toString(1500));
else
if (OptDouble.isSelected())
txtRate.setText(Integer.toString(2800));
else

if (OptDelux.isSelected())
txtRate.setText(Integer.toString(5000));
}
private void cmdAmountActionPerformed(java.awt.event.ActionEvent evt) {
// Finding the cost of facility
if (chkTour.isSelected())
txtFacility.setText(Integer.toString(7000));
else
if (chkGym.isSelected())
txtFacility.setText(Integer.toString(2000));
else
if (chkLaundry.isSelected())
txtFacility.setText(Integer.toString(1000));
Double TAmount = (Double.parseDouble(txtRate.getText()) *
Double.parseDouble(txtDays.getText())) + Double.parseDouble(txtFacility.getText());
// Total amount
txtAmount.setText(Double.toString(TAmount));
}
private void cmdExitActionPerformed(java.awt.event.ActionEvent evt) {
System.exit(0);
}
/**
* @param args the command line arguments
*/
public static void main(String args[]) {
java.awt.EventQueue.invokeLater(new Runnable() {
public void run() {
new HotelBillUI().setVisible(true); } });}

SWAP NUMBER
private void btnChangeActionPerformed(java.awt.event.ActionEvent evt) {
int X, Y, temp;
X = Integer.parseInt(txtNum1.getText());
Y = Integer.parseInt(txtNum2.getText());
jTextArea1.append("Value before swapping is : " + X + " " + Y + "\n");
// Using third variable
temp = X;
X = Y;
Y = temp;
jTextArea1.append("Value after swapping is : " + X + " " + Y);
}
private void btnExitActionPerformed(java.awt.event.ActionEvent evt) {
System.exit(0);
}

UL CASE
private void btnConActionPerformed(java.awt.event.ActionEvent evt) {
String str = txtUL.getText();
txtLower.setText(str.toLowerCase());
txtUpper.setText(str.toUpperCase());
}
private void btnExitActionPerformed(java.awt.event.ActionEvent evt) {
System.exit(0);
}
/**
* @param args the command line arguments
*/
public static void main(String args[]) {
java.awt.EventQueue.invokeLater(new Runnable() {
public void run() {
new ULCaseUI().setVisible(true);
}
});
}

GRADE
private void btnCalcActionPerformed(java.awt.event.ActionEvent evt) {
int m1, m2, m3, total;
String grade;
m1 = Integer.parseInt(txtM1.getText());
m2 = Integer.parseInt(txtM2.getText());
m3 = Integer.parseInt(txtM3.getText());
total = m1 + m2 + m3;
grade = (total >=200) ? "A" : "B";
txtTot.setText(Integer.toString(total));
txtGrade.setText(grade);
}
private void btnExitActionPerformed(java.awt.event.ActionEvent evt) {
System.exit(0);
}
TEMPERATURE
private void btnEXitActionPerformed(java.awt.event.ActionEvent evt) {
System.exit(0);
}
private void btnFTOCActionPerformed(java.awt.event.ActionEvent evt) {
// Declare the format constructor
DecimalFormat twoDigits = new DecimalFormat("0.00");
int F;
double C = 0;
F = Integer.parseInt(txtF.getText());
C = 5.0/9.0 * (F-32);
txtC.setText(twoDigits.format(C));

Vous aimerez peut-être aussi