Create New Item
Item Type
File
Folder
Item Name
Search file in folder and subfolders...
Are you sure want to rename?
File Manager
/
Ebook
/
Informatique
/
JAVA
/
NetBeansProjects
/
JavaApplication2
/
src
:
essai.java
Advanced Search
Upload
New Item
Settings
Back
Back Up
Advanced Editor
Save
/* * To change this license header, choose License Headers in Project Properties. * To change this template file, choose Tools | Templates * and open the template in the editor. */ /** * * @author Patrice */ import java.awt.*; import java.awt.event.*; import javax.swing.*; public class essai { static JFrame frame; 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() { frame = new JFrame("Our JButton listener example"); // create our jbutton JButton showDialogButton = new JButton("Click Me"); // add the listener to the jbutton to handle the "pressed" event showDialogButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { // display/center the jdialog when the button is pressed JDialog d = new JDialog(frame, "Hello", true); d.setLocationRelativeTo(frame); d.setVisible(true); } }); // put the button on the frame frame.getContentPane().setLayout(new FlowLayout()); frame.add(showDialogButton); // set up the jframe, then display it frame.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE); frame.setPreferredSize(new Dimension(300, 200)); frame.pack(); frame.setLocationRelativeTo(null); frame.setVisible(true); } }