本文整理汇总了Java中java.awt.Dialog.setBounds方法的典型用法代码示例。如果您正苦于以下问题:Java Dialog.setBounds方法的具体用法?Java Dialog.setBounds怎么用?Java Dialog.setBounds使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类java.awt.Dialog
的用法示例。
在下文中一共展示了Dialog.setBounds方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: createAWTComponents
import java.awt.Dialog; //导入方法依赖的package包/类
private void createAWTComponents() {
Frame f1 = new Frame("F1");
f1.setBounds(100, 300, 100, 100);
f1.setVisible(true);
try {
Thread.sleep(500);
} catch (Exception ex) {
}
f1.setExtendedState(Frame.ICONIFIED);
Frame g1 = new Frame("G1");
g1.setBounds(150, 350, 100, 100);
g1.setVisible(true);
final Dialog d1 = new Dialog((Frame) null, "D1", Dialog.ModalityType.APPLICATION_MODAL);
d1.setBounds(200, 400, 100, 100);
new Thread(new Runnable() {
public void run() {
d1.setVisible(true);
}
}).start();
}
示例2: selectDependencies
import java.awt.Dialog; //导入方法依赖的package包/类
/**
*
* @param props
* @param initialFilterText initial filter text or null if not given
* @return
*/
public static ModuleDependency[] selectDependencies(final SingleModuleProperties props, final String initialFilterText) {
final AddModulePanel addPanel;
if (null != initialFilterText) {
// init dialog with filter text
addPanel = new AddModulePanel(props, initialFilterText);
}
else{
// keep backwards compatibility
addPanel = new AddModulePanel(props);
}
final DialogDescriptor descriptor = new DialogDescriptor(addPanel,
getMessage("CTL_AddModuleDependencyTitle"));
descriptor.setHelpCtx(new HelpCtx("org.netbeans.modules.apisupport.project.ui.customizer.AddModulePanel"));
descriptor.setClosingOptions(new Object[0]);
final Dialog d = DialogDisplayer.getDefault().createDialog(descriptor);
descriptor.setButtonListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
if (DialogDescriptor.OK_OPTION.equals(e.getSource()) && addPanel.getSelectedDependencies().length == 0) {
return;
}
d.setVisible(false);
d.dispose();
}
});
if (lastSize != null) {
d.setBounds(lastSize);
}
d.setVisible(true);
lastSize = d.getBounds();
d.dispose();
if (descriptor.getValue().equals(DialogDescriptor.OK_OPTION)) {
return addPanel.getSelectedDependencies();
} else {
return new ModuleDependency[0]; // #114932
}
}
示例3: main
import java.awt.Dialog; //导入方法依赖的package包/类
public static void main(String[] args)
{
Frame frame1 = new Frame("frame 1");
frame1.setBounds(0, 0, 100, 100);
frame1.setVisible(true);
Util.waitForIdle(null);
Frame frame2 = new Frame("frame 2");
frame2.setBounds(150, 0, 100, 100);
frame2.setVisible(true);
Util.waitForIdle(null);
Frame frame3 = new Frame("frame 3");
final Dialog dialog = new Dialog(frame3, "dialog", true);
dialog.setBounds(300, 0, 100, 100);
EventQueue.invokeLater(new Runnable() {
public void run() {
dialog.setVisible(true);
}
});
try {
EventQueue.invokeAndWait(new Runnable() { public void run() {} });
Util.waitForIdle(null);
EventQueue.invokeAndWait(new Runnable() {
public void run() {
dialog.dispose();
}
});
}
catch (InterruptedException ie) {
throw new RuntimeException(ie);
}
catch (InvocationTargetException ite) {
throw new RuntimeException(ite);
}
frame1.dispose();
frame2.dispose();
frame3.dispose();
}
示例4: main
import java.awt.Dialog; //导入方法依赖的package包/类
public static void main(String[] args) {
Robot robot = Util.createRobot();
Frame frame = new Frame("Frame");
frame.setBackground(Color.BLUE);
frame.setBounds(200, 50, 300, 300);
frame.setVisible(true);
Dialog dialog1 = new Dialog(frame, "Dialog 1", false);
dialog1.setBackground(Color.RED);
dialog1.setBounds(100, 100, 200, 200);
dialog1.setVisible(true);
Dialog dialog2 = new Dialog(frame, "Dialog 2", false);
dialog2.setBackground(Color.GREEN);
dialog2.setBounds(400, 100, 200, 200);
dialog2.setVisible(true);
Util.waitForIdle(robot);
Util.clickOnComp(dialog2, robot);
Util.waitForIdle(robot);
Point point = dialog1.getLocationOnScreen();
int x = point.x + (int)(dialog1.getWidth() * 0.9);
int y = point.y + (int)(dialog1.getHeight() * 0.9);
try {
if (!Util.testPixelColor(x, y, dialog1.getBackground(), 10, 100, robot)) {
throw new RuntimeException("Test FAILED: Dialog is behind the frame");
}
} finally {
frame.dispose();
dialog1.dispose();
dialog2.dispose();
}
}
示例5: testLeakingNbPresenterDescriptor
import java.awt.Dialog; //导入方法依赖的package包/类
@RandomlyFails // NB-Core-Build #1189
public void testLeakingNbPresenterDescriptor () throws InterruptedException, InvocationTargetException {
try {
Class.forName("java.lang.AutoCloseable");
} catch (ClassNotFoundException ex) {
// this test is known to fail due to JDK bugs 7070542 & 7072167
// which are unlikely to be fixed on JDK6. Thus, if AutoCloseable
// is not present, skip the test
return;
}
WizardDescriptor wizardDescriptor = new WizardDescriptor(getPanels(), null);
wizardDescriptor.setModal (false);
Dialog dialog = DialogDisplayer.getDefault ().createDialog (wizardDescriptor);
WeakReference<WizardDescriptor> w = new WeakReference<WizardDescriptor> (wizardDescriptor);
SwingUtilities.invokeAndWait (new EDTJob(dialog, true));
assertShowing("button is visible", true, dialog);
SwingUtilities.invokeAndWait (new EDTJob(dialog, false));
assertShowing("button is no longer visible", false, dialog);
boolean cancelled = wizardDescriptor.getValue() !=
WizardDescriptor.FINISH_OPTION;
Dialog d = new JDialog();
// workaround for JDK bug 6575402
JPanel p = new JPanel();
d.setLayout(new BorderLayout());
d.add(p, BorderLayout.CENTER);
JButton btn = new JButton("Button");
p.add(btn, BorderLayout.NORTH);
SwingUtilities.invokeAndWait (new EDTJob(d, true));
assertShowing("button is visible", true, btn);
dialog.setBounds(Utilities.findCenterBounds(dialog.getSize()));
SwingUtilities.invokeAndWait (new EDTJob(d, false));
assertShowing("button is no longer visible", false, btn);
assertNull ("BufferStrategy was disposed.", dialog.getBufferStrategy ());
RepaintManager rm = RepaintManager.currentManager(dialog);
rm.setDoubleBufferingEnabled(!rm.isDoubleBufferingEnabled());
rm.setDoubleBufferingEnabled(!rm.isDoubleBufferingEnabled());
dialog = null;
wizardDescriptor = null;
SwingUtilities.invokeAndWait (new Runnable() {
@Override
public void run() {
Frame f = new Frame();
f.setPreferredSize( new Dimension(100,100));
f.setVisible( true );
JDialog dlg = new JDialog(f);
dlg.setVisible(true);
}
});
assertGC ("Dialog disappears.", w);
}
示例6: createDialog
import java.awt.Dialog; //导入方法依赖的package包/类
static Dialog createDialog(
final String title,
final GoToPanelImpl panel,
final GoToPanelImpl.ContentProvider contentProvider,
final JButton okButton) {
okButton.setEnabled (false);
panel.getAccessibleContext().setAccessibleName( NbBundle.getMessage( GoToSymbolAction.class, "AN_GoToSymbol") ); //NOI18N
panel.getAccessibleContext().setAccessibleDescription( NbBundle.getMessage( GoToSymbolAction.class, "AD_GoToSymbol") ); //NOI18N
DialogDescriptor dialogDescriptor = new DialogDescriptor(
panel, // innerPane
title, // displayName
true,
new Object[] {okButton, DialogDescriptor.CANCEL_OPTION},
okButton,
DialogDescriptor.DEFAULT_ALIGN,
HelpCtx.DEFAULT_HELP,
new DialogButtonListener(panel, okButton));
dialogDescriptor.setClosingOptions(new Object[] {okButton, DialogDescriptor.CANCEL_OPTION});
Dialog d = DialogDisplayer.getDefault().createDialog( dialogDescriptor );
// Set size when needed
final int width = UiOptions.GoToSymbolDialog.getWidth();
final int height = UiOptions.GoToSymbolDialog.getHeight();
if (width != -1 && height != -1) {
d.setPreferredSize(new Dimension(width,height));
}
// Center the dialog after the size changed.
Rectangle r = Utilities.getUsableScreenBounds();
int maxW = (r.width * 9) / 10;
int maxH = (r.height * 9) / 10;
final Dimension dim = d.getPreferredSize();
dim.width = Math.min(dim.width, maxW);
dim.height = Math.min(dim.height, maxH);
d.setBounds(Utilities.findCenterBounds(dim));
initialDimension = dim;
d.addWindowListener(new WindowAdapter() {
@Override
public void windowClosed(WindowEvent e) {
contentProvider.closeDialog();
}
});
return d;
}
示例7: createDialog
import java.awt.Dialog; //导入方法依赖的package包/类
private Dialog createDialog( final FileSearchPanel panel) {
openBtn = new JButton();
Mnemonics.setLocalizedText(openBtn, NbBundle.getMessage(FileSearchAction.class, "CTL_Open"));
openBtn.getAccessibleContext().setAccessibleDescription(openBtn.getText());
openBtn.setEnabled( false );
final Object[] buttons = new Object[] { openBtn, DialogDescriptor.CANCEL_OPTION };
String title = NbBundle.getMessage(FileSearchAction.class, "MSG_FileSearchDlgTitle");
DialogDescriptor dialogDescriptor = new DialogDescriptor(
panel,
title,
true,
buttons,
openBtn,
DialogDescriptor.DEFAULT_ALIGN,
HelpCtx.DEFAULT_HELP,
new DialogButtonListener(panel));
dialogDescriptor.setClosingOptions(buttons);
Dialog d = DialogDisplayer.getDefault().createDialog(dialogDescriptor);
d.getAccessibleContext().setAccessibleName(NbBundle.getMessage(FileSearchAction.class, "AN_FileSearchDialog"));
d.getAccessibleContext().setAccessibleDescription(NbBundle.getMessage(FileSearchAction.class, "AD_FileSearchDialog"));
// Set size
d.setPreferredSize( new Dimension( FileSearchOptions.getWidth(),
FileSearchOptions.getHeight() ) );
// Center the dialog after the size changed.
Rectangle r = Utilities.getUsableScreenBounds();
int maxW = (r.width * 9) / 10;
int maxH = (r.height * 9) / 10;
Dimension dim = d.getPreferredSize();
dim.width = Math.min(dim.width, maxW);
dim.height = Math.min(dim.height, maxH);
initialDimension = dim;
d.setBounds(Utilities.findCenterBounds(dim));
d.addWindowListener(new WindowAdapter() {
public @Override void windowClosed(WindowEvent e) {
cleanup(false);
}
});
return d;
}
示例8: createDialog
import java.awt.Dialog; //导入方法依赖的package包/类
/** Creates the dialog to show
*/
private Dialog createDialog( final GoToPanel panel) {
okButton = new JButton (NbBundle.getMessage(GoToTypeAction.class, "CTL_OK"));
okButton.getAccessibleContext().setAccessibleDescription(okButton.getText());
okButton.setEnabled (false);
panel.getAccessibleContext().setAccessibleName( NbBundle.getMessage( GoToTypeAction.class, "AN_GoToType") ); //NOI18N
panel.getAccessibleContext().setAccessibleDescription( NbBundle.getMessage( GoToTypeAction.class, "AD_GoToType") ); //NOI18N
DialogDescriptor dialogDescriptor = new DialogDescriptor(
panel, // innerPane
title, // displayName
true,
new Object[] {okButton, DialogDescriptor.CANCEL_OPTION},
okButton,
DialogDescriptor.DEFAULT_ALIGN,
HelpCtx.DEFAULT_HELP,
new DialogButtonListener( panel ) ); // Action listener
dialogDescriptor.setClosingOptions(new Object[] {okButton, DialogDescriptor.CANCEL_OPTION});
// panel.addPropertyChangeListener( new HelpCtxChangeListener( dialogDescriptor, helpCtx ) );
// if ( panel instanceof HelpCtx.Provider ) {
// dialogDescriptor.setHelpCtx( ((HelpCtx.Provider)panel).getHelpCtx() );
// }
Dialog d = DialogDisplayer.getDefault().createDialog( dialogDescriptor );
// Set size when needed
final int width = UiOptions.GoToTypeDialog.getWidth();
final int height = UiOptions.GoToTypeDialog.getHeight();
if (width != -1 && height != -1) {
d.setPreferredSize(new Dimension(width,height));
}
// Center the dialog after the size changed.
Rectangle r = Utilities.getUsableScreenBounds();
int maxW = (r.width * 9) / 10;
int maxH = (r.height * 9) / 10;
final Dimension dim = d.getPreferredSize();
dim.width = Math.min(dim.width, maxW);
dim.height = Math.min(dim.height, maxH);
d.setBounds(Utilities.findCenterBounds(dim));
initialDimension = dim;
d.addWindowListener(new WindowAdapter() {
public @Override void windowClosed(WindowEvent e) {
cleanup();
}
});
return d;
}