Java Code Examples for javax.swing.JComponent.getLayout()

The following are Jave code examples for showing how to use getLayout() of the javax.swing.JComponent class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
+ Save this method
Example 1
Project: incubator-netbeans   File: RendererPropertyDisplayer.java   View Source Code Vote up 6 votes
protected void prepareRenderer(JComponent comp) {
    comp.setBackground(getBackground());
    comp.setForeground(getForeground());
    comp.setBounds(0, 0, getWidth(), getHeight());

    JComponent innermost;

    if ((innermost = findInnermostRenderer(comp)) instanceof JComboBox) {
        if (comp.getLayout() != null) {
            comp.getLayout().layoutContainer(comp);
        }
    }

    if (!isTableUI() && ((InplaceEditor) comp).supportsTextEntry()) {
        innermost.setBackground(PropUtils.getTextFieldBackground());
        innermost.setForeground(PropUtils.getTextFieldForeground());
    }
}
 
Example 2
Project: MaxSim   File: CFGOptionsPanel.java   View Source Code Vote up 6 votes
private void addColorChooser(JComponent c, String displayName, ColorChooser chooser) {
    GridBagLayout layout = (GridBagLayout)c.getLayout();
    GridBagConstraints constraints = new GridBagConstraints();
    constraints.insets = new Insets(3, 3, 3, 3);
    constraints.weightx = 0.0;
    constraints.fill = GridBagConstraints.NONE;
    constraints.anchor = GridBagConstraints.EAST;
    JLabel label = new JLabel(displayName, JLabel.TRAILING);
    layout.setConstraints(label, constraints);
    c.add(label);
    constraints.anchor = GridBagConstraints.WEST;
    constraints.gridwidth = GridBagConstraints.REMAINDER;
    layout.setConstraints(chooser, constraints);
    c.add(chooser);
    elements.add(chooser);
    label.setLabelFor(chooser);
}
 
Example 3
Project: MaxSim   File: CFGOptionsPanel.java   View Source Code Vote up 6 votes
private void addFontChooser(JComponent c, String displayName, FontChooser chooser) {
    GridBagLayout layout = (GridBagLayout)c.getLayout();
    GridBagConstraints constraints = new GridBagConstraints();
    constraints.insets = new Insets(3, 3, 3, 3);
    constraints.weightx = 0.0;
    constraints.fill = GridBagConstraints.NONE;
    constraints.anchor = GridBagConstraints.EAST;
    JLabel label = new JLabel(displayName, JLabel.TRAILING);
    layout.setConstraints(label, constraints);
    c.add(label);
    constraints.insets = new Insets(3, 3, 3, 1);
    constraints.weightx = 1.0;
    constraints.fill = GridBagConstraints.HORIZONTAL;
    constraints.anchor = GridBagConstraints.CENTER;
    layout.setConstraints(chooser.getPreview(), constraints);
    c.add(chooser.getPreview());
    constraints.insets = new Insets(3, 1, 3, 3);
    constraints.weightx = 0.0;
    constraints.fill = GridBagConstraints.NONE;
    constraints.anchor = GridBagConstraints.EAST;
    constraints.gridwidth = GridBagConstraints.REMAINDER;
    layout.setConstraints(chooser.getButton(), constraints);
    c.add(chooser.getButton());
    elements.add(chooser);
    label.setLabelFor(chooser.getButton());
}
 
Example 4
Project: MaxSim   File: CFGOptionsPanel.java   View Source Code Vote up 6 votes
private void addFlagsEditor(JComponent c, String displayName) {
    GridBagLayout layout = (GridBagLayout)c.getLayout();
    GridBagConstraints constraints = new GridBagConstraints();
    constraints.insets = new Insets(3, 3, 3, 3);
    constraints.weightx = 0.0;
    constraints.fill = GridBagConstraints.NONE;
    constraints.anchor = GridBagConstraints.NORTHEAST;
    FlagsEditor flagsEditor = new FlagsEditor();
    JLabel flagsLabel = new JLabel(displayName, JLabel.TRAILING);
    flagsLabel.setVerticalAlignment(SwingConstants.TOP);
    layout.setConstraints(flagsLabel, constraints);
    c.add(flagsLabel);
    constraints.weightx = 1.0;
    constraints.weighty = 1.0;
    constraints.fill = GridBagConstraints.BOTH;
    constraints.anchor = GridBagConstraints.CENTER;
    constraints.gridwidth = GridBagConstraints.REMAINDER;
    layout.setConstraints(flagsEditor, constraints);
    c.add(flagsEditor);
    elements.add(flagsEditor);
    flagsLabel.setLabelFor(flagsEditor);
}
 
Example 5
Project: Equella   File: Editor.java   View Source Code Vote up 5 votes
protected void addSection(JComponent section, boolean followWithSeparator)
{
	// MigLayout puts in a margin, TableLayout doesn't!
	String cons = section.getLayout() instanceof MigLayout ? "gap 0 0 0 0" : "gap 5 5 5 5";

	add(section, cons);
	if( followWithSeparator )
	{
		add(new JSeparator());
	}
}
 
Example 6
Project: brModelo   File: Controler.java   View Source Code Vote up 5 votes
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);
    }
}