Java Code Examples for javax.swing.JButton#setAlignmentX()
The following examples show how to use
javax.swing.JButton#setAlignmentX() .
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: TablePrintDemo.java From marathonv5 with Apache License 2.0 | 6 votes |
public TablePrintDemo() { super(); setLayout(new BoxLayout(this, BoxLayout.Y_AXIS)); table = new JTable(new MyTableModel()); table.setPreferredScrollableViewportSize(new Dimension(500, 70)); table.setFillsViewportHeight(true); // Create the scroll pane and add the table to it. JScrollPane scrollPane = new JScrollPane(table); // Add the scroll pane to this panel. add(scrollPane); // Add a print button. JButton printButton = new JButton("Print"); printButton.setAlignmentX(Component.CENTER_ALIGNMENT); printButton.addActionListener(this); add(printButton); }
Example 2
Source File: SignIn.java From dctb-utfpr-2018-1 with Apache License 2.0 | 6 votes |
public JButton styleButtons(){ JButton submit = new JButton(); Color colorForeground = new Color(0x8D8D8D); Color colorBackground = new Color(0xF1F1F1); submit.setForeground(colorForeground); submit.setBackground(colorBackground); Border line = new LineBorder(colorForeground); Border margin = new EmptyBorder(5, 15, 5, 15); Border compound = new CompoundBorder(line, margin); submit.setBorder(compound); submit.setAlignmentX(Component.CENTER_ALIGNMENT); return submit; }
Example 3
Source File: FatalErrorDialog.java From launcher with BSD 2-Clause "Simplified" License | 5 votes |
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 4
Source File: KeyConfigure.java From tn5250j with GNU General Public License v2.0 | 5 votes |
private JButton addOptButton(String text, String ac, Container container, boolean enabled) { JButton button = new JButton(text); button.setEnabled(enabled); button.setActionCommand(ac); button.addActionListener(this); button.setAlignmentX(Component.CENTER_ALIGNMENT); container.add(button); return button; }
Example 5
Source File: FatalErrorDialog.java From runelite with BSD 2-Clause "Simplified" License | 5 votes |
public FatalErrorDialog addButton(String message, Runnable action) { JButton button = new JButton(message); button.addActionListener(e -> action.run()); button.setFont(font); button.setBackground(ColorScheme.DARK_GRAY_COLOR); button.setForeground(Color.LIGHT_GRAY); button.setBorder(BorderFactory.createCompoundBorder( BorderFactory.createMatteBorder(1, 0, 0, 0, ColorScheme.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(ColorScheme.DARKER_GRAY_COLOR); } else if (button.getModel().isRollover()) { button.setBackground(ColorScheme.DARK_GRAY_HOVER_COLOR); } else { button.setBackground(ColorScheme.DARK_GRAY_COLOR); } }); rightColumn.add(button); rightColumn.revalidate(); return this; }
Example 6
Source File: Operation.java From cstc with GNU General Public License v3.0 | 5 votes |
private JButton createIconButton(ImageIcon icon) { JButton btn = new JButton(); btn.setBorder(BorderFactory.createEmptyBorder()); btn.setIcon(icon); btn.setContentAreaFilled(false); btn.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR)); btn.setAlignmentX(Component.RIGHT_ALIGNMENT); return btn; }
Example 7
Source File: FormUtils.java From jdal with Apache License 2.0 | 5 votes |
/** * Get Default OK Button from LookAndFeel (like JOptionPane) */ public static JButton newOKButton() { String text = StaticMessageSource.getMessage("Accept"); int mnemonic = getMnemonic("OptionPane.okButtonMnemonic"); JButton b = new JButton(text, OK_ICON); b.setMnemonic(mnemonic); b.setAlignmentX(Container.CENTER_ALIGNMENT); b.setAlignmentY(Container.CENTER_ALIGNMENT); return b; }
Example 8
Source File: ScreenshotComponent.java From netbeans with Apache License 2.0 | 5 votes |
private JButton createZoomOrigButton() { JButton origButton = new JButton(NbBundle.getMessage(ScreenshotComponent.class, "LBL_ZoomOrig")); origButton.setToolTipText(NbBundle.getMessage(ScreenshotComponent.class, "TLTP_ZoomOrig")); origButton.getAccessibleContext().setAccessibleDescription(NbBundle.getMessage(ScreenshotComponent.class, "LBL_ZoomOrigA11yDescr")); origButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { canvas.zoom(1); } }); origButton.setAlignmentX(CENTER_ALIGNMENT); return origButton; }
Example 9
Source File: ScreenshotComponent.java From netbeans with Apache License 2.0 | 5 votes |
private JButton createZoomOutButton() { JButton outButton = new JButton(ImageUtilities.image2Icon(ImageUtilities.loadImage("org/netbeans/modules/debugger/jpda/visual/resources/zoomOut.gif"))); outButton.setToolTipText(NbBundle.getMessage(ScreenshotComponent.class, "TLTP_ZoomOut")); outButton.getAccessibleContext().setAccessibleDescription(NbBundle.getMessage(ScreenshotComponent.class, "LBL_ZoomOutA11yDescr")); outButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { canvas.zoomOut(); } }); outButton.setAlignmentX(CENTER_ALIGNMENT); return outButton; }
Example 10
Source File: ScreenshotComponent.java From netbeans with Apache License 2.0 | 5 votes |
private JButton createZoomInButton() { JButton inButton = new JButton(ImageUtilities.image2Icon(ImageUtilities.loadImage("org/netbeans/modules/debugger/jpda/visual/resources/zoomIn.gif"))); inButton.setToolTipText(NbBundle.getMessage(ScreenshotComponent.class, "TLTP_ZoomIn")); inButton.getAccessibleContext().setAccessibleDescription(NbBundle.getMessage(ScreenshotComponent.class, "LBL_ZoomInA11yDescr")); inButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { canvas.zoomIn(); } }); inButton.setAlignmentX(CENTER_ALIGNMENT); return inButton; }
Example 11
Source File: SignIn.java From dctb-utfpr-2018-1 with Apache License 2.0 | 5 votes |
public JButton styleButtons(){ JButton submit = new JButton(); Color colorForeground = new Color(0x8D8D8D); Color colorBackground = new Color(0xF1F1F1); submit.setForeground(colorForeground); submit.setBackground(colorBackground); Border line = new LineBorder(colorForeground); Border margin = new EmptyBorder(5, 15, 5, 15); Border compound = new CompoundBorder(line, margin); submit.setBorder(compound); submit.setAlignmentX(Component.CENTER_ALIGNMENT); return submit; }
Example 12
Source File: SettingsDialog.java From stendhal with GNU General Public License v2.0 | 5 votes |
/** * Create a new SettingsDialog. * * @param parent parent window, or <code>null</code> */ public SettingsDialog(Frame parent) { super(parent, "Settings"); setDefaultCloseOperation(DISPOSE_ON_CLOSE); int pad = SBoxLayout.COMMON_PADDING; setLayout(new SBoxLayout(SBoxLayout.VERTICAL, pad)); JTabbedPane tabs = new JTabbedPane(); add(tabs); tabs.add("General", new GeneralSettings().getComponent()); tabs.add("Visuals", new VisualSettings().getComponent()); tabs.add("Sound", new SoundSettings().getComponent()); setResizable(false); JButton closeButton = new JButton("Close"); closeButton.setAlignmentX(RIGHT_ALIGNMENT); closeButton.setBorder(BorderFactory.createCompoundBorder(BorderFactory.createEmptyBorder(pad, pad, pad, pad), closeButton.getBorder())); closeButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent arg0) { dispose(); } }); add(closeButton); WindowUtils.closeOnEscape(this); WindowUtils.watchFontSize(this); WindowUtils.trackLocation(this, "settings", false); pack(); }
Example 13
Source File: GeneralSettings.java From stendhal with GNU General Public License v2.0 | 4 votes |
/** * Create new GeneralSettings. */ GeneralSettings() { int pad = SBoxLayout.COMMON_PADDING; page = SBoxLayout.createContainer(SBoxLayout.VERTICAL, pad); page.setBorder(BorderFactory.createEmptyBorder(pad, pad, pad, pad)); // click mode JCheckBox clickModeToggle = SettingsComponentFactory.createSettingsToggle(DOUBLE_CLICK_PROPERTY, false, "Double Click Mode", "Move and attack with double click. If not checked, a single click is enough."); page.add(clickModeToggle); // raising corpses JCheckBox autoRaiseToggle = SettingsComponentFactory.createSettingsToggle(GAMESCREEN_AUTORAISECORPSE, true, "Auto inspect corpses", "Automatically open the loot window for corpses of creatures you can loot"); page.add(autoRaiseToggle); // show healing messages JCheckBox showHealingToggle = SettingsComponentFactory.createSettingsToggle(HEALING_MESSAGE_PROPERTY, false, "Show healing messages", "Show healing messages in the chat log"); page.add(showHealingToggle); // show poison messages JCheckBox showPoisonToggle = SettingsComponentFactory.createSettingsToggle(POISON_MESSAGE_PROPERTY, false, "Show poison messages", "Show poisoned messages in the chat log"); page.add(showPoisonToggle); // Double-tap direction for auto-walk JCheckBox doubleTapAutowalkToggle = SettingsComponentFactory.createSettingsToggle(DOUBLE_TAP_AUTOWALK_PROPERTY, false, "Double-tap direction for auto-walk (experimental)", "Initiates auto-walk when direction key is double-tapped"); page.add(doubleTapAutowalkToggle); // Continuous movement final JCheckBox moveContinuousToggle = SettingsComponentFactory.createSettingsToggle(MOVE_CONTINUOUS_PROPERTY, false, "Continuous movement", "Change maps and pass through portals without stopping"); moveContinuousToggle.addActionListener(new ActionListener() { @Override public void actionPerformed(final ActionEvent e) { new MoveContinuousAction().sendAction(moveContinuousToggle.isSelected()); } }); WtWindowManager.getInstance().registerSettingChangeListener(MOVE_CONTINUOUS_PROPERTY, new SettingChangeListener() { @Override public void changed(String newValue) { moveContinuousToggle.setSelected(Boolean.parseBoolean(newValue)); } }); page.add(moveContinuousToggle); // combat karma page.add(createCombatKarmaSelector()); // Client dimensions JComponent clientSizeBox = SBoxLayout.createContainer(SBoxLayout.VERTICAL, pad); TitledBorder titleB = BorderFactory.createTitledBorder(BorderFactory.createEtchedBorder(), "Client Dimensions"); // There seems to be no good way to change the default background color // of all components. The color is needed for making the etched border. Style style = StyleUtil.getStyle(); if (style != null) { clientSizeBox.setBackground(style.getPlainColor()); titleB.setTitleColor(style.getForeground()); } clientSizeBox.setBorder(BorderFactory.createCompoundBorder(titleB, BorderFactory.createEmptyBorder(pad, pad, pad, pad))); // Save client dimensions JCheckBox saveDimensionsToggle = SettingsComponentFactory.createSettingsToggle( DIMENSIONS_PROPERTY, true, "Save size", "Restores the client's width, height, and maximized state in future sessions"); clientSizeBox.add(saveDimensionsToggle); // Reset client window to default dimensions JButton resetDimensions = new JButton("Reset"); resetDimensions.setToolTipText( "Resets the client's width and height to their default dimensions"); resetDimensions.setActionCommand("reset_dimensions"); resetDimensions.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent arg0) { resetClientDimensions(); } }); resetDimensions.setAlignmentX(Component.RIGHT_ALIGNMENT); clientSizeBox.add(resetDimensions); page.add(clientSizeBox, SLayout.EXPAND_X); }
Example 14
Source File: DumpDatabase.java From DKO with GNU Lesser General Public License v2.1 | 4 votes |
public static void buildCard2() { JPanel card = new JPanel(); card.setLayout(new BoxLayout(card, BoxLayout.Y_AXIS)); JLabel title = new JLabel("Where would you like to dump to?"); title.setAlignmentX(Component.CENTER_ALIGNMENT); title.setBorder(new EmptyBorder(15, 20, 15, 20)); card.add(title); final JFileChooser fc = new JFileChooser(); fc.setSelectedFile(new File("test2.db")); final JButton open = new JButton("Select a SQLite3 File..."); open.setAlignmentX(Component.CENTER_ALIGNMENT); card.add(open); final JLabel fnLabel = new JLabel(); fnLabel.setAlignmentX(Component.CENTER_ALIGNMENT); fnLabel.setBorder(new EmptyBorder(15, 20, 15, 20)); card.add(fnLabel); final NextListener nexter = new NextListener() { @Override public void goNext() { cardStack.add(CARD_3); cl.show(cards, CARD_3); } @Override public void show() { next.setVisible(true); finish.setVisible(false); next.setEnabled(fc.getSelectedFile() != null); file = fc.getSelectedFile(); if (file == null) { fnLabel.setText(""); } else { fnLabel.setText(file.getName() + (file.exists() ? "" : " (new)")); } } }; open.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { int returnVal = fc.showOpenDialog(open); if (returnVal == JFileChooser.APPROVE_OPTION) { } nexter.show(); } }); cards.add(card, CARD_2); nexters.put(CARD_2, nexter); }
Example 15
Source File: AISelectFrame.java From nullpomino with BSD 3-Clause "New" or "Revised" License | 4 votes |
/** * 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); }
Example 16
Source File: UnitScroller.java From triplea with GNU General Public License v3.0 | 4 votes |
/** Constructs a UI component for the UnitScroller. */ public Component build() { final JPanel panel = new JPanel(); collapsiblePanel = new CollapsiblePanel(panel, ""); updateMovesLeft(); panel.setLayout(new BoxLayout(panel, BoxLayout.Y_AXIS)); panel.add(selectUnitImagePanel); panel.add(territoryNameLabel); panel.add(Box.createVerticalStrut(2)); final JButton prevUnit = new JButton(UnitScrollerIcon.LEFT_ARROW.get()); prevUnit.setToolTipText(PREVIOUS_UNITS_TOOLTIP); prevUnit.setAlignmentX(JComponent.CENTER_ALIGNMENT); prevUnit.addActionListener(e -> centerOnPreviousMovableUnit()); final JButton sleepButton = new JButton(UnitScrollerIcon.SLEEP.get()); sleepButton.setToolTipText(SLEEP_UNITS_TOOLTIP); sleepButton.addActionListener(e -> sleepCurrentUnits()); final JButton skipButton = new JButton(UnitScrollerIcon.SKIP.get()); skipButton.setToolTipText(SKIP_UNITS_TOOLTIP); skipButton.addActionListener(e -> skipCurrentUnits()); final JButton wakeAllButton = new JButton(UnitScrollerIcon.WAKE_ALL.get()); wakeAllButton.setToolTipText(WAKE_ALL_TOOLTIP); wakeAllButton.addActionListener(e -> wakeAllUnits()); wakeAllButton.setFocusable(false); final JButton nextUnit = new JButton(UnitScrollerIcon.RIGHT_ARROW.get()); nextUnit.setToolTipText(NEXT_UNITS_TOOLTIP); nextUnit.addActionListener(e -> centerOnNextMovableUnit()); final JPanel skipAndSleepPanel = new JPanelBuilder() .boxLayoutHorizontal() .add(prevUnit) .addHorizontalStrut(HORIZONTAL_BUTTON_GAP) .add(wakeAllButton) .addHorizontalStrut(HORIZONTAL_BUTTON_GAP) .add(sleepButton) .addHorizontalStrut(HORIZONTAL_BUTTON_GAP) .add(skipButton) .addHorizontalStrut(HORIZONTAL_BUTTON_GAP) .add(nextUnit) .build(); skipAndSleepPanel.setAlignmentX(JComponent.CENTER_ALIGNMENT); panel.add(skipAndSleepPanel, BorderLayout.SOUTH); panel.add(Box.createVerticalStrut(3)); return collapsiblePanel; }
Example 17
Source File: MapCreator.java From triplea with GNU General Public License v3.0 | 4 votes |
private MapCreator() { super("TripleA Map Creator"); setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE); // components mainPanel = new JPanel(); final JPanel sidePanel = new JPanel(); final JButton part1 = new JButton("Step 1: Map Properties"); final JButton part2 = new JButton("Step 2: Map Utilities"); final JButton part3 = new JButton("Step 3: Game XML"); final JButton part4 = new JButton("Other: Optional Things"); sidePanel.setLayout(new BoxLayout(sidePanel, BoxLayout.PAGE_AXIS)); sidePanel.add(Box.createVerticalGlue()); sidePanel.add(part1); part1.setAlignmentX(Component.CENTER_ALIGNMENT); sidePanel.add(Box.createVerticalGlue()); sidePanel.add(part2); part2.setAlignmentX(Component.CENTER_ALIGNMENT); sidePanel.add(Box.createVerticalGlue()); sidePanel.add(part3); part3.setAlignmentX(Component.CENTER_ALIGNMENT); sidePanel.add(Box.createVerticalGlue()); sidePanel.add(part4); part4.setAlignmentX(Component.CENTER_ALIGNMENT); sidePanel.add(Box.createVerticalGlue()); createPart1Panel(); createPart2Panel(); createPart3Panel(); createPart4Panel(); part1.addActionListener(SwingAction.of("Part 1", e -> setupMainPanel(panel1))); part2.addActionListener(SwingAction.of("Part 2", e -> setupMainPanel(panel2))); part3.addActionListener(SwingAction.of("Part 3", e -> setupMainPanel(panel3))); part4.addActionListener(SwingAction.of("Part 4", e -> setupMainPanel(panel4))); // set up the menu actions final Action closeAction = SwingAction.of("Close", e -> dispose()); closeAction.putValue(Action.SHORT_DESCRIPTION, "Close Window"); // set up the menu items final JMenuItem exitItem = new JMenuItem(closeAction); // set up the menu bar final JMenuBar menuBar = new JMenuBar(); setJMenuBar(menuBar); final JMenu fileMenu = new JMenu("File"); fileMenu.setMnemonic('F'); fileMenu.addSeparator(); fileMenu.add(exitItem); menuBar.add(fileMenu); // set up the layout manager this.getContentPane().setLayout(new BorderLayout()); this.getContentPane().add(new JScrollPane(sidePanel), BorderLayout.WEST); this.getContentPane().add(new JScrollPane(mainPanel), BorderLayout.CENTER); // now set up the main screen setupMainPanel(panel1); }
Example 18
Source File: JRParameterEditorDialog.java From jdal with Apache License 2.0 | 4 votes |
public void initialize() { this.setTitle("ParĂ¡metros del informe"); // Main Panel containing parameter panel and button panel. JPanel borderPanel = new JPanel(); borderPanel.setBorder(BorderFactory.createTitledBorder("")); borderPanel.setMinimumSize(borderPanel.getPreferredSize()); borderPanel.setLayout(new BorderLayout()); // Button Panel JPanel buttonPanel = new JPanel(); JButton acceptButton = new JButton(new AcceptAction()); acceptButton.setText("Aceptar"); JButton cancelButton = new JButton(new CancelAction()); cancelButton.setText("Cancelar"); acceptButton.setAlignmentX(Component.CENTER_ALIGNMENT); cancelButton.setAlignmentX(Component.CENTER_ALIGNMENT); buttonPanel.add(acceptButton); buttonPanel.add(cancelButton); // Parameter panel JPanel paramPanel = new JPanel(new SpringLayout()); for (JRParameter param : parameters.values()) { ReportParameterEditor propertyEditor = editorFactory .getParameterEditor(param); propertyEditor.getEditor().addKeyListener(new KeyPressed()); JLabel label = new JLabel(param.getName()); label.setLabelFor(propertyEditor.getEditor()); paramPanel.add(label); paramPanel.add(propertyEditor.getEditor()); editors.put(param.getName(), propertyEditor); } borderPanel.add(paramPanel, BorderLayout.PAGE_START); borderPanel.add(buttonPanel, BorderLayout.PAGE_END); SpringUtilities.makeCompactGrid(paramPanel, parameters.size(), 2, // rows, // cols 6, 6, // initX, initY 6, 6); // xPad, yPad add(borderPanel); setLocationRelativeTo(null); pack(); }
Example 19
Source File: ProgressLog.java From stendhal with GNU General Public License v2.0 | 4 votes |
/** * Create a new page. */ Page() { this.setLayout(new SBoxLayout(SBoxLayout.VERTICAL)); JComponent panels = SBoxLayout.createContainer(SBoxLayout.HORIZONTAL, SBoxLayout.COMMON_PADDING); add(panels, SBoxLayout.constraint(SLayout.EXPAND_X, SLayout.EXPAND_Y)); indexArea = new PrettyEditorPane(); indexArea.addHyperlinkListener(this); indexScrollPane = new JScrollPane(indexArea); // Fixed width indexScrollPane.setMaximumSize(new Dimension(INDEX_WIDTH, Integer.MAX_VALUE)); indexScrollPane.setMinimumSize(new Dimension(INDEX_WIDTH, 0)); // Turn off caret following Caret caret = indexArea.getCaret(); if (caret instanceof DefaultCaret) { ((DefaultCaret) caret).setUpdatePolicy(DefaultCaret.NEVER_UPDATE); } panels.add(indexScrollPane, SLayout.EXPAND_Y); contentArea = new PrettyEditorPane(); // Does not need a listener. There should be no links contentScrollPane = new JScrollPane(contentArea); panels.add(contentScrollPane, SBoxLayout.constraint(SLayout.EXPAND_X, SLayout.EXPAND_Y)); JComponent buttonBox = SBoxLayout.createContainer(SBoxLayout.HORIZONTAL, SBoxLayout.COMMON_PADDING); buttonBox.setAlignmentX(RIGHT_ALIGNMENT); buttonBox.setBorder(BorderFactory.createEmptyBorder(SBoxLayout.COMMON_PADDING, 0, SBoxLayout.COMMON_PADDING, SBoxLayout.COMMON_PADDING)); add(buttonBox); // A button for reloading the page contents JButton refresh = new JButton("Update"); refresh.setMnemonic(KeyEvent.VK_U); refresh.setAlignmentX(Component.RIGHT_ALIGNMENT); refresh.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent event) { update(); } }); buttonBox.add(refresh); JButton closeButton = new JButton("Close"); closeButton.setMnemonic(KeyEvent.VK_C); closeButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { getWindow().dispose(); } }); buttonBox.add(closeButton); }
Example 20
Source File: ConfigWindow.java From rscplus with GNU General Public License v3.0 | 3 votes |
/** * Adds a preconfigured JButton to the specified container using the specified alignment * constraint. Does not modify the button's border. * * @param text The text of the button * @param container The container to add the button to * @param alignment The alignment of the button. * @return The newly created JButton. */ private JButton addButton(String text, Container container, float alignment) { JButton button = new JButton(text); button.setAlignmentX(alignment); container.add(button); return button; }