Salve a tutti, stò cercando una soluzione a questo problema, che voi sappiate esiste un tutorial che spieghi ogni componente del gestore eventi?
Ho scritto un programma di calcolo cosi:
codice:import java.util.Scanner; public class Per { public static void main(String[] args) { // TODO Auto-generated method stub Scanner tastiera = new Scanner(System.in); System.out.print("T? " ); double Tot = tastiera.nextInt(); System.out.println("T " + Tot); System.out.print("S? " ); double Sp = tastiera.nextInt(); System.out.println("S " + Sp); double V=Tot-Sp; double P=V/100; double Mx=7; double Sx=4; double Sy=9; double S=20; double Mod=9; System.out.println("_________________"); System.out.println("Ma " + P*Mx); System.out.println("So " + P*Sx); System.out.println("Sc " + P*Sy); System.out.println("St " + P*S); System.out.println("_________________"); System.out.println("Modifiche Standard " + (Tot/100)*Mod); } }
e ho creato con Window builder un interfaccia cosi:
codice:import java.awt.EventQueue; import javax.swing.JFrame; import javax.swing.JLabel; import javax.swing.JButton; import javax.swing.JTextField; public class PROVA { private JFrame frame; private JTextField textField; private JTextField textField_1; /** * Launch the application. */ public static void main(String[] args) { EventQueue.invokeLater(new Runnable() { public void run() { try { PROVA window = new PROVA(); window.frame.setVisible(true); } catch (Exception e) { e.printStackTrace(); } } }); } /** * Create the application. */ public PROVA() { initialize(); } /** * Initialize the contents of the frame. */ private void initialize() { frame = new JFrame(); frame.setBounds(100, 100, 450, 300); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.getContentPane().setLayout(null); JLabel lblNewLabel = new JLabel("STAMPA RISULTATI"); lblNewLabel.setBounds(12, 105, 408, 137); frame.getContentPane().add(lblNewLabel); JButton btnNewButton = new JButton("OK"); btnNewButton.setBounds(294, 53, 113, 25); frame.getContentPane().add(btnNewButton); textField = new JTextField(); textField.setBounds(27, 26, 116, 22); frame.getContentPane().add(textField); textField.setColumns(10); textField_1 = new JTextField(); textField_1.setBounds(27, 54, 116, 22); frame.getContentPane().add(textField_1); textField_1.setColumns(10); JLabel lblNewLabel_1 = new JLabel("T"); lblNewLabel_1.setBounds(155, 28, 113, 20); frame.getContentPane().add(lblNewLabel_1); JLabel lblS = new JLabel("S"); lblS.setBounds(155, 58, 113, 20); frame.getContentPane().add(lblS); } }
Ora vorrei che all'avvio del programma, funzionasse cosi:
Nel textField "T" inserisco un valore che scelgo int
Nel textField "S" lo stesso
e che premendo il Button "OK"
I risultati vengano Printati nel Label
Qualcuno può consigliarmi un tutorial che mostri proprio questo "cioè da programma di calcolo a interfaccia che stampa inserendo dei valori e dando "OK" o può scrivermelo? vi ringrazio molto in anticipo.
Window Builder.jpg

Rispondi quotando
.
