本文整理了Java中javax.swing.JLabel.getSize()
方法的一些代码示例,展示了JLabel.getSize()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。JLabel.getSize()
方法的具体详情如下:
包路径:javax.swing.JLabel
类名称:JLabel
方法名:getSize
暂无
代码示例来源:origin: stanfordnlp/CoreNLP
/**
* Updates the number of unique trees matched and the number of total trees matched by the last
* pattern that was searched for. Thread-safe.
*
* @param pattern The pattern
* @param treeMatches count of unique trees matched by the pattern
* @param totalMatches count of total matching instances
*/
public void updateFoundStats(final String pattern, final int treeMatches, final int totalMatches) {
final String txt = "<html>Match stats: " + treeMatches + " unique trees found with " + totalMatches + " total matches.</html>";
SwingUtilities.invokeLater(() -> {
foundStats.setPreferredSize(foundStats.getSize());
foundStats.setText(txt);
if(pattern != null)
addToHistoryList(pattern, treeMatches, totalMatches);
});
}
代码示例来源:origin: tomighty/tomighty
private float originY(WrappedLines lines) {
return (float) (label.getSize().getHeight() / 2.0 - lines.height / 2f);
}
代码示例来源:origin: tomighty/tomighty
private float xFor(TextLayout line) {
return (float) (label.getSize().getWidth() / 2.0 - line.getAdvance() / 2f);
}
代码示例来源:origin: geotools/geotools
/**
* Sets the minimum width of the coordinate display label and the format string used to print
* values.
*/
private void setLabelSizeAndFormat() {
int minLabelWidth = getStringWidth();
Dimension labelSize = label.getSize();
if (labelSize.width < minLabelWidth) {
label.setMinimumSize(new Dimension(minLabelWidth, labelSize.height));
revalidate();
}
StringBuilder sb = new StringBuilder();
sb.append("%").append(intLen).append(".").append(decLen).append("f, ");
sb.append("%").append(intLen).append(".").append(decLen).append("f");
numFormat = sb.toString();
}
代码示例来源:origin: geotools/geotools
/**
* Checks the current label width against its minimum width and, if the current width is larger,
* adjusts the minimum to prevent the label growing and shrinking as the cursor is moved.
*/
private void ensureMinLabelWidth() {
Dimension minDim = label.getMinimumSize();
Dimension curDim = label.getSize();
if (curDim.width > minDim.width) {
label.setMinimumSize(new Dimension(curDim.width, minDim.height));
}
}
}
代码示例来源:origin: nodebox/nodebox
public ColorPanel(ColorComponent colorComponent) {
this.colorComponent = colorComponent;
setLayout(new BoxLayout(this, BoxLayout.X_AXIS));
Dimension d = new Dimension(Integer.MAX_VALUE, 30);
setMinimumSize(d);
setPreferredSize(d);
setMaximumSize(d);
JLabel label = new JLabel(nodebox.util.StringUtils.humanizeName(colorComponent.toString().toLowerCase(Locale.US)), JLabel.RIGHT);
Dimension size = label.getSize();
label.setFont(Theme.SMALL_BOLD_FONT);
label.setForeground(new Color(66, 66, 66));
label.setPreferredSize(new Dimension(75, size.height));
label.setAlignmentY(JLabel.CENTER);
label.setBorder(new EmptyBorder(3, 0, 0, 0));
add(label);
add(Box.createHorizontalStrut(2));
draggableNumber = new DraggableNumber();
draggableNumber.addChangeListener(this);
d = new Dimension(20, Integer.MAX_VALUE);
draggableNumber.setPreferredSize(d);
draggableNumber.setMaximumSize(d);
draggableNumber.setSize(d);
add(draggableNumber);
slider = new ColorSlider(this);
add(slider);
add(Box.createHorizontalStrut(7));
}
代码示例来源:origin: tomighty/tomighty
private WrappedLines breakLines(Graphics2D g) {
Dimension size = label.getSize();
float maxWidth = size.width;
AttributedString attributedText = new AttributedString(label.getText(), textAttributes());
AttributedCharacterIterator textIterator = attributedText.getIterator();
FontRenderContext fontRendering = g.getFontRenderContext();
LineBreakMeasurer measurer = new LineBreakMeasurer(textIterator, fontRendering);
WrappedLines lines = new WrappedLines();
while(measurer.getPosition() < textIterator.getEndIndex()) {
TextLayout layout = measurer.nextLayout(maxWidth);
lines.add(layout);
}
return lines;
}
代码示例来源:origin: bcdev/beam
private ImagePreviewWorker(String imageFilePath, JLabel imageLabel) {
this.imageFilePath = imageFilePath;
this.imageLabel = imageLabel;
this.targetDimension = this.imageLabel.getSize();
}
代码示例来源:origin: senbox-org/snap-desktop
private ImagePreviewWorker(String imageFilePath, JLabel imageLabel) {
this.imageFilePath = imageFilePath;
this.imageLabel = imageLabel;
this.targetDimension = this.imageLabel.getSize();
}
代码示例来源:origin: com.synaptix/SynaptixWidget
@Override
public Dimension getSize() {
if (!needsRotate) {
return super.getSize();
}
Dimension size = super.getSize();
return new Dimension(size.height, size.width);
}
代码示例来源:origin: org.netbeans.api/org-netbeans-modules-vmd-midp
@Override
protected int getLabelWidth() {
return (int)(view.getSize().getWidth() -
image.getSize().getWidth() - state.getSize().getWidth());
}
};
代码示例来源:origin: org.netbeans.api/org-netbeans-modules-vmd-midp
@Override
protected int getLabelWidth() {
return (int)(view.getSize().getWidth() -
image.getSize().getWidth() - state.getSize().getWidth());
}
};
代码示例来源:origin: JetBrains/jediterm
public void doLayout() {
super.doLayout();
if (myLabel != null) {
myErrorLabel.setBorder(BorderFactory.createEmptyBorder(0, myLabel.getSize().width, 0, 0));
}
}
}
代码示例来源: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: senbox-org/snap-desktop
private Dimension getPreviewSize(CRSEnvelope crsEnvelope) {
Dimension preferredSize = messageLabel.getSize();
if (preferredSize.width == 0 || preferredSize.height == 0) {
preferredSize = new Dimension(400, 200);
}
return getPreviewImageSize(preferredSize, crsEnvelope);
}
代码示例来源:origin: bcdev/beam
private Dimension getPreviewSize(CRSEnvelope crsEnvelope) {
Dimension preferredSize = messageLabel.getSize();
if (preferredSize.width == 0 || preferredSize.height == 0) {
preferredSize = new Dimension(400, 200);
}
return getPreviewImageSize(preferredSize, crsEnvelope);
}
代码示例来源:origin: Jamling/SmartIM
public BlingTimer(Component tab, String name) {
super(300, null);
addActionListener(this);
component = tab;
if (component != null && component instanceof JPanel) {
label = (JLabel) ((JPanel) component).getComponent(0);
src = label.getText();
if (src == null || src.isEmpty()) {
src = name;
}
d = label.getSize();
label.setPreferredSize(d);
}
}
代码示例来源:origin: stackoverflow.com
JDialog dialog = new JDialog();
JLabel label = new JLabel("Test");
dialog.add(label);
// pack(), setSize(), validate() in this order will
// set sizes on all components as wished
dialog.pack();
dialog.setSize(800, 600);
dialog.validate();
System.out.println(label.getSize());
代码示例来源:origin: org.geotools/gt-swing
/**
* Checks the current label width against its minimum width and,
* if the current width is larger, adjusts the minimum to prevent
* the label growing and shrinking as the cursor is moved.
*/
private void ensureMinLabelWidth() {
Dimension minDim = label.getMinimumSize();
Dimension curDim = label.getSize();
if (curDim.width > minDim.width) {
label.setMinimumSize(new Dimension(curDim.width, minDim.height));
}
}
}
代码示例来源:origin: RPTools/maptool
/**
* @see javax.swing.JComponent#paintComponent(java.awt.Graphics)
*/
@Override
protected void paintComponent(Graphics g) {
boolean initStateSecondLine = panel.isInitStateSecondLine() && panel.isShowInitState();
Dimension s = name.getSize();
int th = (textHeight + 2) * (initStateSecondLine ? 2 : 1);
backgroundImageLabel.renderLabel((Graphics2D) g, 0, (s.height - th) / 2, s.width, th);
super.paintComponent(g);
}
内容来源于网络,如有侵权,请联系作者删除!