下面列出了javax.swing.JComponent#getLayout ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。
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());
}
}
@Override
public Dimension getMinimumSize(JComponent c) {
if (c == optionPane) {
Dimension ourMin = getMinimumOptionPaneSize();
LayoutManager lm = c.getLayout();
if (lm != null) {
Dimension lmSize = lm.minimumLayoutSize(c);
if (ourMin != null) {
return new Dimension(Math.max(lmSize.width, ourMin.width), Math.max(lmSize.height, ourMin.height));
}
return lmSize;
}
return ourMin;
}
return null;
}
/**
* @see javax.swing.plaf.basic.BasicButtonUI#getMinimumSize(javax.swing.JComponent)
*/
public Dimension getMinimumSize(JComponent c) {
if (c.getComponentCount() > 0 && c.getLayout() != null) {
return null;
}
AbstractButton b = (AbstractButton) c;
SeaGlassContext ss = getContext(c);
final SynthStyle style2 = ss.getStyle();
Dimension size = style2.getGraphicsUtils(ss).getMinimumSize(ss, style2.getFont(ss), b.getText(), getSizingIcon(b),
b.getHorizontalAlignment(), b.getVerticalAlignment(),
b.getHorizontalTextPosition(), b.getVerticalTextPosition(),
b.getIconTextGap(), b.getDisplayedMnemonicIndex());
ss.dispose();
return size;
}
/**
* @see javax.swing.plaf.basic.BasicButtonUI#getPreferredSize(javax.swing.JComponent)
*/
public Dimension getPreferredSize(JComponent c) {
if (c.getComponentCount() > 0 && c.getLayout() != null) {
return null;
}
AbstractButton b = (AbstractButton) c;
SeaGlassContext ss = getContext(c);
SynthStyle style2 = ss.getStyle();
SynthGraphicsUtils graphicsUtils = style2.getGraphicsUtils(ss);
Dimension size = graphicsUtils.getPreferredSize(ss, style2.getFont(ss), b.getText(), getSizingIcon(b),
b.getHorizontalAlignment(),
b.getVerticalAlignment(), b.getHorizontalTextPosition(),
b.getVerticalTextPosition(), b.getIconTextGap(),
b.getDisplayedMnemonicIndex());
ss.dispose();
// Make height odd.
size.height &= ~1;
return size;
}
/**
* @see javax.swing.plaf.basic.BasicButtonUI#getMaximumSize(javax.swing.JComponent)
*/
public Dimension getMaximumSize(JComponent c) {
if (c.getComponentCount() > 0 && c.getLayout() != null) {
return null;
}
AbstractButton b = (AbstractButton) c;
SeaGlassContext ss = getContext(c);
final SynthStyle style2 = ss.getStyle();
Dimension size = style2.getGraphicsUtils(ss).getMaximumSize(ss, style2.getFont(ss), b.getText(), getSizingIcon(b),
b.getHorizontalAlignment(), b.getVerticalAlignment(),
b.getHorizontalTextPosition(), b.getVerticalTextPosition(),
b.getIconTextGap(), b.getDisplayedMnemonicIndex());
ss.dispose();
return size;
}
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);
}
}
public void propertyChange(PropertyChangeEvent evt) {
Component c = (JComponent) evt.getSource();
JComponent parent = (JComponent) c.getParent();
if (parent != null) {
LayoutManager layout = parent.getLayout();
if (layout == ClientProperty.this) {
layout.layoutContainer(parent);
} else {
c.removePropertyChangeListener(PROPERTY_DESTINATION,
this);
}
}
}