Java Code Examples for javax.swing.JDialog#setLocation()
The following examples show how to use
javax.swing.JDialog#setLocation() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: TransparencyTest.java From openjdk-jdk9 with GNU General Public License v2.0 | 6 votes |
public static void createAndShowGUI() { frame = new JFrame("JFrame"); frame.setSize(WIDTH, HEIGHT); frame.setLocation(100, 300); dialog = new JDialog(frame, false); dialog.setSize(250, 250); dialog.setUndecorated(true); dialog.setLocation(400, 300); dlgPos = dialog.getLocation(); backgroundDialog = new JDialog(frame, false); backgroundDialog.setSize(250, 250); backgroundDialog.getContentPane().setBackground(Color.red); backgroundDialog.setLocation(dlgPos.x, dlgPos.y); frame.setVisible(true); backgroundDialog.setVisible(true); dialog.setVisible(true); }
Example 2
Source File: Test4759934.java From jdk8u-jdk with GNU General Public License v2.0 | 6 votes |
public void actionPerformed(ActionEvent event) { String command = event.getActionCommand(); if (CMD_DIALOG.equals(command)) { JDialog dialog = new JDialog(this.frame, "Dialog"); // NON-NLS: dialog title dialog.setLocation(200, 0); show(dialog, CMD_CHOOSER); } else if (CMD_CHOOSER.equals(command)) { Object source = event.getSource(); Component component = (source instanceof Component) ? (Component) source : null; JColorChooser.showDialog(component, "ColorChooser", Color.BLUE); // NON-NLS: title } }
Example 3
Source File: Test4759934.java From jdk8u-jdk with GNU General Public License v2.0 | 6 votes |
public void actionPerformed(ActionEvent event) { String command = event.getActionCommand(); if (CMD_DIALOG.equals(command)) { JDialog dialog = new JDialog(this.frame, "Dialog"); // NON-NLS: dialog title dialog.setLocation(200, 0); show(dialog, CMD_CHOOSER); } else if (CMD_CHOOSER.equals(command)) { Object source = event.getSource(); Component component = (source instanceof Component) ? (Component) source : null; JColorChooser.showDialog(component, "ColorChooser", Color.BLUE); // NON-NLS: title } }
Example 4
Source File: Test4759934.java From openjdk-jdk9 with GNU General Public License v2.0 | 6 votes |
public void actionPerformed(ActionEvent event) { String command = event.getActionCommand(); if (CMD_DIALOG.equals(command)) { JDialog dialog = new JDialog(this.frame, "Dialog"); // NON-NLS: dialog title dialog.setLocation(200, 0); show(dialog, CMD_CHOOSER); } else if (CMD_CHOOSER.equals(command)) { Object source = event.getSource(); Component component = (source instanceof Component) ? (Component) source : null; JColorChooser.showDialog(component, "ColorChooser", Color.BLUE); // NON-NLS: title } }
Example 5
Source File: WeaponDataSaveService.java From gameserver with Apache License 2.0 | 6 votes |
public WeaponDataSaveService( Collection<WeaponPojo> weapons, String targetDatabase, String targetNamespace, String targetCollection) { this.weapons = weapons; this.targetDatabase = targetDatabase; this.targetNamespace = targetNamespace; this.targetCollection = targetCollection; panel = new JXPanel(); panel.setLayout(new MigLayout("wrap 1")); panel.add(label, "growx, wrap 20"); panel.add(progressBar, "grow, push"); dialog = new JDialog(); dialog.add(panel); dialog.setSize(300, 120); Point p = WindowUtils.getPointForCentering(dialog); dialog.setLocation(p); dialog.setModal(true); dialog.setResizable(false); dialog.setDefaultCloseOperation(JDialog.DO_NOTHING_ON_CLOSE); }
Example 6
Source File: StrengthTestService.java From gameserver with Apache License 2.0 | 6 votes |
public StrengthTestService( StrengthTestConfig config, MyTablePanel tablePanel) { this.model = model; this.config = config; this.count = config.getMaxTry(); this.tablePanel = tablePanel; panel = new JXPanel(); panel.setLayout(new MigLayout("wrap 1")); panel.add(label, "growx, wrap 20"); panel.add(progressBar, "grow, push"); dialog = new JDialog(); dialog.add(panel); dialog.setSize(300, 120); Point p = WindowUtils.getPointForCentering(dialog); dialog.setLocation(p); dialog.setModal(true); dialog.setResizable(false); dialog.setDefaultCloseOperation(JDialog.DO_NOTHING_ON_CLOSE); model = new StrengthTestResultModel(); tablePanel.setTableModel(model); }
Example 7
Source File: Test4759934.java From jdk8u60 with GNU General Public License v2.0 | 6 votes |
public void actionPerformed(ActionEvent event) { String command = event.getActionCommand(); if (CMD_DIALOG.equals(command)) { JDialog dialog = new JDialog(this.frame, "Dialog"); // NON-NLS: dialog title dialog.setLocation(200, 0); show(dialog, CMD_CHOOSER); } else if (CMD_CHOOSER.equals(command)) { Object source = event.getSource(); Component component = (source instanceof Component) ? (Component) source : null; JColorChooser.showDialog(component, "ColorChooser", Color.BLUE); // NON-NLS: title } }
Example 8
Source File: Test4759934.java From TencentKona-8 with GNU General Public License v2.0 | 6 votes |
public void actionPerformed(ActionEvent event) { String command = event.getActionCommand(); if (CMD_DIALOG.equals(command)) { JDialog dialog = new JDialog(this.frame, "Dialog"); // NON-NLS: dialog title dialog.setLocation(200, 0); show(dialog, CMD_CHOOSER); } else if (CMD_CHOOSER.equals(command)) { Object source = event.getSource(); Component component = (source instanceof Component) ? (Component) source : null; JColorChooser.showDialog(component, "ColorChooser", Color.BLUE); // NON-NLS: title } }
Example 9
Source File: BaseEvent.java From HBaseClient with GNU General Public License v3.0 | 5 votes |
/** * 屏幕中间显示对话窗口 * * @param i_JDialog */ public void showCreate(JDialog i_JDialog) { Toolkit v_Toolkit = Toolkit.getDefaultToolkit(); int v_X = (v_Toolkit.getScreenSize().height - i_JDialog.getHeight()) / 2; int v_Y = (v_Toolkit.getScreenSize().width - i_JDialog.getWidth() ) / 2; i_JDialog.setLocation(v_Y ,v_X); i_JDialog.setVisible(true); }
Example 10
Source File: Handler.java From ramus with GNU General Public License v3.0 | 5 votes |
/** * Floats the associated toolbar at the specified screen location, * optionally centering the floating frame on this point. */ public void floatToolBar(int x, int y, final boolean center) { final JDialog floatFrame = getFloatingFrame(); if (floatFrame == null) return; final Container target = ourDockLayout.getTargetContainer(); if (target != null) target.remove(ourToolBar); floatFrame.setVisible(false); floatFrame.getContentPane().remove(ourToolBar); ourToolBar.setOrientation(ToolBarLayout.HORIZONTAL); floatFrame.getContentPane().add(ourToolBar, BorderLayout.CENTER); floatFrame.pack(); if (center) { x -= floatFrame.getWidth() / 2; y -= floatFrame.getHeight() / 2; } // x and y are given relative to screen floatFrame.setLocation(x, y); floatFrame.setTitle(ourToolBar.getName()); floatFrame.setVisible(true); ourToolBarShouldFloat = true; if (target != null) { target.validate(); target.repaint(); } }
Example 11
Source File: DialogUtils.java From WorldGrower with GNU General Public License v3.0 | 5 votes |
/** * Centers the dialog over the given parent component. Also, creates a * semi-transparent panel behind the dialog to mask the parent content. * The title of the dialog is displayed in a custom fashion over the dialog * panel, and a rectangular shadow is placed behind the dialog. */ public static void createDialogBackPanel(JDialog dialog, Component parent) { dialog.setBackground(new Color(255, 255, 255, 64)); DialogBackPanel newContentPane = new DialogBackPanel(dialog.getContentPane(), dialog.getTitle()); dialog.setContentPane(newContentPane); dialog.setSize(parent.getSize()); dialog.setLocation(parent.getLocationOnScreen()); }
Example 12
Source File: UPbFractionTableModel.java From ET_Redux with Apache License 2.0 | 5 votes |
@Override public void actionPerformed(ActionEvent e) { JDialog notesDialog = new FractionNotesDialog(parentFrame, true, fraction); notesDialog.setLocation(parentFrame.getX() + 350, parentFrame.getY() + 350); notesDialog.setVisible(true); JButton tempJB = (JButton) e.getSource(); tuneNotesButton(tempJB, fraction.getFractionNotes()); tempJB.repaint(); }
Example 13
Source File: WeaponDataGeneratorService.java From gameserver with Apache License 2.0 | 5 votes |
public WeaponDataGeneratorService(List<String> namePrefixes, List<Integer> dprList, double[] params) { this.origWeaponList = new ArrayList<WeaponPojo>(); List<DBObject> list = MongoUtil.queryAllFromMongo(null, database, namespace, "equipments", null); for ( DBObject obj : list ) { WeaponPojo weapon = (WeaponPojo)MongoUtil.constructObject(obj); this.origWeaponList.add(weapon); } Collections.sort(this.origWeaponList); if ( namePrefixes != null ) { this.namePrefixes.addAll(namePrefixes); } if ( dprList != null ) { this.dprList.addAll(dprList); } attackUnit = params[0]; defendUnit = params[1]; luckUnit = params[2]; agilityUnit = params[3]; panel = new JXPanel(); panel.setLayout(new MigLayout("wrap 1")); panel.add(label, "growx, wrap 20"); panel.add(progressBar, "grow, push"); dialog = new JDialog(); dialog.add(panel); dialog.setSize(300, 120); Point p = WindowUtils.getPointForCentering(dialog); dialog.setLocation(p); dialog.setModal(true); dialog.setResizable(false); dialog.setDefaultCloseOperation(JDialog.DO_NOTHING_ON_CLOSE); this.progressBar.setIndeterminate(true); }
Example 14
Source File: MyWindowUtil.java From gameserver with Apache License 2.0 | 5 votes |
public static JDialog getCenterDialog(int width, int height, JComponent panel, JButton okButton) { JDialog dialog = new JDialog(); dialog.setLayout(new MigLayout("wrap 1", "[100%]")); dialog.add(panel, "width 100%, height 90%, grow"); if ( okButton != null ) { dialog.add(okButton, "align center"); } dialog.setSize(width, height); Point cpoint = WindowUtils.getPointForCentering(dialog); dialog.setLocation(cpoint); dialog.setModal(true); return dialog; }
Example 15
Source File: SampleAnalysisWorkflowManagerIDTIMS.java From ET_Redux with Apache License 2.0 | 5 votes |
public void actionPerformed(ActionEvent e) { JDialog notesDialog = new FractionNotesDialog(parentFrame, true, fraction); notesDialog.setLocation(parentFrame.getX() + 500, parentFrame.getY() + 50); notesDialog.setVisible(true); JButton tempJB = (JButton) e.getSource(); tuneNotesButton(tempJB, ((UPbFraction) fraction).getFractionNotes()); tempJB.repaint(); }
Example 16
Source File: JDialog741.java From jdk8u_jdk with GNU General Public License v2.0 | 5 votes |
public void start() { System.setProperty("jbre.popupwindow.settype", "true"); jFrame = new JFrame("Wrong popup z-order"); jFrame.setSize(200, 200); jFrame.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE); JPanel jPanel = new JPanel(); jPanel.setPreferredSize(new Dimension(200, 200)); Popup popup = PopupFactory.getSharedInstance().getPopup(jFrame, jPanel, 100, 100); windowAncestor = SwingUtilities.getWindowAncestor(jPanel); ((RootPaneContainer) windowAncestor).getRootPane().putClientProperty("SIMPLE_WINDOW", true); windowAncestor.setFocusable(true); windowAncestor.setFocusableWindowState(true); windowAncestor.setAutoRequestFocus(true); jFrame.setVisible(true); popup.show(); modalBlocker = new JDialog(windowAncestor, "Modal Blocker"); modalBlocker.setModal(true); modalBlocker.setSize(new Dimension(200, 200)); modalBlocker.setLocation(200, 200); modalBlocker.addWindowListener(new JDialog741Listener()); modalBlocker.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE); modalBlocker.setVisible(true); }
Example 17
Source File: SampleAnalysisWorkflowManagerLAICPMS.java From ET_Redux with Apache License 2.0 | 5 votes |
public void actionPerformed(ActionEvent e) { JDialog notesDialog = new FractionNotesDialog(parentFrame, true, fraction); notesDialog.setLocation(parentFrame.getX() + 500, parentFrame.getY() + 50); notesDialog.setVisible(true); JButton tempJB = (JButton) e.getSource(); tuneNotesButton(tempJB, ((UPbFractionI) fraction).getFractionNotes()); tempJB.repaint(); }
Example 18
Source File: MoveChooserService.java From Shuffle-Move with GNU General Public License v3.0 | 4 votes |
@Override public void onSetupGUI() { d = new JDialog(getOwner()); d.setLayout(new GridBagLayout()); d.setTitle(getString(KEY_TITLE)); shuffleMenuBar = new ShuffleMenuBar(getUser(), getOwner()); d.setJMenuBar(shuffleMenuBar); GridBagConstraints c = new GridBagConstraints(); c.fill = GridBagConstraints.BOTH; c.anchor = GridBagConstraints.CENTER; c.weightx = 1.0; c.weighty = 1.0; c.gridy = 1; // Display row c.weighty = 1.0; c.gridwidth = 4; c.gridx = 1; c.gridy++; c.gridx++; results = new ArrayList<SimulationResult>(); resultsMap = new HashMap<SimulationResult, Integer>(); model2 = new DefaultTableModel(getColumnNames(), 0) { private static final long serialVersionUID = 5180830497930828902L; @Override public boolean isCellEditable(int row, int col) { return false; } }; table = new JTable(model2); loadOrderFor(table, getUser().getPreferencesManager().getStringValue(KEY_COLUMN_ORDER)); resizeColumnWidth(table); table.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); listener2 = new ListSelectionListener() { @Override public void valueChanged(ListSelectionEvent e) { pushSelectionToUser2(); } }; table.getSelectionModel().addListSelectionListener(listener2); JScrollPane jsp = new JScrollPane(table); d.add(jsp, c); // Control row c.weighty = 0.0; c.gridwidth = 1; c.gridx = 1; c.gridy++; c.gridx++; metricLabel = new JLabel(getString(KEY_METRIC_LABEL)); metricLabel.setHorizontalAlignment(SwingConstants.CENTER); metricLabel.setHorizontalTextPosition(SwingConstants.CENTER); metricLabel.setToolTipText(getString(KEY_METRIC_TOOLTIP)); d.add(metricLabel, c); c.gridx++; ind = new GradingModeIndicator(getUser()); ind.setToolTipText(getString(KEY_METRIC_TOOLTIP)); d.add(ind, c); c.gridx++; doMoveButton = new JButton(new AbstractAction(getString(KEY_DO_NOW)) { private static final long serialVersionUID = -8952138130413953491L; @Override public void actionPerformed(ActionEvent arg0) { doMovePressed(); } }); doMoveButton.setToolTipText(getString(KEY_DO_TOOLTIP)); d.add(doMoveButton, c); setDefaultButton(doMoveButton); c.gridx++; closeButton = new JButton(new DisposeAction(getString(KEY_CLOSE), this)); closeButton.setToolTipText(getString(KEY_CLOSE_TOOLTIP)); d.add(closeButton, c); d.pack(); ConfigManager preferencesManager = getUser().getPreferencesManager(); final int width = preferencesManager.getIntegerValue(KEY_CHOOSER_WIDTH, DEFAULT_CHOOSER_WIDTH); final int height = preferencesManager.getIntegerValue(KEY_CHOOSER_HEIGHT, DEFAULT_CHOOSER_HEIGHT); d.setSize(width, height); d.repaint(); Integer x = preferencesManager.getIntegerValue(KEY_CHOOSER_X); Integer y = preferencesManager.getIntegerValue(KEY_CHOOSER_Y); if (x != null && y != null) { d.setLocation(x, y); } else { d.setLocationRelativeTo(null); } d.setMinimumSize(MIN_SIZE); d.setResizable(preferencesManager.getBooleanValue(KEY_CHOOSER_RESIZE, DEFAULT_RESIZE)); getUser().addObserver(this); setDialog(d); }
Example 19
Source File: LoneOptionDialog.java From stendhal with GNU General Public License v2.0 | 4 votes |
/** * Place a dialog centered on the screen with the mouse cursor. * * @param dialog dialog to be centered */ private static void setLocation(JDialog dialog) { Rectangle r = mouseScreenBounds(); dialog.setLocation(r.x + (r.width - dialog.getWidth()) / 2, r.y + (r.height - dialog.getHeight()) / 2); }
Example 20
Source File: SkinEditorMainGUI.java From megamek with GNU General Public License v2.0 | 4 votes |
/** * Initializes a number of things about this frame. */ private void initializeFrame() { frame = new JFrame(Messages.getString("ClientGUI.title")); //$NON-NLS-1$ frame.setJMenuBar(menuBar); Rectangle virtualBounds = getVirtualBounds(); int x, y, w, h; if (GUIPreferences.getInstance().getWindowSizeHeight() != 0) { x = GUIPreferences.getInstance().getWindowPosX(); y = GUIPreferences.getInstance().getWindowPosY(); w = GUIPreferences.getInstance().getWindowSizeWidth(); h = GUIPreferences.getInstance().getWindowSizeHeight(); if ((x < virtualBounds.getMinX()) || ((x + w) > virtualBounds.getMaxX())) { x = 0; } if ((y < virtualBounds.getMinY()) || ((y + h) > virtualBounds.getMaxY())) { y = 0; } if (w > virtualBounds.getWidth()) { w = (int) virtualBounds.getWidth(); } if (h > virtualBounds.getHeight()) { h = (int) virtualBounds.getHeight(); } frame.setLocation(x, y); frame.setSize(w, h); } else { frame.setSize(800, 600); } frame.setMinimumSize(new Dimension(640, 480)); frame.setBackground(SystemColor.menu); frame.setForeground(SystemColor.menuText); List<Image> iconList = new ArrayList<Image>(); iconList.add(frame.getToolkit().getImage( new MegaMekFile(Configuration.miscImagesDir(), FILENAME_ICON_16X16) .toString())); iconList.add(frame.getToolkit().getImage( new MegaMekFile(Configuration.miscImagesDir(), FILENAME_ICON_32X32) .toString())); iconList.add(frame.getToolkit().getImage( new MegaMekFile(Configuration.miscImagesDir(), FILENAME_ICON_48X48) .toString())); iconList.add(frame.getToolkit().getImage( new MegaMekFile(Configuration.miscImagesDir(), FILENAME_ICON_256X256) .toString())); frame.setIconImages(iconList); mechW = new JDialog(frame, Messages.getString("ClientGUI.MechDisplay"), false); x = GUIPreferences.getInstance().getDisplayPosX(); y = GUIPreferences.getInstance().getDisplayPosY(); h = GUIPreferences.getInstance().getDisplaySizeHeight(); w = GUIPreferences.getInstance().getDisplaySizeWidth(); if ((x + w) > virtualBounds.getWidth()) { x = 0; w = Math.min(w, (int)virtualBounds.getWidth()); } if ((y + h) > virtualBounds.getHeight()) { y = 0; h = Math.min(h, (int)virtualBounds.getHeight()); } mechW.setLocation(x, y); mechW.setSize(w, h); mechW.setResizable(true); unitDisplay = new UnitDisplay(null); mechW.add(unitDisplay); mechW.setVisible(true); unitDisplay.displayEntity(testEntity); }