Java Code Examples for java.awt.LayoutManager

The following are top voted examples for showing how to use java.awt.LayoutManager. These examples are extracted from open source projects. You can vote up the examples you like and your votes will be used in our system to generate more good examples.
Example 1
Project: Random-Music-Generator   File: Window.java   View source code 6 votes vote down vote up
/**
 * 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);
}
 
Example 2
Project: incubator-netbeans   File: GridBagInfoProvider.java   View source code 6 votes vote down vote up
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);
}
 
Example 3
Project: incubator-netbeans   File: DialogSupport.java   View source code 6 votes vote down vote up
/** 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;
}
 
Example 4
Project: OpenJSharp   File: NimbusLookAndFeel.java   View source code 6 votes vote down vote up
/**
 * 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;
}
 
Example 5
Project: jdk8u-jdk   File: NimbusLookAndFeel.java   View source code 6 votes vote down vote up
/**
 * 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;
}
 
Example 6
Project: openjdk-jdk10   File: NimbusLookAndFeel.java   View source code 6 votes vote down vote up
/**
 * 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;
}
 
Example 7
Project: intellij-ce-playground   File: RadSwingGridLayoutManager.java   View source code 6 votes vote down vote up
@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));
}
 
Example 8
Project: pega-logviewer   File: LogPatternSelectionDialog.java   View source code 6 votes vote down vote up
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;
	}
 
Example 9
Project: typewriter   File: PRoDialog.java   View source code 6 votes vote down vote up
/**
 * 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);
        }
    }
}
 
Example 10
Project: PhET   File: SwingUtils.java   View source code 6 votes vote down vote up
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 );
    }
}
 
Example 11
Project: pega-tracerviewer   File: TracerDataMainPanel.java   View source code 6 votes vote down vote up
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;
	}
 
Example 12
Project: jdk8u_jdk   File: NimbusLookAndFeel.java   View source code 6 votes vote down vote up
/**
 * 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;
}
 
Example 13
Project: incubator-netbeans   File: PlaceholderPanel.java   View source code 5 votes vote down vote up
@Override
public void setLayout(LayoutManager mgr) {
    if (mgr != null) {
        throw new UnsupportedOperationException(
            "PlaceholderPanel's layout manager cannot be changed.");//NOI18N
    }
}
 
Example 14
Project: rapidminer   File: TabbedPaneUI.java   View source code 5 votes vote down vote up
@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;
					}
				}
			}
		};
	}

}
 
Example 15
Project: VASSAL-src   File: GlobalMap.java   View source code 5 votes vote down vote up
/**
 * 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());
    }
  }
}
 
Example 16
Project: VASSAL-src   File: PanelWidget.java   View source code 5 votes vote down vote up
private LayoutManager getLayout(Container c) {
  if (fixed) {
    return new GridLayout(0, nColumns);
  }
  else {
    return new BoxLayout(c, vertical ? BoxLayout.Y_AXIS : BoxLayout.X_AXIS);
  }
}
 
Example 17
Project: Equella   File: CanvasSettingsPanel.java   View source code 5 votes vote down vote up
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();
}
 
Example 18
Project: Equella   File: JRadioGroup.java   View source code 5 votes vote down vote up
private void init(LayoutManager layout, Rectangle radioPosition)
{
	setLayout(layout);
	if( radioPosition == null )
	{
		add(radio);
	}
	else
	{
		add(radio, radioPosition);
	}
	radio.addItemListener(this);
}
 
Example 19
Project: freecol   File: NewUnitPanel.java   View source code 5 votes vote down vote up
/**
 * 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();
}
 
Example 20
Project: freecol   File: FreeColPanel.java   View source code 5 votes vote down vote up
/**
 * 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);
}
 
Example 21
Project: OpenJSharp   File: MotifPopupMenuUI.java   View source code 5 votes vote down vote up
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;
}
 
Example 22
Project: OpenJSharp   File: JToolBar.java   View source code 5 votes vote down vote up
public void setLayout(LayoutManager mgr) {
    LayoutManager oldMgr = getLayout();
    if (oldMgr instanceof PropertyChangeListener) {
        removePropertyChangeListener((PropertyChangeListener)oldMgr);
    }
    super.setLayout(mgr);
}
 
Example 23
Project: jdk8u-jdk   File: MotifPopupMenuUI.java   View source code 5 votes vote down vote up
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;
}
 
Example 24
Project: jdk8u-jdk   File: JToolBar.java   View source code 5 votes vote down vote up
public void setLayout(LayoutManager mgr) {
    LayoutManager oldMgr = getLayout();
    if (oldMgr instanceof PropertyChangeListener) {
        removePropertyChangeListener((PropertyChangeListener)oldMgr);
    }
    super.setLayout(mgr);
}
 
Example 25
Project: openjdk-jdk10   File: MotifPopupMenuUI.java   View source code 5 votes vote down vote up
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;
}
 
Example 26
Project: openjdk-jdk10   File: JToolBar.java   View source code 5 votes vote down vote up
public void setLayout(LayoutManager mgr) {
    LayoutManager oldMgr = getLayout();
    if (oldMgr instanceof PropertyChangeListener) {
        removePropertyChangeListener((PropertyChangeListener)oldMgr);
    }
    super.setLayout(mgr);
}
 
Example 27
Project: openjdk-jdk10   File: ContainerOperator.java   View source code 5 votes vote down vote up
/**
 * Maps {@code Container.getLayout()} through queue
 */
public LayoutManager getLayout() {
    return (runMapping(new MapAction<LayoutManager>("getLayout") {
        @Override
        public LayoutManager map() {
            return ((Container) getSource()).getLayout();
        }
    }));
}
 
Example 28
Project: openjdk-jdk10   File: ContainerOperator.java   View source code 5 votes vote down vote up
/**
 * 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);
        }
    });
}
 
Example 29
Project: brModelo   File: Controler.java   View source code 5 votes vote down vote up
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);
    }
}
 
Example 30
Project: FreeCol   File: NewUnitPanel.java   View source code 5 votes vote down vote up
/**
 * 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();
}
 
Example 31
Project: FreeCol   File: FreeColPanel.java   View source code 5 votes vote down vote up
/**
 * 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);
}
 
Example 32
Project: scorekeeperfrontend   File: BaseDialog.java   View source code 5 votes vote down vote up
/**
 * 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);
}
 
Example 33
Project: sbc-qsystem   File: FBoardParams.java   View source code 5 votes vote down vote up
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);

}
 
Example 34
Project: hy.common.ui   File: JTimePanel.java   View source code 5 votes vote down vote up
public JTimePanel(LayoutManager layout) 
{
	super(layout);
	
	this.init();
	this.setValue(0 ,0 ,0);
}
 
Example 35
Project: hy.common.ui   File: JTimePanel.java   View source code 5 votes vote down vote up
public JTimePanel(LayoutManager layout, boolean isDoubleBuffered) 
{
	super(layout, isDoubleBuffered);
	
	this.init();
	this.setValue(0 ,0 ,0);
}
 
Example 36
Project: hy.common.ui   File: JDatePanel.java   View source code 5 votes vote down vote up
public JDatePanel(LayoutManager layout) 
{
	super(layout);
	
	this.init();
	this.setValue(new Date());
}
 
Example 37
Project: hy.common.ui   File: JDatePanel.java   View source code 5 votes vote down vote up
public JDatePanel(LayoutManager layout, boolean isDoubleBuffered) 
{
	super(layout, isDoubleBuffered);
	
	this.init();
	this.setValue(new Date());
}
 
Example 38
Project: openjdk9   File: CardTest.java   View source code 5 votes vote down vote up
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;
}
 
Example 39
Project: openjdk9   File: MotifPopupMenuUI.java   View source code 5 votes vote down vote up
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;
}
 
Example 40
Project: javify   File: MetalTabbedPaneUI.java   View source code 5 votes vote down vote up
/**
 * 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();
}