cercando su internet ho provato questo ma non va cmq sapreste dirmi perche:
codice:import java.awt.*; import java.awt.event.*; import javax.swing.*; public class Calcolatrice { static JFrame window; public static void main(String[] args){ // schedule this for the event dispatch thread (edt) SwingUtilities.invokeLater(new Runnable(){ public void run(){ displayJFrame(); } }); } static void displayJFrame(){ window = new JFrame("Test"); window.getContentPane().setLayout(new FlowLayout()); window.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE); window.setResizable(false); window.pack(); window.setVisible(true); JTextArea TextArea = new JTextArea(); TextArea.setPreferredSize(new Dimension(100,20)); window.add(TextArea); JButton showDialogButton = new JButton("INVIO"); window.add(showDialogButton); showDialogButton.addActionListener(new ActionListener(){ public void actionPerformed(ActionEvent evt) { String text1 = TextArea.getText(); System.out.println(text1); } }); JButton p = new JButton("HELP"); window.add(p); p.addActionListener(new ActionListener(){ public void actionPerformed(ActionEvent e){ // display/center the jdialog when the button is pressed JDialog d = new JDialog(window, "Hello", true); d.setLocationRelativeTo(window); d.setVisible(true); } }); } }

Rispondi quotando