here's my code:
import javax.swing.*; import java.awt.*; import java.awt.event.*; import java.util.*; public class Milimetri extends JFrame { private JPanel p1 = new JPanel(new FlowLayout(FlowLayout.LEFT)); private JPanel p2 = new JPanel(new FlowLayout(FlowLayout.LEFT)); private JPanel p3 = new JPanel(new FlowLayout(FlowLayout.LEFT)); private JLabel e1 = new JLabel("Meters"); private JLabel e2 = new JLabel("Milimeters:"); private JTextField t1 = new JTextField(20); private JTextField t2 = new JTextField(20); private JButton b1 = new JButton("Result"); public Milimetri(){ super("Metri in Centimetri"); setLayout(new GridLayout(3,1)); add(p1); add(p2); add(p3); p1.add(e1);p1.add(t1); p2.add(e2);p2.add(t2); p3.add(b1); pack(); setResizable(false); setLocationRelativeTo(null); setVisible(true); b1.addActionListener( new ActionListener(){ public void actionPerformed(ActionEvent ev){ double meters = Double.parseDouble(t1.getText()); String milimeters = t2.setText(); } } ); }
When i write a value in meters ..and press the button b1 to show me a value in milimeters...but i don't know what to do!
Pls help!
have a nice day!
PS: i hope i posted correctly