本文整理匯總了Java中javax.swing.JDialog.addWindowListener方法的典型用法代碼示例。如果您正苦於以下問題:Java JDialog.addWindowListener方法的具體用法?Java JDialog.addWindowListener怎麽用?Java JDialog.addWindowListener使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類javax.swing.JDialog
的用法示例。
在下文中一共展示了JDialog.addWindowListener方法的12個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: showDialog
import javax.swing.JDialog; //導入方法依賴的package包/類
/**
* Show font selection dialog.
* @param parent Dialog's Parent component.
* @return OK_OPTION, CANCEL_OPTION or ERROR_OPTION
*
* @see #OK_OPTION
* @see #CANCEL_OPTION
* @see #ERROR_OPTION
**/
public int showDialog(Component parent) {
dialogResultValue = ERROR_OPTION;
JDialog dialog = createDialog(parent);
dialog.addWindowListener(new WindowAdapter() {
@Override
public void windowClosing(WindowEvent e) {
dialogResultValue = CANCEL_OPTION;
}
});
dialog.setVisible(true);
dialog.dispose();
dialog = null;
return dialogResultValue;
}
示例2: createDialog
import javax.swing.JDialog; //導入方法依賴的package包/類
/**
* Creates and returns a fresh dialog for the given frame.
*/
private JDialog createDialog(Component frame) {
Object[] buttons = new Object[] {getOkButton(), getCancelButton()};
JPanel input = new JPanel();
input.setLayout(new BorderLayout());
input.add(getChoiceBox(), BorderLayout.NORTH);
// add an error label if there is a parser
if (this.parsed) {
JPanel errorPanel = new JPanel(new BorderLayout());
errorPanel.add(getErrorLabel());
input.add(errorPanel, BorderLayout.SOUTH);
}
JPanel main = new JPanel();
main.setLayout(new BorderLayout());
main.add(input, BorderLayout.CENTER);
if (this.parsed) {
main.add(createSyntaxPanel(), BorderLayout.EAST);
}
JOptionPane panel = new JOptionPane(main, JOptionPane.PLAIN_MESSAGE,
JOptionPane.OK_CANCEL_OPTION, null, buttons);
JDialog result = panel.createDialog(frame, this.title);
result.setDefaultCloseOperation(WindowConstants.DO_NOTHING_ON_CLOSE);
result.addWindowListener(this.closeListener);
return result;
}
示例3: createDialog
import javax.swing.JDialog; //導入方法依賴的package包/類
/**
* Creates and returns a fresh dialog for the given frame.
*/
private JDialog createDialog(Component frame) {
Object[] buttons = new Object[] {getOkButton(), getCancelButton()};
// input panel with text area and choice box
JPanel input = new JPanel();
input.setLayout(new BorderLayout());
input.setPreferredSize(new Dimension(300, 150));
input.add(new JLabel("<html><b>Enter value:"), BorderLayout.NORTH);
input.add(new JScrollPane(getTextArea()), BorderLayout.CENTER);
input.add(getChoiceBox(), BorderLayout.SOUTH);
JPanel main = new JPanel();
main.setLayout(new BorderLayout());
main.add(input, BorderLayout.CENTER);
if (this.parsed) {
JPanel errorPanel = new JPanel(new BorderLayout());
errorPanel.add(getErrorLabel());
main.add(errorPanel, BorderLayout.SOUTH);
main.add(createSyntaxPanel(), BorderLayout.EAST);
}
JOptionPane panel = new JOptionPane(main, JOptionPane.PLAIN_MESSAGE,
JOptionPane.OK_CANCEL_OPTION, null, buttons);
JDialog result = panel.createDialog(frame, this.title);
result.setDefaultCloseOperation(WindowConstants.DO_NOTHING_ON_CLOSE);
result.addWindowListener(this.closeListener);
return result;
}
示例4: createCancelDialog
import javax.swing.JDialog; //導入方法依賴的package包/類
/**
* Creates a modal dialog that will interrupt this thread, when the
* cancel button is pressed.
*/
private JDialog createCancelDialog() {
JDialog result;
// create message dialog
JOptionPane message = new JOptionPane(
isAnimated() ? getAnimationPanel()
: new Object[] {getStateCountLabel(), getTransitionCountLabel()},
JOptionPane.PLAIN_MESSAGE);
message.setOptions(new Object[] {getCancelButton()});
result = message.createDialog(getFrame(), "Exploring state space");
result.pack();
result.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
result.addWindowListener(new WindowAdapter() {
@Override
public void windowClosing(WindowEvent e) {
ExploreThread.this.interrupt();
}
});
result.setAlwaysOnTop(true);
return result;
}
示例5: showDialog
import javax.swing.JDialog; //導入方法依賴的package包/類
/**
* Show font selection dialog.
*
* @param parent
* Dialog's Parent component.
* @return OK_OPTION, CANCEL_OPTION or ERROR_OPTION
*
* @see #OK_OPTION
* @see #CANCEL_OPTION
* @see #ERROR_OPTION
**/
public int showDialog(Component parent) {
dialogResultValue = ERROR_OPTION;
JDialog dialog = createDialog(parent);
dialog.addWindowListener(new WindowAdapter() {
public void windowClosing(WindowEvent e) {
dialogResultValue = CANCEL_OPTION;
}
});
dialog.setVisible(true);
dialog.dispose();
dialog = null;
return dialogResultValue;
}
示例6: showDialog
import javax.swing.JDialog; //導入方法依賴的package包/類
/**
* Show font selection dialog.
* @param parent Dialog's Parent component.
* @return OK_OPTION, CANCEL_OPTION or ERROR_OPTION
*
* @see #OK_OPTION
* @see #CANCEL_OPTION
* @see #ERROR_OPTION
**/
public int showDialog(Component parent)
{
dialogResultValue = ERROR_OPTION;
JDialog dialog = createDialog(parent);
dialog.addWindowListener(new WindowAdapter()
{
public void windowClosing(WindowEvent e)
{
dialogResultValue = CANCEL_OPTION;
}
});
dialog.setVisible(true);
dialog.dispose();
dialog = null;
return dialogResultValue;
}
示例7: getDevelopmentDialog
import javax.swing.JDialog; //導入方法依賴的package包/類
final private JDialog getDevelopmentDialog( ControlJFrame objPcontrolJFrame,
JTextArea objPdevelopmentJTextArea,
ExtendedJButton objPdevelopmentCloseExtendedJButton) {
// Development scrollpane :
final JScrollPane objLdevelopmentJScrollPane =
new JScrollPane(objPdevelopmentJTextArea,
ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED,
ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED);
objLdevelopmentJScrollPane.setOpaque(true);
// Development dialog :
final JDialog objLdevelopmentJDialog =
new JDialog(objPcontrolJFrame,
objPcontrolJFrame.getLanguageString(Language.intS_TITLE_DEVELOPMENT),
true);
objLdevelopmentJDialog.setLayout(new GridBagLayout());
final ExtendedGridBagConstraints objLextendedGridBagConstraints =
new ExtendedGridBagConstraints( 0,
GridBagConstraints.RELATIVE,
1,
1,
GridBagConstraints.CENTER,
0,
0,
0,
10,
0,
0,
GridBagConstraints.BOTH,
1.0F,
1.0F);
// Add content :
objLdevelopmentJDialog.add(objLdevelopmentJScrollPane, objLextendedGridBagConstraints);
objLextendedGridBagConstraints.setFilling(GridBagConstraints.NONE, 0.0F, 0.0F);
objLdevelopmentJDialog.add(objPdevelopmentCloseExtendedJButton, objLextendedGridBagConstraints);
objLdevelopmentJDialog.addWindowListener(new JDialogWindowListener(objPcontrolJFrame, objLdevelopmentJDialog, false));
return objLdevelopmentJDialog;
}
示例8: testHidenChildDispose
import javax.swing.JDialog; //導入方法依賴的package包/類
/**
* Test if a dialog that has never been shown fire
* the WINDOW_CLOSED event on parent dispose().
* @throws Exception
*/
public static void testHidenChildDispose() throws Exception {
JFrame f = new JFrame();
JDialog dlg = new JDialog(f);
Listener l = new Listener();
dlg.addWindowListener(l);
f.dispose();
waitEvents();
assertEquals(0, l.getCount());
}
示例9: testVisibleChildParentDispose
import javax.swing.JDialog; //導入方法依賴的package包/類
/**
* Test if a dialog fire the WINDOW_CLOSED event
* on parent dispose().
* @throws Exception
*/
public static void testVisibleChildParentDispose() throws Exception {
JFrame f = new JFrame();
JDialog dlg = new JDialog(f);
Listener l = new Listener();
dlg.addWindowListener(l);
dlg.setVisible(true);
f.dispose();
waitEvents();
assertEquals(1, l.getCount());
}
示例10: initializeChooseColumnDialog
import javax.swing.JDialog; //導入方法依賴的package包/類
private void initializeChooseColumnDialog( String input ) {
String tempURLString = null;
if ( hole.getLeg() < 100 ) {
tempURLString = DSDP.DSDP_PATH + input + "/" + hole.toString() + "-" + input + ".txt";
}
else {
tempURLString = DSDP.DSDP_PATH + "ODP_" + input + "/" + hole.toString() + "-" + input + ".txt";
}
try {
DensityBRGTable tempTable = new DensityBRGTable(tempURLString);
selectSedimentDialog = new JDialog(dsdpF);
selectSedimentDialog.setTitle("Select Column");
selectSedimentDialog.addWindowListener(this);
selectAddColumnCB = new JComboBox();
selectAddColumnCB.addItem("Select Column");
for ( int i = 1; i < tempTable.headings.length; i++ ) {
selectAddColumnCB.addItem(tempTable.headings[i]);
}
selectAddColumnCB.addItemListener(this);
selectSedimentDialog.add(selectAddColumnCB);
selectSedimentDialog.pack();
selectSedimentDialog.setSize( 195, 100 );
selectSedimentDialog.setLocation( selectSedimentDialogX, selectSedimentDialogY );
selectSedimentDialog.setVisible(true);
} catch (IOException ioe) {
ioe.printStackTrace();
}
}
示例11: initSpyDialog
import javax.swing.JDialog; //導入方法依賴的package包/類
/**
* Initializes Spy dialog.
*/
protected void initSpyDialog(Component rootComponent, Component component) {
if (rootComponent instanceof Dialog) {
spyDialog = new CaddyDialog((Dialog) rootComponent) {
@Override
protected JRootPane createRootPane() {
return createSpyRootPane();
}
};
} else if (rootComponent instanceof Frame) {
spyDialog = new CaddyDialog((Frame) rootComponent) {
@Override
protected JRootPane createRootPane() {
return createSpyRootPane();
}
};
} else {
spyDialog = new JDialog() {
@Override
protected JRootPane createRootPane() {
return createSpyRootPane();
}
};
}
spyDialog.setName("SwingSpy");
spyDialog.setTitle("SwingSpy");
spyDialog.setModal(false);
spyDialog.setAlwaysOnTop(true);
Container contentPane = spyDialog.getContentPane();
contentPane.setLayout(new BorderLayout());
spyPanel = new SwingSpyPanel();
spyPanel.reload(rootComponent, component);
contentPane.add(spyPanel);
spyDialog.pack();
spyDialog.addWindowListener(new WindowAdapter() {
@Override
public void windowClosing(WindowEvent e) {
super.windowClosed(e);
spyGlass.setVisible(false);
spyDialog = null;
}
});
spyDialog.setLocationRelativeTo(null);
spyDialog.setVisible(true);
}
示例12: initDialog
import javax.swing.JDialog; //導入方法依賴的package包/類
public void initDialog() {
try {
testBox = Box.createHorizontalBox();
System.out.println(name);
testDialog = new JDialog(((haxby.map.MapApp)customDB.map.getApp()).getFrame(),name);
testDialog.addWindowListener(this);
JPanel selectSedimentPanel = new JPanel( new BorderLayout() );
selectSedimentPanel.setBorder( BorderFactory.createEmptyBorder( 10, 10, 10, 10 ) );
JPanel sedimentDialogBottomPanel = new JPanel( new GridLayout(0,1) );
JPanel sedimentDialogSouthPanel = new JPanel( new FlowLayout());
columnCB = new JComboBox();
JLabel sedimentLabel = new JLabel("");
saveDataB = new JButton("Save Data");
columnCB.addItemListener(this);
columnCB.setAlignmentX(Component.LEFT_ALIGNMENT);
saveDataB.addActionListener(this);
testDialog.setLayout( new BorderLayout() );
testDialog.getContentPane().add( selectSedimentPanel, "North" );
sedimentDialogSouthPanel.add(saveDataB);
sedimentDialogBottomPanel.add(sedimentDialogSouthPanel);
sedimentDialogBottomPanel.add( sedimentLabel);
testDialog.getContentPane().add( sedimentDialogBottomPanel, "South" );
CustomBRGTable testPts;
testPts = new CustomBRGTable(urlString);
String[] columnHeadings = null;
columnHeadings = testPts.getColumnHeadings();
for ( int i = 1; i < columnHeadings.length; i++ ) {
columnCB.addItem(columnHeadings[i]);
}
if ( columnCB.getItemCount() > 1 ) {
selectSedimentPanel.add(columnCB, BorderLayout.WEST );
}
testGraph = new CustomXYGraph( testPts, 0 );
selectAddColumnCB = new JComboBox();
selectAddColumnCB.addItem("Add Graph");
for ( int i = 1; i < ((CustomBRGTable)testGraph.getPoints()).getColumnHeadings().length; i++ ) {
selectAddColumnCB.addItem(((CustomBRGTable)testGraph.getPoints()).getColumnHeadings()[i]);
}
selectAddColumnCB.addActionListener(this);
sedimentDialogSouthPanel.add(selectAddColumnCB);
flipYAxisCB = new JCheckBox("Flip Y-Axis", CustomBRGTable.REVERSE_Y_AXIS );
ignoreZerosCB = new JCheckBox("Ignore 0's", CustomBRGTable.IGNORE_ZEROS );
flipYAxisCB.addActionListener(this);
ignoreZerosCB.addActionListener(this);
sedimentDialogSouthPanel.add(flipYAxisCB, "East");
sedimentDialogSouthPanel.add(ignoreZerosCB);
Zoomer z = new Zoomer(testGraph);
testGraph.setScrollableTracksViewportWidth(true);
testGraph.setScrollableTracksViewportHeight(true);
testGraph.setMinimumSize(new Dimension(300, min_Height));
testGraph.setPreferredSize(new Dimension( 300, preferred_Height));
testGraph.setMaximumSize(new Dimension( 300, max_Height));
testGraph.setAlignmentX(Component.TOP_ALIGNMENT);
testGraph.addMouseListener(z);
testGraph.addKeyListener(z);
testGraph.addMouseMotionListener(this);
testBox.add(testGraph);
testBox.setMinimumSize(new Dimension( 400, min_Height));
testBox.setPreferredSize(new Dimension( 10000, preferred_Height));
testBox.setMaximumSize(new Dimension( 10000, max_Height));
JScrollPane sedimentSP = new JScrollPane( testBox, JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED, JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED );
testDialog.getContentPane().add( sedimentSP, "Center" );
testDialog.pack();
testDialog.setLocation( 500, 500 );
testDialog.setSize( 600, 400 );
testDialog.setVisible(true);
} catch (IOException e) {
e.printStackTrace();
}
}