import java.awt.event.*; import java.awt.*; import javax.swing.*; class PopupRequestBD extends JDialog { JPanel mainPanel; JPanel buttonPanel; JPanel requestPanel; JButton buttonOK; JButton buttonCancel; JLabel requestLabel; JScrollPane requestScroll; JTextArea requestArea; private String query; public JFrame parentFrame; public String getQuery() { return query ; } public PopupRequestBD( JFrame frame, String popupName ) { super( (Frame)frame, popupName, true ); parentFrame = frame; query = new String( "" ); requestArea = new JTextArea( "", 20, 4 ); requestLabel = new JLabel( "Entrez votre requête :" ); requestScroll = new JScrollPane( requestArea ); requestPanel = new JPanel(); requestPanel.setLayout( new BorderLayout() ); requestPanel.setBorder(BorderFactory.createCompoundBorder( BorderFactory.createLineBorder( Color.black, 1 ), BorderFactory.createEmptyBorder( 2, 2, 2, 2 ))); requestPanel.add( requestLabel, BorderLayout.NORTH ); requestPanel.add( requestScroll, BorderLayout.CENTER ); buttonPanel = new JPanel(); buttonPanel.setLayout( new GridLayout( 1, 2 ) ); buttonOK = new JButton( "OK" ); buttonOK.addActionListener( new ActionListener() { public void actionPerformed( ActionEvent ev ) { query = requestArea.getText(); setVisible( false ); parentFrame.pack(); } } ); buttonCancel = new JButton( "Annuler" ); buttonCancel.addActionListener( new ActionListener() { public void actionPerformed( ActionEvent ev ) { query = ""; setVisible( false ); parentFrame.pack(); } } ); buttonPanel.add( buttonOK ); buttonPanel.add( buttonCancel ); mainPanel = new JPanel(); mainPanel.setLayout( new BorderLayout() ); mainPanel.add( requestPanel, BorderLayout.CENTER ); mainPanel.add( buttonPanel, BorderLayout.SOUTH ); getContentPane().add( mainPanel ); setSize( 350, 160 ); setVisible( false ); //setResizable( false ); } }