本文整理了Java中javax.swing.JLabel.getInsets()
方法的一些代码示例,展示了JLabel.getInsets()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。JLabel.getInsets()
方法的具体详情如下:
包路径:javax.swing.JLabel
类名称:JLabel
方法名:getInsets
暂无
代码示例来源:origin: org.netbeans.modules/org-netbeans-modules-visualweb-propertyeditors
public Insets getInsets(Insets in) {
in = super.getInsets(in);
in.left += 2;
return in;
}
代码示例来源:origin: RPTools/maptool
public Insets getInsets() {
Insets insets = super.getInsets();
if (painting) {
if (rotation == ROTATE_LEFT) {
int temp = insets.bottom;
insets.bottom = insets.left;
insets.left = insets.top;
insets.top = insets.right;
insets.right = temp;
} else if (rotation == ROTATE_RIGHT) {
int temp = insets.bottom;
insets.bottom = insets.right;
insets.right = insets.top;
insets.top = insets.left;
insets.left = temp;
}
}
return insets;
}
代码示例来源:origin: RPTools/maptool
public Insets getInsets(Insets insets) {
insets = super.getInsets(insets);
if (painting) {
if (rotation == ROTATE_LEFT) {
int temp = insets.bottom;
insets.bottom = insets.left;
insets.left = insets.top;
insets.top = insets.right;
insets.right = temp;
} else if (rotation == ROTATE_RIGHT) {
int temp = insets.bottom;
insets.bottom = insets.right;
insets.right = insets.top;
insets.top = insets.left;
insets.left = temp;
}
}
return insets;
}
代码示例来源:origin: net.sf.kerner-utils/kerner-utils
/**
* Returns the available height to paint text on. This is the height of the
* passed component with insets subtracted.
*
* @param l
* a component
* @return the available height
*/
protected int getAvailableHeight(final JLabel l) {
l.getInsets(paintViewInsets);
return l.getHeight() - paintViewInsets.top - paintViewInsets.bottom;
}
代码示例来源:origin: net.sf.kerner-utils/kerner-utils
/**
* The preferred height of the label is the height of the lines with added
* top and bottom insets.
*
* @param label
* the label
* @return the preferred height of the wrapped lines.
*/
protected int getPreferredHeight(final JLabel label) {
final int numOfLines = getTextLines(label).size();
final Insets insets = label.getInsets(paintViewInsets);
return numOfLines * metrics.getHeight() + insets.top + insets.bottom;
}
代码示例来源:origin: stackoverflow.com
String text = "Hear no evil";
JLabel label = new JLabel(text);
System.out.println( label.getPreferredSize() );
System.out.println( label.getInsets() );
JCheckBox checkBox = new JCheckBox(text);
System.out.println( checkBox.getPreferredSize() );
System.out.println( checkBox.getInsets() );
代码示例来源:origin: stackoverflow.com
JLabel label = new JLabel("xx");
int minWidth = ((int) (label.getFontMetrics(label.getFont()).getStringBounds(label.getText(),label.getGraphics()).getWidth()) + label.getInsets().left + label.getInsets().right);
代码示例来源:origin: org.netbeans.modules/org-netbeans-modules-profiler
private Dimension getClientSize() {
Insets insets = displayer.getInsets();
Dimension size = displayer.getSize().equals(ZERO_SIZE) ? displayer.getPreferredSize() : displayer.getSize();
return new Dimension(size.width - insets.left - insets.right, size.height - insets.top - insets.bottom);
}
代码示例来源:origin: net.sf.kerner-utils/kerner-utils
/**
* Calculate the paint rectangles for the icon and text for the passed
* label.
*
* @param l
* a label
* @param fm
* the font metrics to use, or <code>null</code> to get the font
* metrics from the label
* @param width
* label width
* @param height
* label height
*/
protected void updateLayout(final JLabel l, FontMetrics fm, final int width, final int height) {
if (fm == null) {
fm = l.getFontMetrics(l.getFont());
}
metrics = fm;
final String text = l.getText();
final Icon icon = l.getIcon();
final Insets insets = l.getInsets(paintViewInsets);
paintViewR.x = insets.left;
paintViewR.y = insets.top;
paintViewR.width = width - (insets.left + insets.right);
paintViewR.height = height - (insets.top + insets.bottom);
paintIconR.x = paintIconR.y = paintIconR.width = paintIconR.height = 0;
paintTextR.x = paintTextR.y = paintTextR.width = paintTextR.height = 0;
layoutCL(l, fm, text, icon, paintViewR, paintIconR, paintTextR);
}
代码示例来源:origin: com.haulmont.thirdparty/swingx-core
/**
* {@inheritDoc} <p>
*
* Paints a diagonal cross over the text if the comp is of type JLabel,
* does nothing otherwise.
*/
@Override
protected void doPaint(Graphics2D g, JComponent comp, int width,
int height) {
if (!(comp instanceof JLabel)) return;
JLabel label = (JLabel) comp;
Insets insets = label.getInsets(insetss);
paintViewR.x = insets.left;
paintViewR.y = insets.top;
paintViewR.width = width - (insets.left + insets.right);
paintViewR.height = height - (insets.top + insets.bottom);
paintIconR.x = paintIconR.y = paintIconR.width = paintIconR.height = 0;
paintTextR.x = paintTextR.y = paintTextR.width = paintTextR.height = 0;
SwingUtilities.layoutCompoundLabel(label,
label.getFontMetrics(label.getFont()), label.getText(), null,
label.getVerticalAlignment(), label.getHorizontalAlignment(),
label.getVerticalTextPosition(), label.getHorizontalTextPosition(),
paintViewR, paintIconR, paintTextR, label.getIconTextGap());
doPaint(g, paintTextR);
}
代码示例来源:origin: org.swinglabs.swingx/swingx-all
@Override
public void ancestorResized(HierarchyEvent e) {
if (header == e.getComponent()) {
View v = (View) descriptionPane.getClientProperty(BasicHTML.propertyKey);
// view might get lost on LAF change ...
if (v == null) {
descriptionPane.putClientProperty(BasicHTML.propertyKey,
MultiLineSupport.createView(descriptionPane));
v = (View) descriptionPane.getClientProperty(BasicHTML.propertyKey);
}
if (v != null) {
Container tla = header.getTopLevelAncestor();
if (tla == null) {
tla = header.getParent();
while (tla.getParent() != null) {
tla = tla.getParent();
}
}
int h = Math.max(descriptionPane.getHeight(), tla.getHeight());
int w = Math.min(tla.getWidth(), header.getParent().getWidth());
// 35 = description pane insets, TODO: obtain dynamically
w -= 35 + header.getInsets().left + header.getInsets().right + descriptionPane.getInsets().left + descriptionPane.getInsets().right + imagePanel.getInsets().left + imagePanel.getInsets().right + imagePanel.getWidth() + descriptionPane.getBounds().x;
v.setSize(w, h);
descriptionPane.setSize(w, (int) Math.ceil(v.getPreferredSpan(View.Y_AXIS)));
}
}
}};
header.addPropertyChangeListener(propListener);
代码示例来源:origin: com.haulmont.thirdparty/swingx-core
@Override
public void ancestorResized(HierarchyEvent e) {
if (header == e.getComponent()) {
View v = (View) descriptionPane.getClientProperty(BasicHTML.propertyKey);
// view might get lost on LAF change ...
if (v == null) {
descriptionPane.putClientProperty(BasicHTML.propertyKey,
MultiLineSupport.createView(descriptionPane));
v = (View) descriptionPane.getClientProperty(BasicHTML.propertyKey);
}
if (v != null) {
Container tla = header.getTopLevelAncestor();
if (tla == null) {
tla = header.getParent();
while (tla.getParent() != null) {
tla = tla.getParent();
}
}
int h = Math.max(descriptionPane.getHeight(), tla.getHeight());
int w = Math.min(tla.getWidth(), header.getParent().getWidth());
// 35 = description pane insets, TODO: obtain dynamically
w -= 35 + header.getInsets().left + header.getInsets().right + descriptionPane.getInsets().left + descriptionPane.getInsets().right + imagePanel.getInsets().left + imagePanel.getInsets().right + imagePanel.getWidth() + descriptionPane.getBounds().x;
v.setSize(w, h);
descriptionPane.setSize(w, (int) Math.ceil(v.getPreferredSpan(View.Y_AXIS)));
}
}
}};
header.addPropertyChangeListener(propListener);
代码示例来源:origin: org.swinglabs.swingx/swingx-core
@Override
public void ancestorResized(HierarchyEvent e) {
if (header == e.getComponent()) {
View v = (View) descriptionPane.getClientProperty(BasicHTML.propertyKey);
// view might get lost on LAF change ...
if (v == null) {
descriptionPane.putClientProperty(BasicHTML.propertyKey,
MultiLineSupport.createView(descriptionPane));
v = (View) descriptionPane.getClientProperty(BasicHTML.propertyKey);
}
if (v != null) {
Container tla = header.getTopLevelAncestor();
if (tla == null) {
tla = header.getParent();
while (tla.getParent() != null) {
tla = tla.getParent();
}
}
int h = Math.max(descriptionPane.getHeight(), tla.getHeight());
int w = Math.min(tla.getWidth(), header.getParent().getWidth());
// 35 = description pane insets, TODO: obtain dynamically
w -= 35 + header.getInsets().left + header.getInsets().right + descriptionPane.getInsets().left + descriptionPane.getInsets().right + imagePanel.getInsets().left + imagePanel.getInsets().right + imagePanel.getWidth() + descriptionPane.getBounds().x;
v.setSize(w, h);
descriptionPane.setSize(w, (int) Math.ceil(v.getPreferredSpan(View.Y_AXIS)));
}
}
}};
header.addPropertyChangeListener(propListener);
代码示例来源:origin: org.codehaus.jtstand/jtstand-desktop
@Override
public void ancestorResized(HierarchyEvent e) {
if (header == e.getComponent()) {
View v = (View) descriptionPane.getClientProperty(BasicHTML.propertyKey);
// view might get lost on LAF change ...
if (v == null) {
descriptionPane.putClientProperty(BasicHTML.propertyKey,
descriptionPane.getMultiLineSupport().createView(descriptionPane));
v = (View) descriptionPane.getClientProperty(BasicHTML.propertyKey);
}
if (v != null) {
Container tla = header.getTopLevelAncestor();
if (tla == null) {
tla = header.getParent();
while (tla.getParent() != null) {
tla = tla.getParent();
}
}
int h = Math.max(descriptionPane.getHeight(), tla.getHeight());
int w = Math.min(tla.getWidth(), header.getParent().getWidth());
// 35 = description pane insets, TODO: obtain dynamically
w -= 35 + header.getInsets().left + header.getInsets().right + descriptionPane.getInsets().left + descriptionPane.getInsets().right + imagePanel.getInsets().left + imagePanel.getInsets().right + imagePanel.getWidth() + descriptionPane.getBounds().x;
v.setSize(w, h);
descriptionPane.setSize(w, (int) Math.ceil(v.getPreferredSpan(View.Y_AXIS)));
}
}
}};
header.addPropertyChangeListener(propListener);
代码示例来源:origin: org.bidib.jbidib.swinglabs.swingx/swingx-core
/**
* {@inheritDoc} <p>
*
* Paints a diagonal cross over the text if the comp is of type JLabel,
* does nothing otherwise.
*/
@Override
protected void doPaint(Graphics2D g, JComponent comp, int width,
int height) {
if (!(comp instanceof JLabel)) return;
JLabel label = (JLabel) comp;
Insets insets = label.getInsets(insetss);
paintViewR.x = insets.left;
paintViewR.y = insets.top;
paintViewR.width = width - (insets.left + insets.right);
paintViewR.height = height - (insets.top + insets.bottom);
paintIconR.x = paintIconR.y = paintIconR.width = paintIconR.height = 0;
paintTextR.x = paintTextR.y = paintTextR.width = paintTextR.height = 0;
SwingUtilities.layoutCompoundLabel(label,
label.getFontMetrics(label.getFont()), label.getText(), null,
label.getVerticalAlignment(), label.getHorizontalAlignment(),
label.getVerticalTextPosition(), label.getHorizontalTextPosition(),
paintViewR, paintIconR, paintTextR, label.getIconTextGap());
doPaint(g, paintTextR);
}
代码示例来源:origin: org.bidib.jbidib.swinglabs.swingx/swingx-core
@Override
public void ancestorResized(HierarchyEvent e) {
if (header == e.getComponent()) {
View v = (View) descriptionPane.getClientProperty(BasicHTML.propertyKey);
// view might get lost on LAF change ...
if (v == null) {
descriptionPane.putClientProperty(BasicHTML.propertyKey,
MultiLineSupport.createView(descriptionPane));
v = (View) descriptionPane.getClientProperty(BasicHTML.propertyKey);
}
if (v != null) {
Container tla = header.getTopLevelAncestor();
if (tla == null) {
tla = header.getParent();
while (tla.getParent() != null) {
tla = tla.getParent();
}
}
int h = Math.max(descriptionPane.getHeight(), tla.getHeight());
int w = Math.min(tla.getWidth(), header.getParent().getWidth());
// 35 = description pane insets, TODO: obtain dynamically
w -= 35 + header.getInsets().left + header.getInsets().right + descriptionPane.getInsets().left + descriptionPane.getInsets().right + imagePanel.getInsets().left + imagePanel.getInsets().right + imagePanel.getWidth() + descriptionPane.getBounds().x;
v.setSize(w, h);
descriptionPane.setSize(w, (int) Math.ceil(v.getPreferredSpan(View.Y_AXIS)));
}
}
}};
header.addPropertyChangeListener(propListener);
代码示例来源:origin: org.swinglabs.swingx/swingx-all
/**
* {@inheritDoc} <p>
*
* Paints a diagonal cross over the text if the comp is of type JLabel,
* does nothing otherwise.
*/
@Override
protected void doPaint(Graphics2D g, JComponent comp, int width,
int height) {
if (!(comp instanceof JLabel)) return;
JLabel label = (JLabel) comp;
Insets insets = label.getInsets(insetss);
paintViewR.x = insets.left;
paintViewR.y = insets.top;
paintViewR.width = width - (insets.left + insets.right);
paintViewR.height = height - (insets.top + insets.bottom);
paintIconR.x = paintIconR.y = paintIconR.width = paintIconR.height = 0;
paintTextR.x = paintTextR.y = paintTextR.width = paintTextR.height = 0;
SwingUtilities.layoutCompoundLabel(label,
label.getFontMetrics(label.getFont()), label.getText(), null,
label.getVerticalAlignment(), label.getHorizontalAlignment(),
label.getVerticalTextPosition(), label.getHorizontalTextPosition(),
paintViewR, paintIconR, paintTextR, label.getIconTextGap());
doPaint(g, paintTextR);
}
代码示例来源:origin: org.swinglabs.swingx/swingx-core
/**
* {@inheritDoc} <p>
*
* Paints a diagonal cross over the text if the comp is of type JLabel,
* does nothing otherwise.
*/
@Override
protected void doPaint(Graphics2D g, JComponent comp, int width,
int height) {
if (!(comp instanceof JLabel)) return;
JLabel label = (JLabel) comp;
Insets insets = label.getInsets(insetss);
paintViewR.x = insets.left;
paintViewR.y = insets.top;
paintViewR.width = width - (insets.left + insets.right);
paintViewR.height = height - (insets.top + insets.bottom);
paintIconR.x = paintIconR.y = paintIconR.width = paintIconR.height = 0;
paintTextR.x = paintTextR.y = paintTextR.width = paintTextR.height = 0;
SwingUtilities.layoutCompoundLabel(label,
label.getFontMetrics(label.getFont()), label.getText(), null,
label.getVerticalAlignment(), label.getHorizontalAlignment(),
label.getVerticalTextPosition(), label.getHorizontalTextPosition(),
paintViewR, paintIconR, paintTextR, label.getIconTextGap());
doPaint(g, paintTextR);
}
代码示例来源:origin: org.codehaus.jtstand/jtstand-desktop
/**
* {@inheritDoc} <p>
*
* Paints a diagonal cross over the text if the comp is of type JLabel,
* does nothing otherwise.
*/
@Override
protected void doPaint(Graphics2D g, JComponent comp, int width,
int height) {
if (!(comp instanceof JLabel)) return;
JLabel label = (JLabel) comp;
Insets insets = label.getInsets(insetss);
paintViewR.x = insets.left;
paintViewR.y = insets.top;
paintViewR.width = width - (insets.left + insets.right);
paintViewR.height = height - (insets.top + insets.bottom);
paintIconR.x = paintIconR.y = paintIconR.width = paintIconR.height = 0;
paintTextR.x = paintTextR.y = paintTextR.width = paintTextR.height = 0;
SwingUtilities.layoutCompoundLabel(label,
label.getFontMetrics(label.getFont()), label.getText(), null,
label.getVerticalAlignment(), label.getHorizontalAlignment(),
label.getVerticalTextPosition(), label.getHorizontalTextPosition(),
paintViewR, paintIconR, paintTextR, label.getIconTextGap());
doPaint(g, paintTextR);
}
代码示例来源:origin: org.java.net.substance/substance
Insets insets = label.getInsets(paintViewInsets);
paintViewR.x = insets.left;
paintViewR.y = insets.top;
内容来源于网络,如有侵权,请联系作者删除!