Java Code Examples for javax.swing.JDialog#setResizable()

The following examples show how to use javax.swing.JDialog#setResizable() . 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: StrengthTestService.java    From gameserver with Apache License 2.0 6 votes vote down vote up
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 2
Source File: WeaponManualDataImportService.java    From gameserver with Apache License 2.0 6 votes vote down vote up
public WeaponManualDataImportService(
		File file,
		WeaponTableModel model,
		ArrayList<Double> dprList) {
	this.importExcelFile = file;
	this.weaponModel = model;
	this.levelDprList = dprList;
	
	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 3
Source File: CopyMongoCollectionService.java    From gameserver with Apache License 2.0 6 votes vote down vote up
public CopyMongoCollectionService(
		String sourceDatabase, String sourceNamespace, String sourceCollection, 
		String targetDatabase, String targetNamespace, String targetCollection) {
	this.sourceDatabase = sourceDatabase; 
	this.sourceNamespace = sourceNamespace;
	this.sourceCollection = sourceCollection; 
	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 4
Source File: PreferencePanel.java    From pumpernickel with MIT License 5 votes vote down vote up
/** Creates a modal dialog displaying this PreferencePanel. */
public JDialog createDialog(Frame parent, String name) {
	JDialog d = new JDialog(parent, name, true);

	if (isMac) {
		// brush metal isn't available for dialogs, only frames
		// d.getRootPane().putClientProperty("apple.awt.brushMetalLook",
		// Boolean.TRUE);
		separator.setForeground(new Color(64, 64, 64));
	}
	d.getContentPane().setLayout(new GridBagLayout());
	GridBagConstraints c = new GridBagConstraints();
	c.gridx = 0;
	c.gridy = 0;
	c.weightx = 1;
	c.weighty = 1;
	c.fill = GridBagConstraints.BOTH;
	d.getContentPane().add(this, c);
	d.setResizable(false);
	InputMap inputMap = d.getRootPane().getInputMap(
			JComponent.WHEN_IN_FOCUSED_WINDOW);
	ActionMap actionMap = d.getRootPane().getActionMap();

	inputMap.put(escapeKey, escapeKey);
	inputMap.put(commandPeriodKey, escapeKey);
	actionMap.put(escapeKey, closeDialogAndDisposeAction);

	return d;
}
 
Example 5
Source File: DecryptTextView.java    From pgptool with GNU General Public License v3.0 5 votes vote down vote up
@Override
protected JDialog initDialog(Window owner, Object constraints) {
	JDialog ret = new JDialog(owner, ModalityType.MODELESS);
	ret.setLayout(new BorderLayout());
	ret.setResizable(true);
	ret.setMinimumSize(new Dimension(UiUtils.getFontRelativeSize(80), UiUtils.getFontRelativeSize(40)));
	ret.setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE);
	ret.setTitle(Messages.get("action.decryptText"));
	ret.add(pnl, BorderLayout.CENTER);
	initWindowGeometryPersister(ret, "decrText");
	return ret;
}
 
Example 6
Source File: KeysListView.java    From pgptool with GNU General Public License v3.0 5 votes vote down vote up
@Override
protected JDialog initDialog(Window owner, Object constraints) {
	JDialog ret = new JDialog(owner, ModalityType.APPLICATION_MODAL);
	ret.setMinimumSize(new Dimension(spacing(50), spacing(25)));
	ret.setLayout(new BorderLayout());
	ret.setResizable(true);
	ret.setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE);
	ret.setTitle(Messages.get("term.keysList"));
	ret.add(panelRoot, BorderLayout.CENTER);
	ret.setJMenuBar(menuBar);
	initWindowGeometryPersister(ret, "keysList");
	return ret;
}
 
Example 7
Source File: GetKeyPasswordDialogView.java    From pgptool with GNU General Public License v3.0 5 votes vote down vote up
@Override
protected JDialog initDialog(Window owner, Object constraints) {
	JDialog ret = new JDialog(owner, ModalityType.DOCUMENT_MODAL);
	ret.setLayout(new BorderLayout());
	ret.setResizable(false);
	ret.setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE);
	ret.setTitle(Messages.get("action.providePasswordForAKey"));
	ret.add(pnl, BorderLayout.CENTER);
	ret.pack();
	UiUtils.centerWindow(ret, owner);
	return ret;
}
 
Example 8
Source File: AboutView.java    From pgptool with GNU General Public License v3.0 5 votes vote down vote up
@Override
protected JDialog initDialog(Window owner, Object constraints) {
	JDialog ret = new JDialog(owner, ModalityType.APPLICATION_MODAL);
	ret.setLayout(new BorderLayout());
	ret.setResizable(false);
	ret.setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE);
	ret.setTitle(Messages.get("term.aboutApp"));
	ret.add(pnl, BorderLayout.CENTER);
	ret.pack();
	return ret;
}
 
Example 9
Source File: ConnectorDetailsPanel.java    From sldeditor with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Show dialog.
 *
 * @param parentPanel the parent panel
 * @param connectionDetails the connection details
 * @return the connector details panel
 */
public static GeoServerConnection showDialog(
        JDialog parentPanel, GeoServerConnection connectionDetails) {
    JDialog dialog =
            new JDialog(
                    parentPanel,
                    Localisation.getString(
                            ConnectorDetailsPanel.class, "ConnectorDetailsPanel.title"),
                    true);
    dialog.setResizable(false);

    ConnectorDetailsPanel panel = new ConnectorDetailsPanel(dialog);

    dialog.getContentPane().add(panel);

    panel.populate(connectionDetails);
    dialog.pack();
    dialog.setSize(BasePanel.FIELD_PANEL_WIDTH, 175);

    Controller.getInstance().centreDialog(dialog);

    if (!isInTestMode()) {
        dialog.setVisible(true);
    }

    if (panel.okButtonPressed() || isInTestMode()) {
        return panel.getConnectionDetails();
    }
    return null;
}
 
Example 10
Source File: KeyImporterView.java    From pgptool with GNU General Public License v3.0 5 votes vote down vote up
@Override
protected JDialog initDialog(Window owner, Object constraints) {
	JDialog ret = new JDialog(owner, ModalityType.APPLICATION_MODAL);
	ret.setLayout(new BorderLayout());
	ret.setResizable(true);
	ret.setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE);
	ret.setTitle(Messages.get("action.importKey"));
	ret.add(pnl, BorderLayout.CENTER);
	ret.setMinimumSize(new Dimension(spacing(60), spacing(30)));

	initWindowGeometryPersister(ret, "keyImprt");

	return ret;
}
 
Example 11
Source File: MainFrame.java    From procamcalib with GNU General Public License v2.0 5 votes vote down vote up
private void readmeMenuItemActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_readmeMenuItemActionPerformed
    try {
        JTextArea textArea = new JTextArea();
        Font font = textArea.getFont();
        textArea.setFont(new Font("Monospaced", font.getStyle(), font.getSize()));
        textArea.setEditable(false);

        String text = "";
        BufferedReader r = new BufferedReader(new FileReader(
                myDirectory + File.separator + "../README.md"));
        String line;
        while ((line = r.readLine()) != null) {
            text += line + '\n';
        }

        textArea.setText(text);
        textArea.setCaretPosition(0);
        textArea.setLineWrap(true);
        textArea.setWrapStyleWord(true);
        textArea.setColumns(80);

        // stuff it in a scrollpane with a controlled size.
        JScrollPane scrollPane = new JScrollPane(textArea);
        Dimension dim = textArea.getPreferredSize();
        dim.height = dim.width*50/80;
        scrollPane.setPreferredSize(dim);

        // pass the scrollpane to the joptionpane.
        JDialog dialog = new JOptionPane(scrollPane, JOptionPane.PLAIN_MESSAGE).
                createDialog(this, "README");
        dialog.setResizable(true);
        dialog.setModalityType(ModalityType.MODELESS);
        dialog.setVisible(true);
    } catch (Exception ex) {
        Logger.getLogger(MainFrame.class.getName()).log(Level.SEVERE, null, ex);
    }
}
 
Example 12
Source File: DownloadIconsService.java    From gameserver with Apache License 2.0 5 votes vote down vote up
@Override
protected void process(List<Integer> chunks) {
	if ( stage == Stage.GET_NUM_OF_ICONS ) {
		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);
		dialog.setVisible(true);
		
		label.setText("正在获取图标列表...");
		label.setFont(MainFrame.BIG_FONT);
		progressBar.setIndeterminate(true);
	} else if ( stage == Stage.GOT_NUM_OF_ICONS ) {
		label.setFont(MainFrame.BIG_FONT);
		label.setText("总图标数量: " + icons.size());
		label.repaint();
		progressBar.setIndeterminate(false);
		progressBar.setMinimum(0);
		progressBar.setMaximum(icons.size());
		progressBar.setStringPainted(true);
	} else if ( stage == Stage.DOWNLOAD_ICONS ) {
		if ( chunks != null && chunks.size()>0 ) {
			int percent = chunks.get(chunks.size()-1);
			progressBar.setValue(percent);
		}
	} else if ( stage == Stage.INITIAL_EQUIPS ) {
		label.setText("正在初始化装备数据...");
		progressBar.setIndeterminate(true);
	}
}
 
Example 13
Source File: DefaultAbout.java    From opt4j with MIT License 5 votes vote down vote up
@Override
public JDialog getDialog(ApplicationFrame frame) {
	JDialog dialog = new JDialog(frame, "About Configurator", true);
	dialog.setBackground(Color.WHITE);
	dialog.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
	dialog.setResizable(false);

	dialog.add(new JLabel("Void Frame"));
	dialog.pack();
	dialog.setVisible(false);

	return dialog;
}
 
Example 14
Source File: SkinEditorMainGUI.java    From megamek with GNU General Public License v2.0 4 votes vote down vote up
/**
 * 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);
}
 
Example 15
Source File: MoveChooserService.java    From Shuffle-Move with GNU General Public License v3.0 4 votes vote down vote up
@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 16
Source File: WindowUtils.java    From gcs with Mozilla Public License 2.0 4 votes vote down vote up
/**
 * Shows an option dialog.
 *
 * @param parentComponent The parent {@link Component} to use. May be {@code null}.
 * @param message         The message. May be a {@link Component}.
 * @param title           The title to use.
 * @param resizable       Whether to allow the dialog to be resized by the user.
 * @param optionType      The type of option dialog. Use the {@link JOptionPane} constants.
 * @param messageType     The type of message. Use the {@link JOptionPane} constants.
 * @param icon            The icon to use. May be {@code null}.
 * @param options         The options to display. May be {@code null}.
 * @param initialValue    The initial option.
 * @return See the documentation for {@link JOptionPane}.
 */
public static int showOptionDialog(Component parentComponent, Object message, String title, boolean resizable, int optionType, int messageType, Icon icon, Object[] options, Object initialValue) {
    JOptionPane pane = new JOptionPane(message, messageType, optionType, icon, options, initialValue);
    pane.setUI(new SizeAwareBasicOptionPaneUI(pane.getUI()));
    pane.setInitialValue(initialValue);
    pane.setComponentOrientation((parentComponent == null ? JOptionPane.getRootFrame() : parentComponent).getComponentOrientation());

    JDialog dialog = pane.createDialog(getWindowForComponent(parentComponent), title);
    WindowSizeEnforcer.monitor(dialog);
    pane.selectInitialValue();
    dialog.setResizable(resizable);
    Component field = getFirstFocusableField(message);
    if (field != null) {
        dialog.addWindowFocusListener(new WindowAdapter() {
            @Override
            public void windowGainedFocus(WindowEvent event) {
                field.requestFocus();
                dialog.removeWindowFocusListener(this);
            }
        });
    }
    dialog.setVisible(true);
    dialog.dispose();
    pane.setMessage(null);

    Object selectedValue = pane.getValue();
    if (selectedValue != null) {
        if (options == null) {
            if (selectedValue instanceof Integer) {
                return ((Integer) selectedValue).intValue();
            }
        } else {
            int length = options.length;
            for (int i = 0; i < length; i++) {
                if (options[i].equals(selectedValue)) {
                    return i;
                }
            }
        }
    }
    return JOptionPane.CLOSED_OPTION;
}
 
Example 17
Source File: StartupDialog.java    From visualvm with GNU General Public License v2.0 4 votes vote down vote up
public static JDialog create(String caption, String message, int messageType) {
    // Bugfix #361, set the JDialog to appear in the Taskbar on Windows (ModalityType.APPLICATION_MODAL)
    Window[] windows = Window.getWindows();
    final JDialog d = windows == null || windows.length == 0 ?
            new JDialog(null, caption, JDialog.ModalityType.APPLICATION_MODAL) :
            new JDialog((Frame)null, caption, true);
    
    if (message != null) initDialog(d, message, messageType);
    
    // Bugfix #361, JDialog should use the VisualVM icon for better identification
    List<Image> icons = new ArrayList();
    icons.add(ImageUtilities.loadImage("org/netbeans/core/startup/frame.gif", true)); // NOI18N
    icons.add(ImageUtilities.loadImage("org/netbeans/core/startup/frame24.gif", true)); // NOI18N
    icons.add(ImageUtilities.loadImage("org/netbeans/core/startup/frame32.gif", true)); // NOI18N
    icons.add(ImageUtilities.loadImage("org/netbeans/core/startup/frame48.gif", true)); // NOI18N
    d.setIconImages(icons);
    
    d.setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE);
    d.setResizable(false);
    d.setLocationRelativeTo(null);
    
    // Bugfix #361, ensure that the dialog will be the topmost visible window after opening
    d.addHierarchyListener(new HierarchyListener() {
        public void hierarchyChanged(HierarchyEvent e) {
            if ((e.getChangeFlags() & HierarchyEvent.SHOWING_CHANGED) != 0) {
                if (d.isShowing()) {
                    // For some reason the dialog created with defined JDialog.ModalityType
                    // isn't displayed on Windows when opened by the NetBeans launcher. This
                    // code seems to workaround it while not breaking anything elsewhere.
                    // Disabled to fix jigsaw, the problem is not reproducible using Java7u80@Win7
                    // ComponentPeer peer = d.getPeer();
                    // if (peer != null) peer.setVisible(true);

                    d.removeHierarchyListener(this);
                    d.setAlwaysOnTop(true);
                    d.toFront();
                    d.setAlwaysOnTop(false);
                }
            }
        }
    });
    
    return d;
}
 
Example 18
Source File: EditTeamService.java    From Shuffle-Move with GNU General Public License v3.0 4 votes vote down vote up
@Override
public void onSetupGUI() {
   d = new JDialog(getOwner(), getString(KEY_TITLE));
   d.setLayout(new GridBagLayout());
   GridBagConstraints c = new GridBagConstraints();
   c.fill = GridBagConstraints.HORIZONTAL;
   c.weightx = 1.0;
   c.weighty = 0.0;
   c.gridx = 1;
   c.gridy = 1;
   c.gridwidth = 2;
   c.gridheight = 1;
   d.add(makeUpperPanel(), c);
   
   c.gridy += 1;
   c.fill = GridBagConstraints.BOTH;
   c.weighty = 1.0;
   c.gridwidth = 1;
   d.add(makeRosterPanel(), c);
   
   c.gridx += 1;
   c.weightx = 0.0;
   d.add(makeTeamPanel(), c);
   c.weightx = 1.0;
   
   c.gridx = 1;
   c.gridy += 1;
   c.gridwidth = 2;
   c.fill = GridBagConstraints.HORIZONTAL;
   c.weighty = 0.0;
   d.add(makeBottomPanel(), c);
   
   ConfigManager preferencesManager = getUser().getPreferencesManager();
   int defaultWidth = preferencesManager.getIntegerValue(KEY_POPUP_WIDTH, DEFAULT_POPUP_WIDTH);
   int defaultHeight = preferencesManager.getIntegerValue(KEY_POPUP_HEIGHT, DEFAULT_POPUP_HEIGHT);
   int width = preferencesManager.getIntegerValue(KEY_EDIT_TEAM_WIDTH, defaultWidth);
   int height = preferencesManager.getIntegerValue(KEY_EDIT_TEAM_HEIGHT, defaultHeight);
   d.repaint();
   d.pack();
   d.setMinimumSize(new Dimension(getMinimumWidth(), DEFAULT_POPUP_HEIGHT));
   d.setSize(new Dimension(width, height));
   d.setLocationRelativeTo(null);
   d.setResizable(true);
   addActionListeners();
   
   setDialog(d);
}
 
Example 19
Source File: BiomeExporterDialog.java    From amidst with GNU General Public License v3.0 4 votes vote down vote up
private JDialog createDialog() {
	JPanel panel = new JPanel(new GridBagLayout());

	setConstraints(40, 0, 0, 0, NONE, 1, 1, 1, 1, 0.0, 0.0, SOUTH);
	panel.add(createLabeledPanel("Top:", topSpinner, NONE), constraints);

	setConstraints(20, 20, 0, 0, NONE, 0, 2, 1, 1, 0.0, 0.0, SOUTH);
	panel.add(createLabeledPanel("Left:", leftSpinner, NONE), constraints);

	setConstraints(20, 0, 0, 0, NONE, 1, 3, 1, 1, 0.0, 0.0, SOUTH);
	panel.add(createLabeledPanel("Bottom:", bottomSpinner, NONE), constraints);

	setConstraints(20, 0, 0, 0, NONE, 2, 2, 1, 1, 0.0, 0.0, SOUTH);
	panel.add(createLabeledPanel("Right:", rightSpinner, NONE), constraints);

	setConstraints(10, 20, 0, 0, NONE, 0, 5, 2, 1, 0.0, 0.0, SOUTHWEST);
	panel.add(fullResCheckBox, constraints);

	setConstraints(0, 15, 0, 15, BOTH, 3, 0, 1, 6, 1.0, 0.0, CENTER);
	panel.add(Box.createGlue(), constraints);

	setConstraints(0, 0, 0, 0, BOTH, 0, 4, 4, 1, 0.0, 1.0, CENTER);
	panel.add(Box.createGlue(), constraints);

	JPanel pathPanel = new JPanel(new GridBagLayout());

	setConstraints(0, 0, 0, 0, HORIZONTAL, 0, 0, 1, 1, 0.0, 0.0, SOUTH);
	pathPanel.add(createLabeledPanel("Path:", pathField, HORIZONTAL), constraints);

	setConstraints(0, 10, 0, 0, HORIZONTAL, 1, 0, 1, 1, 0.0, 0.0, SOUTH);
	pathPanel.add(browseButton, constraints);

	setConstraints(10, 20, 20, 10, BOTH, 0, 6, 4, 2, 0.0, 0.0, SOUTHWEST);
	panel.add(pathPanel, constraints);

	setConstraints(15, 10, 10, 20, BOTH, 4, 0, 1, 7, 0.0, 0.0, EAST);
	panel.add(createLabeledPanel("Preview:", previewLabel, NONE), constraints);

	setConstraints(10, 10, 20, 20, NONE, 4, 7, 1, 1, 0.0, 0.0, SOUTHEAST);
	panel.add(exportButton, constraints);

	JDialog newDialog = new JDialog(parentFrame, "Export Biome Image");
	newDialog.setDefaultCloseOperation(JDialog.DO_NOTHING_ON_CLOSE);
	newDialog.addWindowListener(new WindowAdapter() {
		@Override
		public void windowClosing(WindowEvent e) {
			/*
			 * This executes only when it's closed with the x button, alt f4, etc.
			 * When this happens we know that the user did not press the ok button
			 * to continue, so we re enable the export biomes menu button.
			 */
			menuBarSupplier.get().setMenuItemsEnabled(new String[] { "Export Biomes to Image ...", "Biome Profile" }, true);
			newDialog.dispose();
		}
	});
	newDialog.add(panel);
	newDialog.pack();
	newDialog.setResizable(false);
	return newDialog;
}
 
Example 20
Source File: IdeOptions.java    From CQL with GNU Affero General Public License v3.0 4 votes vote down vote up
public void showOptions0() {
	IdeOptions o = this; // new IdeOptions(IdeOptions.theCurrentOptions);

	JPanel p1 = new JPanel(new GridLayout(1, 1));
	p1.add(new JScrollPane(general()));
	JPanel p2 = new JPanel(new GridLayout(1, 1));
	p2.add(new JScrollPane(onlyColors()));
	JPanel p3 = new JPanel(new GridLayout(1, 1));
	p3.add(new JScrollPane(outline()));
	JTabbedPane jtb = new JTabbedPane();
	jtb.add("General", p1);
	jtb.add("Colors", p2);
	jtb.add("Outline", p3);
	CodeTextPanel cc = new CodeTextPanel("", AqlOptions.getMsg());
	jtb.addTab("CQL", cc);

	jtb.setSelectedIndex(selected_tab);
	JPanel oo = new JPanel(new GridLayout(1, 1));
	oo.add(jtb);
	// oo.setPreferredSize(theD);

	// outline at top otherwise weird sizing collapse on screen
	JOptionPane pane = new JOptionPane(oo, JOptionPane.PLAIN_MESSAGE, JOptionPane.OK_CANCEL_OPTION, null,
			new String[] { "OK", "Cancel", "Reset", "Save", "Load", "Delete" }, "OK");
	// pane.setPreferredSize(theD);
	JDialog dialog = pane.createDialog(null, "Options");
	dialog.setModal(false);
	dialog.setResizable(true);
	dialog.addWindowListener(new WindowAdapter() {

		@Override
		public void windowDeactivated(WindowEvent e) {
			Object ret = pane.getValue();

			selected_tab = jtb.getSelectedIndex();

			if (ret == "OK") {
				theCurrentOptions = o;
				notifyListenersOfChange();
			} else if (ret == "Reset") {
				new IdeOptions().showOptions0();
			} else if (ret == "Save") { // save
				save(o);
				o.showOptions0();
			} else if (ret == "Load") { // load
				load().showOptions0();
			} else if (ret == "Delete") {
				delete();
				o.showOptions0();
			}
		}

	});
	dialog.setPreferredSize(theD);
	dialog.pack();
	dialog.setLocationRelativeTo(null);
	dialog.setVisible(true);
}