hello there u said if any body need help u can help them
so plz i need ur help with this
i did a program in java gui (temperature converter) and i just need the program to print the result in a text file
so plz plz plz help me
the out put should look like this
welcome:
from f to c ="the result"
from c to f =" the result"
and if u can plz before friday
heres my code
/****************************************************************/
/* tconverter */
/* */
/****************************************************************/
import java.io.*;
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
/**
* Summary description for tconverter
*
*/
public class tconverter extends JFrame
{
String strFilePath = "TestFile.txt";
// Variables declaration
private JLabel jLabel1;
private JLabel jLabel2;
private JTextField jTextField1;
private JTextField jTextField2;
private JButton jButton1;
private JButton jButton2;
private JButton jButton3;
private JButton jButton4;
private JPanel contentPane;
// End of variables declaration
public tconverter()
{
super();
initializeComponent();
//
// TODO: Add any constructor code after initializeComponent call
//
this.setVisible(true);
}
/**
* 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 Windows Form Designer. Otherwise, retrieving design might not work properly.
* Tip: If you must revise this method, please backup this GUI file for JFrameBuilder
* to retrieve your design properly in future, before revising this method.
*/
private void initializeComponent()
{
jLabel1 = new JLabel();
jLabel2 = new JLabel();
jTextField1 = new JTextField();
jTextField2 = new JTextField();
jButton1 = new JButton();
jButton2 = new JButton();
jButton3 = new JButton();
jButton4 = new JButton();
contentPane = (JPanel)this.getContentPane();
//
// jLabel1
//
jLabel1.setText("convert what quantity?");
//
// jLabel2
//
jLabel2.setText("the result of convertation is");
//
// jTextField1
//
jTextField1.setText("");
jTextField1.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e)
{
jTextField1_actionPerformed(e);
}
});
//
// jTextField2
//
jTextField2.setText("");
jTextField2.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e)
{
jTextField2_actionPerformed(e);
}
});
//
// jButton1
//
jButton1.setText("C");
jButton1.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e)
{
jButton1_actionPerformed(e);
}
});
//
// jButton2
//
jButton2.setText("F");
jButton2.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e)
{
jButton2_actionPerformed(e);
}
});
//
// jButton3
//
jButton3.setText("Close");
jButton3.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e)
{
jButton3_actionPerformed(e);
}
});
//
// jButton4
//
jButton4.setText("About us...");
jButton4.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e)
{
jButton4_actionPerformed(e);
}
});
//
// contentPane
//
contentPane.setLayout(null);
addComponent(contentPane, jLabel1, 16,28,122,18);
addComponent(contentPane, jLabel2, 9,173,140,18);
addComponent(contentPane, jTextField1, 175,24,196,22);
addComponent(contentPane, jTextField2, 177,167,196,23);
addComponent(contentPane, jButton1, 20,90,83,28);
addComponent(contentPane, jButton2, 215,91,83,28);
addComponent(contentPane, jButton3, -1,247,83,28);
addComponent(contentPane, jButton4, 291,249,93,28);
//
// tconverter
//
this.setTitle("tconverter - extends JFrame");
this.setLocation(new Point(0, 0));
this.setSize(new Dimension(390, 300));
}
/** Add Component Without a Layout Manager (Absolute Positioning) */
private void addComponent(Container container,Component c,int x,int y,int width,int height)
{
c.setBounds(x,y,width,height);
container.add(c);
}
//
// TODO: Add any appropriate code in the following Event Handling Methods
//
private void jTextField1_actionPerformed(ActionEvent e)
{
System.out.println("\njTextField1_actionPerformed(ActionEvent e) called.");
// TODO: Add any handling code here
}
private void jTextField2_actionPerformed(ActionEvent e)
{
System.out.println("\njTextField2_actionPerformed(ActionEvent e) called.");
// TODO: Add any handling code here
}
private void jButton1_actionPerformed(ActionEvent e)
{
System.out.println("\njButton1_actionPerformed(ActionEvent e) called.");
// TODO: Add any handling code here
int tempCele = (int)(((Double.parseDouble(jTextField1.getText()))- 32) * 0.56);
jTextField2.setText(tempCele + " C");
}
private void jButton2_actionPerformed(ActionEvent e)
{
System.out.println("\njButton2_actionPerformed(ActionEvent e) called.");
// TODO: Add any handling code here
int tempFahr = (int)((Double.parseDouble(jTextField1.getText()))
* 1.8 + 32);
jTextField2.setText(tempFahr + " Fahrenheit");
}
private void jButton3_actionPerformed(ActionEvent e)
{
System.out.println("\njButton3_actionPerformed(ActionEvent e) called.");
// TODO: Add any handling code here
String t = "Thank You";
JOptionPane.showMessageDialog(null, " Thank You for using our Temperature converter");
System.exit(0);
}
private void jButton4_actionPerformed(ActionEvent e)
{
System.out.println("\njButton4_actionPerformed(ActionEvent e) called.");
// TODO: Add any handling code here
String t = "About me";
JOptionPane.showMessageDialog(null, "This is a Temperature converter tool");
}
//
// TODO: Add any method code to meet your needs in the following area
//
//============================= Testing ================================//
//= =//
//= The following main method is just for testing this class you built.=//
//= After testing,you may simply delete it. =//
//======================================================================//
public static void main(String[] args)
{
JFrame.setDefaultLookAndFeelDecorated(true);
JDialog.setDefaultLookAndFeelDecorated(true);
try
{
UIManager.setLookAndFeel("com.sun.java.swing.plaf.windows.WindowsLookAndFeel");
}
catch (Exception ex)
{
System.out.println("Failed loading L&F: ");
System.out.println(ex);
}
new tconverter();
}
//= End of Testing =
}