/** * Initialisationsmethode, die in jedem Konstruktor benutzt wird * @param layout * @param panels */ void initialize(LayoutManager layout, ArrayList<JPanel> panels){ this.setLayout(layout); for(JPanel panel: panels){ this.add(panel); } this.setTitle("Random Music Generator Canon"); this.setSize(1200, 700); //places Frame in the middle of the screen this.setLocationRelativeTo(null); this.setResizable(true); this.setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE); this.addWindowListener(new defaultWindowListener()); //adjusting look to local system try { UIManager.setLookAndFeel( UIManager.getSystemLookAndFeelClassName() ); } catch (ClassNotFoundException | InstantiationException | IllegalAccessException | UnsupportedLookAndFeelException e) { e.printStackTrace(); } //shows the Frame on the screen this.setVisible(true); }
public GridBagInfoProvider(Container container, LayoutSupportManager layoutManager) { this.container = container; this.layoutManager = layoutManager; LayoutManager containerLayout = container.getLayout(); if (!(containerLayout instanceof GridBagLayout)) { throw new IllegalArgumentException(); } try { tempXField = GridBagConstraints.class.getDeclaredField("tempX"); // NOI18N tempXField.setAccessible(true); tempYField = GridBagConstraints.class.getDeclaredField("tempY"); // NOI18N tempYField.setAccessible(true); tempHeightField = GridBagConstraints.class.getDeclaredField("tempHeight"); // NOI18N tempHeightField.setAccessible(true); tempWidthField = GridBagConstraints.class.getDeclaredField("tempWidth"); // NOI18N tempWidthField.setAccessible(true); } catch (NoSuchFieldException nsfex) { FormUtils.LOGGER.log(Level.INFO, nsfex.getMessage(), nsfex); } containerEmphColor = deriveEmphColor(container); }
/** Create a panel with buttons that will be placed according * to the required alignment */ private JPanel createButtonPanel( JButton[] buttons, boolean sidebuttons ) { int count = buttons.length; JPanel outerPanel = new JPanel( new BorderLayout() ); outerPanel.setBorder( new EmptyBorder( new Insets( sidebuttons ? 5 : 0, sidebuttons ? 0 : 5, 5, 5 ) ) ); LayoutManager lm = new GridLayout( // GridLayout makes equal cells sidebuttons ? count : 1, sidebuttons ? 1 : count, 5, 5 ); JPanel innerPanel = new JPanel( lm ); for( int i = 0; i < count; i++ ) innerPanel.add( buttons[i] ); outerPanel.add( innerPanel, sidebuttons ? BorderLayout.NORTH : BorderLayout.EAST ) ; return outerPanel; }
/** * Package private method which returns either BorderLayout.NORTH, * BorderLayout.SOUTH, BorderLayout.EAST, or BorderLayout.WEST depending * on the location of the toolbar in its parent. The toolbar might be * in PAGE_START, PAGE_END, CENTER, or some other position, but will be * resolved to either NORTH,SOUTH,EAST, or WEST based on where the toolbar * actually IS, with CENTER being NORTH. * * This code is used to determine where the border line should be drawn * by the custom toolbar states, and also used by NimbusIcon to determine * whether the handle icon needs to be shifted to look correct. * * Toollbars are unfortunately odd in the way these things are handled, * and so this code exists to unify the logic related to toolbars so it can * be shared among the static files such as NimbusIcon and generated files * such as the ToolBar state classes. */ static Object resolveToolbarConstraint(JToolBar toolbar) { //NOTE: we don't worry about component orientation or PAGE_END etc //because the BasicToolBarUI always uses an absolute position of //NORTH/SOUTH/EAST/WEST. if (toolbar != null) { Container parent = toolbar.getParent(); if (parent != null) { LayoutManager m = parent.getLayout(); if (m instanceof BorderLayout) { BorderLayout b = (BorderLayout)m; Object con = b.getConstraints(toolbar); if (con == SOUTH || con == EAST || con == WEST) { return con; } return NORTH; } } } return NORTH; }
@Override public void createSnapshotLayout(final SnapshotContext context, final JComponent parent, final RadContainer container, final LayoutManager layout) { GridLayout gridLayout = (GridLayout) layout; int ncomponents = parent.getComponentCount(); int nrows = gridLayout.getRows(); int ncols = gridLayout.getColumns(); if (nrows > 0) { ncols = (ncomponents + nrows - 1) / nrows; } else { nrows = (ncomponents + ncols - 1) / ncols; } container.setLayout(new GridLayoutManager(nrows, ncols, new Insets(0, 0, 0, 0), gridLayout.getHgap(), gridLayout.getVgap(), true, true)); }
private JPanel getMainJPanel() { JPanel mainJPanel = new JPanel(); LayoutManager layout = new BoxLayout(mainJPanel, BoxLayout.Y_AXIS); mainJPanel.setLayout(layout); JPanel logPatternJPanel = getLogPatternJPanel(); JPanel buttonsJPanel = getButtonsJPanel(); mainJPanel.add(logPatternJPanel); mainJPanel.add(Box.createRigidArea(new Dimension(4, 2))); mainJPanel.add(buttonsJPanel); mainJPanel.add(Box.createRigidArea(new Dimension(4, 4))); // mainJPanel.add(Box.createHorizontalGlue()); return mainJPanel; }
/** * Sets the <code>LayoutManager</code>. Overridden to conditionally forward * the call to the <code>contentPane</code>. Refer to * {@link javax.swing.RootPaneContainer} for more information.<p> * * <b>Wichtig:</b><br> * Der neue <code>LayoutManager</code> sollte ein * <code>PRoBorderLayout</code> sein, da das Hinzuf�gen der Komponenten in * der Methode <code>init()</code> sich auf das Layout * <code>PRoBorderLayout</code> bezieht.<br> * M�chten Sie ein anderes Layout implementieren, dann ist die Methode * <code>init()</code> zu �berlagern. * * @param manager the <code>LayoutManager</code> * @see #setRootPaneCheckingEnabled * @see javax.swing.RootPaneContainer */ @Override public final void setLayout(final LayoutManager manager) { if (init) { ppPRoDialog.removeAll(); ppPRoDialog.setLayout(manager); this.getContentPane().removeAll(); this.init(); } if (!init) { if (rootPaneCheckingEnabled) { this.getContentPane().setLayout(manager); } else { super.setLayout(manager); } } }
public static void addGridBagComponent( Container container, Component component, int gridX, int gridY, int gridWidth, int gridHeight, int fill, int anchor, Insets insets ) throws AWTException { LayoutManager lm = container.getLayout(); if ( !( lm instanceof GridBagLayout ) ) { throw new AWTException( "Invalid layout: " + lm ); } else { GridBagConstraints gbc = getGridBagConstraints( gridX, gridY, gridWidth, gridHeight, fill, anchor ); gbc.insets = insets; ( (GridBagLayout) lm ).setConstraints( component, gbc ); container.add( component ); } }
private JPanel getTracerInfoJPanel() { JPanel infoJPanel = new JPanel(); LayoutManager layout = new BoxLayout(infoJPanel, BoxLayout.X_AXIS); infoJPanel.setLayout(layout); // Dimension preferredSize = new Dimension(300, 30); // infoJPanel.setPreferredSize(preferredSize); JPanel incompleteTracerJPanel = getIncompleteTracerJPanel(); JPanel charsetJPanel = getCharsetJPanel(); JPanel sizeJPanel = getSizeJPanel(); infoJPanel.add(incompleteTracerJPanel); infoJPanel.add(charsetJPanel); infoJPanel.add(sizeJPanel); return infoJPanel; }
@Override public void setLayout(LayoutManager mgr) { if (mgr != null) { throw new UnsupportedOperationException( "PlaceholderPanel's layout manager cannot be changed.");//NOI18N } }
@Override protected LayoutManager createLayoutManager() { if (tabPane.getTabLayoutPolicy() == JTabbedPane.SCROLL_TAB_LAYOUT) { // can't override because private class.. return super.createLayoutManager(); } else { // override for docking framework spacing fix! return new BasicTabbedPaneUI.TabbedPaneLayout() { @Override protected void calculateTabRects(int tabPlacement, int tabCount) { final int spacer = -5; final int indent = 0; super.calculateTabRects(tabPlacement, tabCount); for (int i = 1; i < rects.length; i++) { // hack to get the tabs closer together. Don't shift leftmost tab(s) if (rects[i].x > 0) { rects[i].x += i * spacer + indent; } } } }; } }
/** * This funcion is overridden to make sure that the parent layout * is redone when the GlobalMap is shown. */ public void setVisible(boolean visible) { super.setVisible(visible); if (visible) { final LayoutManager l = getParent().getLayout(); if (l instanceof Map.InsetLayout) { l.layoutContainer(getParent()); } } }
private LayoutManager getLayout(Container c) { if (fixed) { return new GridLayout(0, nColumns); } else { return new BoxLayout(c, vertical ? BoxLayout.Y_AXIS : BoxLayout.X_AXIS); } }
protected void setupGui() { final JLabel canvasUrlLabel = new JLabel(getString("label.canvasurl")); final JLabel clientIdLabel = new JLabel(getString("label.clientid")); final JLabel secretLabel = new JLabel(getString("label.secret")); preamble = new JLabel(getString("preamble", CANVAS_SIGNUP_URL)); preamble.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR)); preamble.addMouseListener(this); canvasUrl = new JTextField(20); clientId = new JTextField(20); secret = new JPasswordField(20); bypassLogon = new JCheckBox(); bypassLogon.setText(getString("label.bypasslogon")); final LayoutManager layout = new MigLayout("wrap", "[fill][fill,grow]"); setLayout(layout); setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5)); add(preamble, "span 2, gapbottom 20"); add(canvasUrlLabel); add(canvasUrl); add(clientIdLabel); add(clientId); add(secretLabel); add(secret); add(bypassLogon, "span 2"); validate(); }
private void init(LayoutManager layout, Rectangle radioPosition) { setLayout(layout); if( radioPosition == null ) { add(radio); } else { add(radio, radioPosition); } radio.addItemListener(this); }
/** * The constructor to use. * * @param freeColClient The {@code FreeColClient} for the game. * @param layout The {@code LayoutManager} to use. * @param label The label for the panel. * @param units A list of {@code UnitType}s to offer. */ public NewUnitPanel(FreeColClient freeColClient, LayoutManager layout, String label, List<UnitType> units) { super(freeColClient, layout); this.question = new JLabel(label); this.units.addAll(units); final Europe europe = getMyPlayer().getEurope(); this.priceComparator = Comparator.comparingInt((UnitType ut) -> europe.getUnitPrice(ut)); okButton.setText(Messages.message("close")); update(); }
/** * Default constructor. * * @param freeColClient The {@code FreeColClient} for the game. * @param layout The {@code LayoutManager} to be used. */ protected FreeColPanel(FreeColClient freeColClient, LayoutManager layout) { super(layout); this.freeColClient = freeColClient; setBorder(FreeColImageBorder.imageBorder); okButton.setActionCommand(OK); okButton.addActionListener(this); setCancelComponent(okButton); }
public Dimension getPreferredSize(JComponent c) { LayoutManager layout = c.getLayout(); Dimension d = layout.preferredLayoutSize(c); String title = ((JPopupMenu)c).getLabel(); if (titleFont == null) { UIDefaults table = UIManager.getLookAndFeelDefaults(); titleFont = table.getFont("PopupMenu.font"); } FontMetrics fm = c.getFontMetrics(titleFont); int stringWidth = 0; if (title!=null) { stringWidth += SwingUtilities2.stringWidth(c, fm, title); } if (d.width < stringWidth) { d.width = stringWidth + 8; Insets i = c.getInsets(); if (i!=null) { d.width += i.left + i.right; } if (border != null) { i = border.getBorderInsets(c); d.width += i.left + i.right; } return d; } return null; }
public void setLayout(LayoutManager mgr) { LayoutManager oldMgr = getLayout(); if (oldMgr instanceof PropertyChangeListener) { removePropertyChangeListener((PropertyChangeListener)oldMgr); } super.setLayout(mgr); }
/** * Maps {@code Container.getLayout()} through queue */ public LayoutManager getLayout() { return (runMapping(new MapAction<LayoutManager>("getLayout") { @Override public LayoutManager map() { return ((Container) getSource()).getLayout(); } })); }
/** * Maps {@code Container.setLayout(LayoutManager)} through queue */ public void setLayout(final LayoutManager layoutManager) { runMapping(new MapVoidAction("setLayout") { @Override public void map() { ((Container) getSource()).setLayout(layoutManager); } }); }
public void PopuleBarra(JComponent obj) { ButtonGroup buttons = new ButtonGroup(); Barra = obj; Acao ac = new Acao(editor, "?", "Controler.interface.BarraLateral.Nothing.img", "Controler.interface.BarraLateral.Nothing.Texto", null); JToggleButton btn = arrume(new JToggleButton(ac)); buttons.add(btn); obj.add(btn); btn.setSelected(true); ac.IDX = -1; this.BtnNothing = btn; int i = 0; for (ConfigAcao ca : Lista) { if (ca.tipo == TipoConfigAcao.tpBotoes || ca.tipo == TipoConfigAcao.tpAny) { ac = new Acao(editor, ca.texto, ca.ico, ca.descricao, ca.command); ac.IDX = i++; btn = arrume(new JToggleButton(ac)); buttons.add(btn); //obj.add(btn); listaBotoes.put(ca.command, btn); } } menuComandos c = menuComandos.cmdDel; String str = "Controler.comandos." + c.toString().substring(3).toLowerCase(); ac = new Acao(editor, Editor.fromConfiguracao.getValor(str + ".descricao"), str + ".img", str + ".descricao", c.toString()); ListaDeAcoesEditaveis.add(ac); ac.normal = false; JButton btn2 = new JButton(ac); btn2.setHideActionText(true); btn2.setFocusable(false); btn2.setPreferredSize(new Dimension(40, 40)); obj.add(btn2); LayoutManager la = obj.getLayout(); if (la instanceof GridLayout) { ((GridLayout) la).setRows(i + 2); } }
/** * Create the dialog. * * @param lm the layout manager to use for the mainPanel * @param floatme true to create a non-modal dialog that floats on top of other windows */ public BaseDialog(LayoutManager lm, boolean floatme) { super(new BorderLayout()); valid = false; currentDialog = null; floating = floatme; labels = new HashMap<String,JLabel>(); fields = new HashMap<String,JTextField>(); selects = new HashMap<String,JComboBox<Object>>(); checks = new HashMap<String,JCheckBox>(); radios = new HashMap<String,JRadioButton>(); buttonGroup = new ButtonGroup(); ok = new JButton("OK"); cancel = new JButton("Cancel"); ok.addActionListener(this); cancel.addActionListener(this); defaultButton = ok; buttonPanel = new JPanel(); buttonPanel.add(ok); buttonPanel.add(cancel); mainPanel = new JPanel(lm); mainPanel.setBorder(new EmptyBorder(6,6,6,6)); add(mainPanel, BorderLayout.CENTER); add(buttonPanel, BorderLayout.SOUTH); }
private void buttonColorActionPerformed( java.awt.event.ActionEvent evt) {//GEN-FIRST:event_buttonColorActionPerformed final JDialog di = new JDialog(this, true); di.setTitle(getLocaleMessage("dialog.select_color")); final JColorChooser cc = new JColorChooser( Color.decode("#" + textFieldFontColor.getText())); di.setSize(450, 440); LayoutManager l = new FlowLayout(2, 10, 10); di.setLayout(l); di.add(cc); final JButton but = new JButton(new AbstractAction() { @Override public void actionPerformed(ActionEvent e) { textFieldFontColor .setText( Integer.toHexString(cc.getColor().getRGB()).substring(2).toUpperCase()); runningLabel.setForeground(Color.decode("#" + textFieldFontColor.getText())); di.setVisible(false); } }); but.setText(getLocaleMessage("dialog.select")); but.setSize(20, 20); di.add(but); Uses.setLocation(di); di.setVisible(true); }
public JTimePanel(LayoutManager layout) { super(layout); this.init(); this.setValue(0 ,0 ,0); }
public JTimePanel(LayoutManager layout, boolean isDoubleBuffered) { super(layout, isDoubleBuffered); this.init(); this.setValue(0 ,0 ,0); }
public JDatePanel(LayoutManager layout) { super(layout); this.init(); this.setValue(new Date()); }
public JDatePanel(LayoutManager layout, boolean isDoubleBuffered) { super(layout, isDoubleBuffered); this.init(); this.setValue(new Date()); }
Panel create(LayoutManager layout) { Button b = null; Panel p = new Panel(); p.setLayout(layout); b = new Button("one"); b.addActionListener(listener); p.add("North", b); b = new Button("two"); b.addActionListener(listener); p.add("West", b); b = new Button("three"); b.addActionListener(listener); p.add("South", b); b = new Button("four"); b.addActionListener(listener); p.add("East", b); b = new Button("five"); b.addActionListener(listener); p.add("Center", b); b = new Button("six"); b.addActionListener(listener); p.add("Center", b); return p; }
/** * Creates and returns an instance of {@link TabbedPaneLayout}. * * @return A layout manager used by this UI delegate. */ protected LayoutManager createLayoutManager() { return (tabPane.getTabLayoutPolicy() == JTabbedPane.WRAP_TAB_LAYOUT) ? new MetalTabbedPaneUI.TabbedPaneLayout() : super.createLayoutManager(); }