Java Code Examples for javax.swing.Box#setMaximumSize()
The following examples show how to use
javax.swing.Box#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: TableEditor.java From jdal with Apache License 2.0 | 5 votes |
/** * Creates a new Box with table and actions buttons * @return a new Box */ protected Container createTablePanel() { table = new JTable(tableModel, tableModel.getTableColumnModel()); table.setRowHeight(22); table.setAutoCreateRowSorter(true); tableModel.addTableModelListener(this); JScrollPane scroll = new JScrollPane(table); scroll.setAlignmentX(Container.LEFT_ALIGNMENT); Box box = Box.createVerticalBox(); JButton addButton = new JButton(new AddAction()); JButton deleteButton = new JButton(new DeleteAction()); JButton saveButton = new JButton(new SaveAction()); JButton refreshButton = new JButton(new RefreshAction()); Box buttonBox = Box.createHorizontalBox(); buttonBox.add(addButton); buttonBox.add(Box.createHorizontalStrut(5)); buttonBox.add(deleteButton); buttonBox.add(Box.createHorizontalStrut(5)); buttonBox.add(saveButton); buttonBox.add(Box.createHorizontalStrut(5)); buttonBox.add(refreshButton); buttonBox.setAlignmentX(Container.LEFT_ALIGNMENT); buttonBox.setMaximumSize(new Dimension(Short.MAX_VALUE, 25)); box.add(buttonBox); box.add(Box.createVerticalStrut(5)); box.add(scroll); return box; }
Example 2
Source File: TransitionDialog.java From SikuliX1 with MIT License | 4 votes |
void init(String text){ setBackground(Color.yellow); setForeground(Color.black); JPanel content = new JPanel(); content.setLayout(new BoxLayout(content, BoxLayout.Y_AXIS)); add(content); textPane = new TextPane(); textPane.setText(text); textPane.setBorder(BorderFactory.createEmptyBorder(3, 5, 3, 5)); Color darkyellow = new Color(238,185,57); titleBar = new JLabel(); titleBar.setFont(new Font("sansserif", Font.BOLD, 14)); titleBar.setBackground(darkyellow); titleBar.setOpaque(true); titleBar.setBorder(BorderFactory.createEmptyBorder(5, 5, 3, 5)); titleBar.setSize(titleBar.getPreferredSize()); titleBar.setVisible(false); buttons = new Box(BoxLayout.X_AXIS); defaultButton = new Button("Close"); buttons.add(defaultButton); buttons.setBorder(BorderFactory.createEmptyBorder(15,5,5,5)); content.add(titleBar); content.add(textPane); content.add(buttons); // this allows the title bar to take the whole width of the dialog box titleBar.setMaximumSize(new Dimension(Integer.MAX_VALUE,Integer.MAX_VALUE)); buttons.setMaximumSize(new Dimension(Integer.MAX_VALUE,Integer.MAX_VALUE)); textPane.setMaximumSize(new Dimension(Integer.MAX_VALUE,Integer.MAX_VALUE)); // these allow all the parts to left aligned titleBar.setAlignmentX(Component.LEFT_ALIGNMENT); textPane.setAlignmentX(Component.LEFT_ALIGNMENT); buttons.setAlignmentX(Component.LEFT_ALIGNMENT); // these are meant to prevent the message box from stealing // focus when it's clicked, but they don't seem to work // setFocusableWindowState(false); // setFocusable(false); // this allows the window to be dragged to another location on the screen ComponentMover cm = new ComponentMover(); cm.registerComponent(this); pack(); }
Example 3
Source File: SimpleBoxFormBuilder.java From jdal with Apache License 2.0 | 4 votes |
/** * Builds the panel form. * @return the form component */ public JComponent getForm() { // set sizes; int columnHeight= 0; for (int h : rowsHeight) columnHeight += h; // add space into components (fillers) columnHeight += (rows -1) * defaultSpace; for (int i = 0; i < columns.size(); i++) { Box box = columns.get(i); int maxWidth = columnsWidth.get(i) == 0 ? Short.MAX_VALUE : columnsWidth.get(i); box.setMaximumSize(new Dimension(maxWidth, columnHeight)); if (maxWidth < Short.MAX_VALUE && columnHeight < Short.MAX_VALUE) { box.setMinimumSize(new Dimension(maxWidth, columnHeight)); box.setPreferredSize(new Dimension(maxWidth, columnHeight)); } } container.setFocusTraversalPolicy(focusTransversal); container.setFocusTraversalPolicyProvider(true); container.setSize(Short.MAX_VALUE, columnHeight); if (isFixedHeight()) { Dimension maxSize = new Dimension(Short.MAX_VALUE, columnHeight); if (container.isMaximumSizeSet()) { maxSize = container.getMaximumSize(); maxSize.height = columnHeight; } container.setMaximumSize(maxSize); } if (isDebug()) container.setBorder(BorderFactory.createLineBorder(Color.BLUE)); if (border != null) container.setBorder(border); return container; }