本文整理汇总了Java中javax.swing.JDialog.setLocationRelativeTo方法的典型用法代码示例。如果您正苦于以下问题:Java JDialog.setLocationRelativeTo方法的具体用法?Java JDialog.setLocationRelativeTo怎么用?Java JDialog.setLocationRelativeTo使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类javax.swing.JDialog
的用法示例。
在下文中一共展示了JDialog.setLocationRelativeTo方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getDialog
import javax.swing.JDialog; //导入方法依赖的package包/类
/**
* Gets the authorization dialog.
*
* @param presetUsername username which should be shown preset when displaying the dialog
* @param owner the window to which the dialog should belong (to center etc.)
* @return the dialog
*/
public JDialog getDialog(String presetUsername, Window owner) {
authDialog = new JDialog(owner);
OIDCPanel oidcPanel = new OIDCPanel(this);
if (presetUsername != null) {
oidcPanel.getJTextFieldUsername().setText(presetUsername);
}
authDialog.setContentPane(oidcPanel);
authDialog.setSize(new Dimension(500, 190));
authDialog.setLocationRelativeTo(null);
return authDialog;
}
示例2: actionPerformed
import javax.swing.JDialog; //导入方法依赖的package包/类
public void actionPerformed(ActionEvent e) {
// FIXME: don't create a new one each time!
final File logfile = new File(Info.getHomeDir(), "errorLog");
final LogPane lp = new LogPane(logfile);
// FIXME: this should have its own key. Probably keys should be renamed
// to reflect what they are labeling, e.g., Help.show_error_log_menu_item,
// Help.error_log_dialog_title.
final JDialog d =
new JDialog(frame, Resources.getString("Help.error_log"));
d.setLayout(new MigLayout("insets 0"));
d.add(new JScrollPane(lp), "grow, push, w 500, h 600");
d.setLocationRelativeTo(frame);
d.setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE);
d.pack();
d.setVisible(true);
}
示例3: showProgress
import javax.swing.JDialog; //导入方法依赖的package包/类
public static ProgressDialog showProgress(Component parent, String message)
{
JDialog d = ComponentHelper.createJDialog(parent);
ProgressDialog p = new ProgressDialog(d);
d.getRootPane().setWindowDecorationStyle(JRootPane.INFORMATION_DIALOG);
d.setResizable(false);
d.setContentPane(p);
d.setTitle(message);
d.pack();
d.setLocationRelativeTo(parent);
d.setVisible(true);
return p;
}
示例4: setupUI
import javax.swing.JDialog; //导入方法依赖的package包/类
private void setupUI() {
dialog = new JDialog();
dialog.setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE);
dialog.setSize(200, 100);
dialog.setLocationRelativeTo(null);
dialog.setVisible(true);
JPopupMenu popup = new JPopupMenu();
popup.add(new JMenuItem("one"));
JMenuItem two = new JMenuItem("two");
two.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
passed = true;
}
});
popup.add(two);
popup.add(new JMenuItem("three"));
popup.show(dialog, 50, 50);
}
示例5: showSelectLanguageDialog
import javax.swing.JDialog; //导入方法依赖的package包/类
/**
* Method showSelectLanguageDialog
*/
private void showSelectLanguageDialog() {
// Don't show this dialog if DEFAULT_LOCALE is configured in the
// properties file.
if (checkConfigForDefaultLocale()) {
return;
}
JDialog selectLanguageDialog = new SelectLanguageDialog(frame, "Select Language");
selectLanguageDialog.setSize(240, 180);
selectLanguageDialog.setLocationRelativeTo(null);
selectLanguageDialog.setVisible(true);
}
示例6: createROCPlotDialog
import javax.swing.JDialog; //导入方法依赖的package包/类
/** Creates a dialog containing a plotter for a given list of ROC data points. */
public void createROCPlotDialog(ROCData data) {
ROCChartPlotter plotter = new ROCChartPlotter();
plotter.addROCData("ROC", data);
JDialog dialog = new JDialog();
dialog.setTitle("ROC Plot");
dialog.add(plotter);
dialog.setSize(500, 500);
dialog.setLocationRelativeTo(null);
dialog.setVisible(true);
}
示例7: createDialog
import javax.swing.JDialog; //导入方法依赖的package包/类
private JDialog createDialog(Component parent) {
Frame frame = parent instanceof Frame ? (Frame) parent
: (Frame) SwingUtilities.getAncestorOfClass(Frame.class, parent);
JDialog dialog = new JDialog(frame, getMessage("SelectFont"), true);
Action okAction = new DialogOKAction(dialog);
Action cancelAction = new DialogCancelAction(dialog);
JButton okButton = new JButton(okAction);
okButton.setFont(DEFAULT_FONT);
JButton cancelButton = new JButton(cancelAction);
cancelButton.setFont(DEFAULT_FONT);
JPanel buttonsPanel = new JPanel();
buttonsPanel.setLayout(new GridLayout(2, 1));
buttonsPanel.add(okButton);
buttonsPanel.add(cancelButton);
buttonsPanel.setBorder(BorderFactory.createEmptyBorder(25, 0, 10, 10));
ActionMap actionMap = buttonsPanel.getActionMap();
actionMap.put(cancelAction.getValue(Action.DEFAULT), cancelAction);
actionMap.put(okAction.getValue(Action.DEFAULT), okAction);
InputMap inputMap = buttonsPanel.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW);
inputMap.put(KeyStroke.getKeyStroke("ESCAPE"), cancelAction.getValue(Action.DEFAULT));
inputMap.put(KeyStroke.getKeyStroke("ENTER"), okAction.getValue(Action.DEFAULT));
JPanel dialogEastPanel = new JPanel();
dialogEastPanel.setLayout(new BorderLayout());
dialogEastPanel.add(buttonsPanel, BorderLayout.NORTH);
dialog.getContentPane().add(this, BorderLayout.CENTER);
dialog.getContentPane().add(dialogEastPanel, BorderLayout.EAST);
dialog.pack();
dialog.setLocationRelativeTo(frame);
return dialog;
}
示例8: main
import javax.swing.JDialog; //导入方法依赖的package包/类
public static void main(String[] args) {
final String loremIpsum = "Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.";
final JDialog d = new JDialog();
d.setTitle("Flow Label Test");
d.setModal(true);
d.setResizable(true);
d.setLocationRelativeTo(null);
d.setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE);
d.add(new FlowLabel(loremIpsum + "\n\n" + loremIpsum));
d.pack();
d.setVisible(true);
}
示例9: createDialog
import javax.swing.JDialog; //导入方法依赖的package包/类
public static JDialog createDialog(Frame owner, String title, String gradientTitle) {
JDialog dialog = new JDialog(owner, title, true);
dialog.setLayout(new BorderLayout());
dialog.add(Guitilities.createGradientTitle(title), BorderLayout.NORTH);
dialog.setLocationRelativeTo(owner);
dialog.setLocationByPlatform(true);
dialog.setResizable(false);
return dialog;
}
示例10: createDialog
import javax.swing.JDialog; //导入方法依赖的package包/类
protected JDialog createDialog(Component parent) {
Frame frame = parent instanceof Frame ? (Frame) parent
: (Frame) SwingUtilities.getAncestorOfClass(Frame.class, parent);
JDialog dialog = new JDialog(frame, ("Select Font"), true);
Action okAction = new DialogOKAction(dialog);
Action cancelAction = new DialogCancelAction(dialog);
JButton okButton = new JButton(okAction);
okButton.setFont(DEFAULT_FONT);
JButton cancelButton = new JButton(cancelAction);
cancelButton.setFont(DEFAULT_FONT);
JPanel buttonsPanel = new JPanel();
buttonsPanel.setLayout(new GridLayout(2, 1));
buttonsPanel.add(okButton);
buttonsPanel.add(cancelButton);
buttonsPanel.setBorder(BorderFactory.createEmptyBorder(25, 0, 10, 10));
ActionMap actionMap = buttonsPanel.getActionMap();
actionMap.put(cancelAction.getValue(Action.DEFAULT), cancelAction);
actionMap.put(okAction.getValue(Action.DEFAULT), okAction);
InputMap inputMap = buttonsPanel.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW);
inputMap.put(KeyStroke.getKeyStroke("ESCAPE"), cancelAction.getValue(Action.DEFAULT));
inputMap.put(KeyStroke.getKeyStroke("ENTER"), okAction.getValue(Action.DEFAULT));
JPanel dialogEastPanel = new JPanel();
dialogEastPanel.setLayout(new BorderLayout());
dialogEastPanel.add(buttonsPanel, BorderLayout.NORTH);
dialog.getContentPane().add(this, BorderLayout.CENTER);
dialog.getContentPane().add(dialogEastPanel, BorderLayout.EAST);
dialog.pack();
dialog.setLocationRelativeTo(frame);
return dialog;
}
示例11: createDialog
import javax.swing.JDialog; //导入方法依赖的package包/类
protected JDialog createDialog(Component parent)
{
Frame frame = parent instanceof Frame ? (Frame) parent
: (Frame) SwingUtilities.getAncestorOfClass(Frame.class, parent);
JDialog dialog = new JDialog(frame, Editor.fromConfiguracao.getValor("Inspector.obj.font.selfonte"), true);
Action okAction = new DialogOKAction(dialog);
Action cancelAction = new DialogCancelAction(dialog);
JButton okButton = new JButton(okAction);
okButton.setFont(DEFAULT_FONT);
JButton cancelButton = new JButton(cancelAction);
cancelButton.setFont(DEFAULT_FONT);
JPanel buttonsPanel = new JPanel();
buttonsPanel.setLayout(new GridLayout(2, 1));
buttonsPanel.add(okButton);
buttonsPanel.add(cancelButton);
buttonsPanel.setBorder(BorderFactory.createEmptyBorder(25, 0, 10, 10));
ActionMap actionMap = buttonsPanel.getActionMap();
actionMap.put(cancelAction.getValue(Action.DEFAULT), cancelAction);
actionMap.put(okAction.getValue(Action.DEFAULT), okAction);
InputMap inputMap = buttonsPanel.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW);
inputMap.put(KeyStroke.getKeyStroke("ESCAPE"), cancelAction.getValue(Action.DEFAULT));
inputMap.put(KeyStroke.getKeyStroke("ENTER"), okAction.getValue(Action.DEFAULT));
JPanel dialogEastPanel = new JPanel();
dialogEastPanel.setLayout(new BorderLayout());
dialogEastPanel.add(buttonsPanel, BorderLayout.NORTH);
dialog.getContentPane().add(this, BorderLayout.CENTER);
dialog.getContentPane().add(dialogEastPanel, BorderLayout.EAST);
dialog.pack();
dialog.setLocationRelativeTo(frame);
return dialog;
}
示例12: mapaLabelMouseClicked
import javax.swing.JDialog; //导入方法依赖的package包/类
private void mapaLabelMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_mapaLabelMouseClicked
JDialog dialog = new JDialog();
dialog.setUndecorated(true);
JLabel label = new JLabel(imagemIcone);
dialog.setLocationRelativeTo(this);
dialog.setUndecorated(false);
dialog.add(label);
dialog.pack();
dialog.setVisible(true);
}
示例13: saveSEGY
import javax.swing.JDialog; //导入方法依赖的package包/类
private void saveSEGY(OutputStream out) throws IOException {
if(image==null) throw new IOException("no image loaded");
String mcsPath = PathUtil.getPath("PORTALS/MULTI_CHANNEL_PATH",
MapApp.BASE_URL+"/data/portals/mcs/");
URL url = URLFactory.url( mcsPath + line.getCruiseID().trim() + "/segy/" +
line.getCruiseID().trim() +"-"+
line.getID().trim() + ".segy" );
URLConnection urlCon = url.openConnection();
BufferedInputStream in = new BufferedInputStream(urlCon.getInputStream());
int length = urlCon.getContentLength();
// Create a JProgressBar + JDialog
JDialog d = new JDialog((Frame)null, "Saving SEGY");
JPanel p = new JPanel(new BorderLayout());
p.setBorder(BorderFactory.createEmptyBorder(1, 1, 1, 1));
d.setLocationRelativeTo(null);
JProgressBar pb = new JProgressBar(0,length);
p.add(new JLabel("Saving " + (length / 1000000) + "mb segy file"), BorderLayout.NORTH);
p.add(pb);
d.getContentPane().add(p);
d.pack();
d.setDefaultCloseOperation(JDialog.DO_NOTHING_ON_CLOSE);
d.setVisible(true);
byte[] b = new byte[16384];
int read = in.read(b);
while (read != -1) {
out.write(b, 0, read);
pb.setValue(pb.getValue() + read);
pb.repaint();
read = in.read(b);
}
out.flush();
in.close();
d.dispose();
}
示例14: 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);
}
示例15: showOptionDialog
import javax.swing.JDialog; //导入方法依赖的package包/类
protected int showOptionDialog(JFrame mainFrame, String message,
String title, String[] options, int defaultValue) {
final IntHolder holder = new IntHolder();
final JDialog dialog = new JDialog(mainFrame, true);
dialog.setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE);
holder.value = defaultValue;
JPanel panel = new JPanel(new BorderLayout());
JPanel m = new JPanel(new FlowLayout());
m.add(new JLabel(message));
panel.add(m, BorderLayout.CENTER);
JPanel bottom = new JPanel(new GridLayout(1, 3, 5, 7));
int i = 0;
for (String s : options) {
final int r = i;
JButton button = new JButton(new AbstractAction(s) {
/**
*
*/
private static final long serialVersionUID = 7269041268620864162L;
@Override
public void actionPerformed(ActionEvent e) {
holder.value = r;
dialog.setVisible(false);
}
});
i++;
bottom.add(button);
}
JPanel p = new JPanel(new FlowLayout());
p.add(bottom);
panel.add(p, BorderLayout.SOUTH);
JPanel pane = new JPanel(new FlowLayout());
pane.add(panel);
dialog.setTitle(title);
dialog.setContentPane(pane);
dialog.pack();
dialog.setResizable(false);
dialog.setLocationRelativeTo(null);
dialog.setVisible(true);
return holder.value;
}