Java Code Examples for javax.swing.JButton#setMaximumSize()

The following examples show how to use javax.swing.JButton#setMaximumSize() . 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: MeasurementSetPanel.java    From opensim-gui with Apache License 2.0 6 votes vote down vote up
public JPanel getMarkerPairComponent(MarkerPair markerPair, int measurementIndex, int markerPairIndex) {
   JPanel panel = new JPanel();
   panel.setLayout(new BoxLayout(panel, BoxLayout.X_AXIS));
   panel.setBorder(markerPairControlsBorder);
   panel.setAlignmentX(0);

   // Markers
   panel.add(getMarkerComponent(markerPair.getMarkerName(0), measurementIndex, markerPairIndex, 0));
   panel.add(getMarkerComponent(markerPair.getMarkerName(1), measurementIndex, markerPairIndex, 1));

   // Delete marker pair button
   JButton removeMarkerPairButton = new JButton(new RemoveMarkerPairAction(measurementIndex, markerPairIndex));
   removeMarkerPairButton.setRolloverIcon(removeRolloverIcon);
   removeMarkerPairButton.setMargin(new Insets(0,0,0,0));
   removeMarkerPairButton.setMinimumSize(buttonDim);
   removeMarkerPairButton.setMaximumSize(buttonDim);
   removeMarkerPairButton.setPreferredSize(buttonDim);
   removeMarkerPairButton.setBorder(null);
   removeMarkerPairButton.setContentAreaFilled(false);
   removeMarkerPairButton.setOpaque(true);
   removeMarkerPairButton.setBackground(Color.white);
   panel.add(removeMarkerPairButton);

   return panel;
}
 
Example 2
Source File: ServerDataSourceSelectionPanel.java    From nextreports-designer with Apache License 2.0 6 votes vote down vote up
private void init() {
	dataSourceField = new JTextField();
	JButton dsButton = new JButton(ImageUtil.getImageIcon("database"));
	dsButton.setPreferredSize(buttonDim);
	dsButton.setMaximumSize(buttonDim);
	dsButton.setMinimumSize(buttonDim);
	dsButton.setToolTipText(I18NSupport.getString("wizard.panel.start.datasource.title"));
	dsButton.addActionListener(new ActionListener() {
           public void actionPerformed(ActionEvent e) {      
           	if (selection()) {
           		selectDataSourceDialog();
           	}
           }
       });
	
	setLayout(new GridBagLayout());
       
       add(dataSourceField, new GridBagConstraints(0, 0, 1, 1, 1.0, 0.0,
               GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL,
               new Insets(0, 0, 0, 0), 0, 0));
       add(dsButton, new GridBagConstraints(1, 0, 1, 1, 0.0, 0.0,
               GridBagConstraints.WEST, GridBagConstraints.NONE,
               new Insets(0, 5, 0, 0), 0, 0));
}
 
Example 3
Source File: TraceEventTypePopupMenu.java    From pega-tracerviewer with Apache License 2.0 6 votes vote down vote up
private JButton getClearAllJButton() {
    JButton clearAllJButton = new JButton("Clear All");

    Dimension size = new Dimension(80, 20);
    clearAllJButton.setPreferredSize(size);
    clearAllJButton.setMinimumSize(size);
    clearAllJButton.setMaximumSize(size);

    clearAllJButton.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent event) {

            // applyColumnHeaderFilter(columnIndex, true);
            // clearAllJButtonAction();
            //
            // setVisible(false);
            applyClearAll();
        }
    });

    return clearAllJButton;
}
 
Example 4
Source File: TraceEventTypePopupMenu.java    From pega-tracerviewer with Apache License 2.0 6 votes vote down vote up
private JButton getSelectAllJButton() {
    JButton selectAllJButton = new JButton("Select All");

    Dimension size = new Dimension(80, 20);
    selectAllJButton.setPreferredSize(size);
    selectAllJButton.setMinimumSize(size);
    selectAllJButton.setMaximumSize(size);

    selectAllJButton.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent event) {

            applySelectAll();
        }
    });

    return selectAllJButton;
}
 
Example 5
Source File: HistoryColorChooserPanel.java    From nextreports-designer with Apache License 2.0 5 votes vote down vote up
private JButton makeColorButton(String name) {
    JButton button = new JButton(name);
    button.setPreferredSize(btnDim);
    button.setMinimumSize(btnDim);
    button.setMaximumSize(btnDim);        
    button.setBorder(BorderFactory.createCompoundBorder(
            BorderFactory.createLineBorder(Color.WHITE),
            BorderFactory.createRaisedBevelBorder()));        
    button.setBackground(Color.GRAY);
    button.setEnabled(false);        
    return button;
}
 
Example 6
Source File: SkinSpecPanel.java    From megamek with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Used for BorderElements that have multiple entries, this method adds
 * a row of PathButton, Path text field, tiled checkbox and remove
 * button
 */
protected void addPathRow(String imgPath, boolean isTiled,
        boolean removeEnabled) {
    JButton newPathLbl = new JButton(
            Messages.getString("SkinEditor.Path")); //$NON-NLS-1$
    newPathLbl.setMargin(new Insets(1, 1, 1, 1));
    newPathLbl.setToolTipText(Messages.getString(
            "SkinEditor.PathToolTip", //$NON-NLS-1$
            new Object[] { Configuration.widgetsDir().getPath() }));
    newPathLbl.addActionListener(this);
    pathLbl.add(newPathLbl); //$NON-NLS-1$
    JTextField newPath = new JTextField(imgPath, TEXTFIELD_COLS);
    newPath.getDocument().addDocumentListener(this);
    path.add(newPath);
    JCheckBox newTiled = new JCheckBox(
            Messages.getString("SkinEditor.Tiled"), //$NON-NLS-1$
            isTiled);
    newTiled.setToolTipText(Messages
            .getString("SkinEditor.TiledToolTip")); //$NON-NLS-1$
    newTiled.addActionListener(this);
    tiled.add(newTiled);
    JButton newRemoveButton = new JButton(
            Messages.getString("SkinEditor.RemoveButton")); //$NON-NLS-1$
    newRemoveButton.setToolTipText(Messages
            .getString("SkinEditor.RemoveButtonToolTip")); //$NON-NLS-1$
    newRemoveButton.setMargin(new Insets(0, 0, 1, 0));
    newRemoveButton.setPreferredSize(new Dimension(14, 14));
    newRemoveButton.setMaximumSize(new Dimension(14, 14));
    newRemoveButton.setEnabled(removeEnabled);
    newRemoveButton.addActionListener(this);
    removeButtons.add(newRemoveButton);
}
 
Example 7
Source File: StandardButtonHelper.java    From OpERP with MIT License 5 votes vote down vote up
public static JButton SetStandardSizeForButton(JButton btn){
	btn.setMaximumSize(new Dimension(95, 95));
	btn.setMinimumSize(new Dimension(95,95));
	btn.setHorizontalTextPosition(SwingConstants.CENTER);
	btn.setVerticalTextPosition(SwingConstants.BOTTOM);
	btn.setFont(new Font("Arial", Font.PLAIN, 10));
	return btn;
}
 
Example 8
Source File: Help.java    From Scripts with GNU General Public License v3.0 5 votes vote down vote up
/** Returns a button w/ "maximized" width */
JButton plainButton(final String label) {
	final JButton button = new JButton(label);
	button.setMaximumSize(new Dimension(Integer.MAX_VALUE, button
			.getMinimumSize().height));
	return button;
}
 
Example 9
Source File: GUIOptionComponentBase.java    From PacketProxy with Apache License 2.0 5 votes vote down vote up
private JPanel createTableButton(ActionListener addAction, ActionListener editAction, ActionListener removeAction) {
	JPanel panel = new JPanel();

	JButton button_add = new JButton("Add");
	JButton button_edit = new JButton("Edit");
	JButton button_remove = new JButton("Remove");

	int height = button_add.getMinimumSize().height;

	button_add.setMaximumSize(new Dimension(100,height));
	button_edit.setMaximumSize(new Dimension(100,height));
	button_remove.setMaximumSize(new Dimension(100,height));

	if(null!=addAction) {
		panel.add(button_add);
		button_add.addActionListener(addAction);
	}

	if(null!=editAction) {
		panel.add(button_edit);
		button_edit.addActionListener(editAction);
	}

	if(null!=removeAction) {
		panel.add(button_remove);
		button_remove.addActionListener(removeAction);
	}

	panel.setLayout(new BoxLayout(panel, BoxLayout.Y_AXIS));
	panel.setBackground(Color.WHITE);
	panel.setMaximumSize(new Dimension(100, panel.getMinimumSize().height));
	panel.setAlignmentY(Component.TOP_ALIGNMENT);
	return panel;
}
 
Example 10
Source File: FatalErrorDialog.java    From launcher with BSD 2-Clause "Simplified" License 5 votes vote down vote up
public FatalErrorDialog addButton(String message, Runnable action)
{
	JButton button = new JButton(message);
	button.addActionListener(e -> action.run());
	button.setFont(font);
	button.setBackground(DARK_GRAY_COLOR);
	button.setForeground(Color.LIGHT_GRAY);
	button.setBorder(BorderFactory.createCompoundBorder(
		BorderFactory.createMatteBorder(1, 0, 0, 0, DARK_GRAY_COLOR.brighter()),
		new EmptyBorder(4, 4, 4, 4)
	));
	button.setAlignmentX(Component.CENTER_ALIGNMENT);
	button.setMaximumSize(new Dimension(Integer.MAX_VALUE, Integer.MAX_VALUE));
	button.setFocusPainted(false);
	button.addChangeListener(ev ->
	{
		if (button.getModel().isPressed())
		{
			button.setBackground(DARKER_GRAY_COLOR);
		}
		else if (button.getModel().isRollover())
		{
			button.setBackground(DARK_GRAY_HOVER_COLOR);
		}
		else
		{
			button.setBackground(DARK_GRAY_COLOR);
		}
	});

	rightColumn.add(button);
	rightColumn.revalidate();

	return this;
}
 
Example 11
Source File: EquipmentListJPanel.java    From defense-solutions-proofs-of-concept with Apache License 2.0 5 votes vote down vote up
/**
 * Sets the names of the equipment for which buttons should display.
 * @param equipmentNames the names of the equipment for which buttons should display.
 */
public void setEquipmentNames(List<String> equipmentNames) {
    removeAll();

    for (final String name : equipmentNames) {
        JButton button = new JButton(name) {
            @Override
            public void paint(Graphics g) {
                if (null == getIcon()) {
                    //Doing this here because it's expensive, so only
                    //do it when we actually need it.
                    setIcon(new ImageIcon(mil2525CSymbolController.getSymbolImage(name)));
                }
                super.paint(g);
            }
        };
        button.setFont(BUTTON_FONT);
        button.setHorizontalAlignment(SwingConstants.LEFT);
        button.setFocusable(false);
        button.setMaximumSize(new Dimension(Integer.MAX_VALUE, 60));
        button.setMinimumSize(new Dimension(0, 60));
        button.addActionListener(new ActionListener() {

            public void actionPerformed(ActionEvent e) {
                for (ActionListener listener : listeners) {
                    listener.actionPerformed(e);
                }
            }
        });
        add(button);
    }
}
 
Example 12
Source File: DungeonScrollBarUi.java    From dungeon with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
/**
 * This is a temporary solution to remove the buttons from BasicScrollBarUI.
 *
 * @return a JButton with all sizes set to zero
 */
private static JButton createZeroButton() {
  JButton button = new JButton();
  button.setPreferredSize(ZERO_DIMENSION);
  button.setMinimumSize(ZERO_DIMENSION);
  button.setMaximumSize(ZERO_DIMENSION);
  return button;
}
 
Example 13
Source File: RemoteTopologyPanel.java    From snap-desktop with GNU General Public License v3.0 5 votes vote down vote up
private static JButton buildButton(String resourceImagePath, ActionListener buttonListener, Dimension buttonSize) {
    ImageIcon icon = UIUtils.loadImageIcon(resourceImagePath);
    JButton button = new JButton(icon);
    button.setFocusable(false);
    button.addActionListener(buttonListener);
    button.setPreferredSize(buttonSize);
    button.setMinimumSize(buttonSize);
    button.setMaximumSize(buttonSize);
    return button;
}
 
Example 14
Source File: BasicReplaceResultsPanel.java    From netbeans with Apache License 2.0 5 votes vote down vote up
private void init() {
    JPanel leftPanel = new JPanel();
    replaceButton = new JButton();
    replaceButton.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            replace();
        }
    });
    updateReplaceButton();
    leftPanel.setLayout(new BoxLayout(leftPanel, BoxLayout.PAGE_AXIS));
    JPanel buttonPanel = new JPanel();
    buttonPanel.setLayout(new FlowLayout(FlowLayout.LEADING, 2, 1));
    buttonPanel.add(replaceButton);
    replaceButton.setMaximumSize(replaceButton.getPreferredSize());
    buttonPanel.setMaximumSize(new Dimension( // #225246
            (int) buttonPanel.getMaximumSize().getWidth(),
            (int) buttonPanel.getPreferredSize().getHeight()));
    leftPanel.add(resultsOutlineSupport.getOutlineView());
    leftPanel.add(buttonPanel);

    this.splitPane = new JSplitPane();
    splitPane.setLeftComponent(leftPanel);
    splitPane.setRightComponent(new ContextView(resultModel,
            getExplorerManager()));
    initSplitDividerLocationHandling();

    getContentPanel().add(splitPane);
    initResultModelListener();
    replaceButton.getAccessibleContext().setAccessibleDescription(
            NbBundle.getMessage(ResultView.class,
            "ACS_TEXT_BUTTON_REPLACE"));                            //NOI18N
}
 
Example 15
Source File: XDMScrollBarUI.java    From xdm with GNU General Public License v2.0 5 votes vote down vote up
protected JButton createZeroButton() {
	JButton button = new JButton();
	Dimension zeroDim = new Dimension(0, 0);
	button.setPreferredSize(zeroDim);
	button.setMinimumSize(zeroDim);
	button.setMaximumSize(zeroDim);
	return button;
}
 
Example 16
Source File: ToolAdapterTabbedEditorDialog.java    From snap-desktop with GNU General Public License v3.0 4 votes vote down vote up
private JButton renderInstallButton(org.esa.snap.core.gpf.descriptor.dependency.Bundle currentBundle,
                                 JPanel bundlePanel) {
    JButton installButton = new JButton() {
        @Override
        public void setText(String text) {
            super.setText(text);
            adjustDimension(this);
        }
    };
    installButton.setText((currentBundle.getLocation() == BundleLocation.REMOTE ?
            "Download and " :
            "") + "Install Now");
    installButton.setToolTipText(currentBundle.getLocation() == BundleLocation.REMOTE ?
                                         currentBundle.getDownloadURL() :
                                         currentBundle.getSource() != null ?
                                                 currentBundle.getSource().toString() : "");
    installButton.setMaximumSize(installButton.getPreferredSize());
    installButton.addActionListener((ActionEvent e) -> {
        newOperatorDescriptor.setBundles(bundleForm.applyChanges());
        org.esa.snap.core.gpf.descriptor.dependency.Bundle modifiedBundle = newOperatorDescriptor.getBundle();
        try (BundleInstaller installer = new BundleInstaller(newOperatorDescriptor)) {
            ProgressHandle progressHandle = ProgressHandleFactory.createSystemHandle("Installing bundle");
            installer.setProgressMonitor(new ProgressHandler(progressHandle, false));
            installer.setCallback(() -> {
                if (modifiedBundle.isInstalled()) {
                    Path path = newOperatorDescriptor.resolveVariables(modifiedBundle.getTargetLocation())
                            .toPath()
                            .resolve(FileUtils.getFilenameWithoutExtension(modifiedBundle.getEntryPoint()));
                    SwingUtilities.invokeLater(() -> {
                        progressHandle.finish();
                        Dialogs.showInformation(String.format("Bundle was installed in location:\n%s", path));
                        installButton.setVisible(false);
                        bundlePanel.revalidate();
                    });
                    String updateVariable = modifiedBundle.getUpdateVariable();
                    if (updateVariable != null) {
                        Optional<SystemVariable> variable = newOperatorDescriptor.getVariables()
                                .stream()
                                .filter(v -> v.getKey().equals(updateVariable))
                                .findFirst();
                        variable.ifPresent(systemVariable -> {
                            systemVariable.setShared(true);
                            systemVariable.setValue(path.toString());
                        });
                        varTable.revalidate();
                    }
                } else {
                    SwingUtilities.invokeLater(() -> {
                        progressHandle.finish();
                        Dialogs.showInformation("Bundle installation failed. \n" +
                                                        "Please see the application log for details.");
                        bundlePanel.revalidate();
                    });
                }
                return null;
            });
            installButton.setVisible(false);
            installer.install(true);
        } catch (Exception ex) {
            logger.warning(ex.getMessage());
        }
    });
    this.downloadAction = () -> {
        tabbedPane.setSelectedIndex(tabbedPane.getTabCount() - 1);
        installButton.requestFocusInWindow();
        installButton.doClick();
        return null;
    };
    installButton.setVisible(canInstall(currentBundle));
    return installButton;
}
 
Example 17
Source File: NetAdmin.java    From nullpomino with BSD 3-Clause "New" or "Revised" License 4 votes vote down vote up
/**
 * Init login screen
 */
private void initLoginUI() {
	// Main panel
	JPanel mpLoginOwner = new JPanel(new BorderLayout());
	this.getContentPane().add(mpLoginOwner, SCREENCARD_NAMES[SCREENCARD_LOGIN]);
	JPanel mpLogin = new JPanel();
	mpLogin.setLayout(new BoxLayout(mpLogin, BoxLayout.Y_AXIS));
	mpLoginOwner.add(mpLogin, BorderLayout.NORTH);

	// * Login Message label
	labelLoginMessage = new JLabel(getUIText("Login_Message_Default"));
	labelLoginMessage.setAlignmentX(0f);
	mpLogin.add(labelLoginMessage);

	// * Server panel
	JPanel spServer = new JPanel(new BorderLayout());
	spServer.setAlignmentX(0f);
	mpLogin.add(spServer);

	// ** Server label
	JLabel lServer = new JLabel(getUIText("Login_Server"));
	spServer.add(lServer, BorderLayout.WEST);

	// ** Server textbox
	txtfldServer = new JTextField(30);
	txtfldServer.setText(propConfig.getProperty("login.server", ""));
	txtfldServer.setComponentPopupMenu(new TextComponentPopupMenu(txtfldServer));
	spServer.add(txtfldServer, BorderLayout.EAST);

	// * Username panel
	JPanel spUsername = new JPanel(new BorderLayout());
	spUsername.setAlignmentX(0f);
	mpLogin.add(spUsername);

	// ** Username label
	JLabel lUsername = new JLabel(getUIText("Login_Username"));
	spUsername.add(lUsername, BorderLayout.WEST);

	// ** Username textbox
	txtfldUsername = new JTextField(30);
	txtfldUsername.setText(propConfig.getProperty("login.username", ""));
	txtfldUsername.setComponentPopupMenu(new TextComponentPopupMenu(txtfldUsername));
	spUsername.add(txtfldUsername, BorderLayout.EAST);

	// * Password panel
	JPanel spPassword = new JPanel(new BorderLayout());
	spPassword.setAlignmentX(0f);
	mpLogin.add(spPassword);

	// ** Password label
	JLabel lPassword = new JLabel(getUIText("Login_Password"));
	spPassword.add(lPassword, BorderLayout.WEST);

	// ** Password textbox
	passfldPassword = new JPasswordField(30);
	String strPassword = propConfig.getProperty("login.password", "");
	if(strPassword.length() > 0) {
		passfldPassword.setText(NetUtil.decompressString(strPassword));
	}
	passfldPassword.setComponentPopupMenu(new TextComponentPopupMenu(passfldPassword));
	spPassword.add(passfldPassword, BorderLayout.EAST);

	// * Remember Username checkbox
	chkboxRememberUsername = new JCheckBox(getUIText("Login_RememberUsername"));
	chkboxRememberUsername.setSelected(propConfig.getProperty("login.rememberUsername", false));
	chkboxRememberUsername.setAlignmentX(0f);
	mpLogin.add(chkboxRememberUsername);

	// * Remember Password checkbox
	chkboxRememberPassword = new JCheckBox(getUIText("Login_RememberPassword"));
	chkboxRememberPassword.setSelected(propConfig.getProperty("login.rememberPassword", false));
	chkboxRememberPassword.setAlignmentX(0f);
	mpLogin.add(chkboxRememberPassword);

	// * Buttons panel
	JPanel spButtons = new JPanel();
	spButtons.setLayout(new BoxLayout(spButtons, BoxLayout.X_AXIS));
	spButtons.setAlignmentX(0f);
	mpLogin.add(spButtons);

	// ** Login button
	btnLogin = new JButton(getUIText("Login_Login"));
	btnLogin.setMnemonic('L');
	btnLogin.setMaximumSize(new Dimension(Short.MAX_VALUE, btnLogin.getMaximumSize().height));
	btnLogin.setActionCommand("Login_Login");
	btnLogin.addActionListener(this);
	spButtons.add(btnLogin);

	// ** Quit button
	JButton btnQuit = new JButton(getUIText("Login_Quit"));
	btnQuit.setMnemonic('Q');
	btnQuit.setMaximumSize(new Dimension(Short.MAX_VALUE, btnQuit.getMaximumSize().height));
	btnQuit.setActionCommand("Login_Quit");
	btnQuit.addActionListener(this);
	spButtons.add(btnQuit);
}
 
Example 18
Source File: NullpoMinoSwing.java    From nullpomino with BSD 3-Clause "New" or "Revised" License 4 votes vote down vote up
/**
 * Init top screen
 */
protected void initTopScreenUI(JComponent p) {
	p.setLayout(new BoxLayout(p, BoxLayout.Y_AXIS));

	// Label
	lModeSelect = new JLabel(getUIText("Top_ModeSelect"));
	lModeSelect.setAlignmentX(0f);
	p.add(lModeSelect);

	// Mode & rule select panel
	JPanel subpanelModeSelect = new JPanel(new BorderLayout());
	subpanelModeSelect.setBorder(new EtchedBorder());
	subpanelModeSelect.setAlignmentX(0f);
	p.add(subpanelModeSelect);

	// * Mode select listbox
	listboxMode = new JList(modeList);
	listboxMode.addMouseListener(new ListboxModeMouseAdapter());
	listboxMode.addListSelectionListener(new ListSelectionListener() {
		public void valueChanged(ListSelectionEvent e) {
			String strMode = (String)listboxMode.getSelectedValue();
			lModeSelect.setText(getModeDesc(strMode));
			prepareRuleList(strMode);
		}
	});
	JScrollPane scpaneListboxMode = new JScrollPane(listboxMode);
	scpaneListboxMode.setPreferredSize(new Dimension(280, 375));
	subpanelModeSelect.add(scpaneListboxMode, BorderLayout.WEST);

	// * Rule select listbox
	listmodelRule = new DefaultListModel();
	listboxRule = new JList(listmodelRule);
	listboxRule.addMouseListener(new ListboxModeMouseAdapter());
	JScrollPane scpaneListBoxRule = new JScrollPane(listboxRule);
	scpaneListBoxRule.setPreferredSize(new Dimension(150, 375));
	subpanelModeSelect.add(scpaneListBoxRule, BorderLayout.CENTER);

	// * Set default selected index
	listboxMode.setSelectedValue(propGlobal.getProperty("name.mode", ""), true);
	if(listboxMode.getSelectedIndex() == -1) listboxMode.setSelectedIndex(0);
	prepareRuleList((String)listboxMode.getSelectedValue());

	// Start button
	JButton buttonStartOffline = new JButton(getUIText("Top_StartOffline"));
	buttonStartOffline.setMnemonic('S');
	buttonStartOffline.addActionListener(this);
	buttonStartOffline.setActionCommand("Top_StartOffline");
	buttonStartOffline.setAlignmentX(0f);
	buttonStartOffline.setMaximumSize(new Dimension(Short.MAX_VALUE, buttonStartOffline.getMaximumSize().height));
	p.add(buttonStartOffline);
	this.getRootPane().setDefaultButton(buttonStartOffline);

	// Menu
	initMenu();
}
 
Example 19
Source File: AbstractUndoableMovesPanel.java    From triplea with GNU General Public License v3.0 4 votes vote down vote up
protected void setSize(final Dimension buttonSize, final JButton cancelButton) {
  cancelButton.setMinimumSize(buttonSize);
  cancelButton.setPreferredSize(buttonSize);
  cancelButton.setMaximumSize(buttonSize);
}
 
Example 20
Source File: AISelectFrame.java    From nullpomino with BSD 3-Clause "New" or "Revised" License 4 votes vote down vote up
/**
 * GUIAInitialization
 */
protected void initUI() {
	this.getContentPane().setLayout(new BoxLayout(this.getContentPane(), BoxLayout.Y_AXIS));

	// AIList
	JPanel panelAIList = new JPanel();
	panelAIList.setLayout(new BorderLayout());
	panelAIList.setAlignmentX(LEFT_ALIGNMENT);
	this.add(panelAIList);

	String[] strList = new String[aiPathList.length];
	for(int i = 0; i < strList.length; i++) {
		strList[i] = aiNameList[i] + " (" + aiPathList[i] + ")";
	}
	listboxAI = new JList(strList);

	JScrollPane scpaneAI = new JScrollPane(listboxAI);
	scpaneAI.setPreferredSize(new Dimension(400, 250));
	panelAIList.add(scpaneAI, BorderLayout.CENTER);

	JButton btnNoUse = new JButton(NullpoMinoSwing.getUIText("AISelect_NoUse"));
	btnNoUse.setMnemonic('N');
	btnNoUse.addActionListener(this);
	btnNoUse.setActionCommand("AISelect_NoUse");
	btnNoUse.setMaximumSize(new Dimension(Short.MAX_VALUE, 30));
	panelAIList.add(btnNoUse, BorderLayout.SOUTH);

	// AIText box of the movement interval
	JPanel panelTxtfldAIMoveDelay = new JPanel();
	panelTxtfldAIMoveDelay.setLayout(new BorderLayout());
	panelTxtfldAIMoveDelay.setAlignmentX(LEFT_ALIGNMENT);
	this.add(panelTxtfldAIMoveDelay);

	panelTxtfldAIMoveDelay.add(new JLabel(NullpoMinoSwing.getUIText("AISelect_LabelAIMoveDelay")), BorderLayout.WEST);

	txtfldAIMoveDelay = new JTextField(20);
	panelTxtfldAIMoveDelay.add(txtfldAIMoveDelay, BorderLayout.EAST);

	// AIText box of the movement interval
	JPanel panelTxtfldAIThinkDelay = new JPanel();
	panelTxtfldAIThinkDelay.setLayout(new BorderLayout());
	panelTxtfldAIThinkDelay.setAlignmentX(LEFT_ALIGNMENT);
	this.add(panelTxtfldAIThinkDelay);

	panelTxtfldAIThinkDelay.add(new JLabel(NullpoMinoSwing.getUIText("AISelect_LabelAIThinkDelay")), BorderLayout.WEST);

	txtfldAIThinkDelay = new JTextField(20);
	panelTxtfldAIThinkDelay.add(txtfldAIThinkDelay, BorderLayout.EAST);

	// AIThread use check Box
	chkboxAIUseThread = new JCheckBox(NullpoMinoSwing.getUIText("AISelect_CheckboxAIUseThread"));
	chkboxAIUseThread.setAlignmentX(LEFT_ALIGNMENT);
	chkboxAIUseThread.setMnemonic('T');
	this.add(chkboxAIUseThread);

	chkBoxAIShowHint = new JCheckBox(NullpoMinoSwing.getUIText("AISelect_CheckboxAIShowHint"));
	chkBoxAIShowHint.setAlignmentX(LEFT_ALIGNMENT);
	chkBoxAIShowHint.setMnemonic('H');
	this.add(chkBoxAIShowHint);

	chkBoxAIPrethink = new JCheckBox(NullpoMinoSwing.getUIText("AISelect_CheckboxAIPrethink"));
	chkBoxAIPrethink.setAlignmentX(LEFT_ALIGNMENT);
	chkBoxAIPrethink.setMnemonic('P');
	this.add(chkBoxAIPrethink);

	chkBoxAIShowState = new JCheckBox(NullpoMinoSwing.getUIText("AISelect_CheckboxAIShowState"));
	chkBoxAIShowState.setAlignmentX(LEFT_ALIGNMENT);
	chkBoxAIShowState.setMnemonic('S');
	this.add(chkBoxAIShowState);

	//  buttonKind
	JPanel panelButtons = new JPanel();
	panelButtons.setLayout(new BoxLayout(panelButtons, BoxLayout.X_AXIS));
	panelButtons.setAlignmentX(LEFT_ALIGNMENT);
	this.add(panelButtons);

	JButton btnOK = new JButton(NullpoMinoSwing.getUIText("AISelect_OK"));
	btnOK.setMnemonic('O');
	btnOK.addActionListener(this);
	btnOK.setActionCommand("AISelect_OK");
	btnOK.setAlignmentX(LEFT_ALIGNMENT);
	btnOK.setMaximumSize(new Dimension(Short.MAX_VALUE, 30));
	panelButtons.add(btnOK);
	this.getRootPane().setDefaultButton(btnOK);

	JButton btnCancel = new JButton(NullpoMinoSwing.getUIText("AISelect_Cancel"));
	btnCancel.setMnemonic('C');
	btnCancel.addActionListener(this);
	btnCancel.setActionCommand("AISelect_Cancel");
	btnCancel.setAlignmentX(LEFT_ALIGNMENT);
	btnCancel.setMaximumSize(new Dimension(Short.MAX_VALUE, 30));
	panelButtons.add(btnCancel);
}