javax.swing.JTextField.getMargin()方法的使用及代码示例

x33g5p2x  于2022-01-21 转载在 其他  
字(4.8k)|赞(0)|评价(0)|浏览(139)

本文整理了Java中javax.swing.JTextField.getMargin()方法的一些代码示例,展示了JTextField.getMargin()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。JTextField.getMargin()方法的具体详情如下:
包路径:javax.swing.JTextField
类名称:JTextField
方法名:getMargin

JTextField.getMargin介绍

暂无

代码示例

代码示例来源:origin: org.swinglabs.swingx/swingx-core

/**
 * Returns the insets of the original border (without the margin! Beware of
 * {@link MarginBorder}!).
 * 
 * @return the insets of the border delegate
 */
public Insets getRealBorderInsets() {
  if (borderDelegate == null) {
    //SwingX 1287: null borders are possible and give no insets
    return new Insets(0, 0, 0, 0);
  }
  Insets insets = borderDelegate.getBorderInsets(textField);
  // for some reason, all LnFs add the margin to the insets.
  // we want the insets without the margin, so substract the margin here!!
  // TODO: consider checking, if the current border really includes the
  // margin. Consider:
  // 1. Not only MarginBorder adds margin
  // 2. Calling getBorderInsets(null) is not appropriate, since some
  // Borders can't handle null values.
  Insets margin = textField.getMargin();
  if (margin != null) {
    insets.left -= margin.left;
    insets.right -= margin.right;
    insets.top -= margin.top;
    insets.bottom -= margin.bottom;
  }
  return insets;
}

代码示例来源:origin: org.swinglabs.swingx/swingx-all

/**
 * Returns the insets of the original border (without the margin! Beware of
 * {@link MarginBorder}!).
 * 
 * @return the insets of the border delegate
 */
public Insets getRealBorderInsets() {
  if (borderDelegate == null) {
    //SwingX 1287: null borders are possible and give no insets
    return new Insets(0, 0, 0, 0);
  }
  Insets insets = borderDelegate.getBorderInsets(textField);
  // for some reason, all LnFs add the margin to the insets.
  // we want the insets without the margin, so substract the margin here!!
  // TODO: consider checking, if the current border really includes the
  // margin. Consider:
  // 1. Not only MarginBorder adds margin
  // 2. Calling getBorderInsets(null) is not appropriate, since some
  // Borders can't handle null values.
  Insets margin = textField.getMargin();
  if (margin != null) {
    insets.left -= margin.left;
    insets.right -= margin.right;
    insets.top -= margin.top;
    insets.bottom -= margin.bottom;
  }
  return insets;
}

代码示例来源:origin: com.haulmont.thirdparty/swingx-core

/**
 * Returns the insets of the original border (without the margin! Beware of
 * {@link MarginBorder}!).
 * 
 * @return the insets of the border delegate
 */
public Insets getRealBorderInsets() {
  if (borderDelegate == null) {
    //SwingX 1287: null borders are possible and give no insets
    return new Insets(0, 0, 0, 0);
  }
  Insets insets = borderDelegate.getBorderInsets(textField);
  // for some reason, all LnFs add the margin to the insets.
  // we want the insets without the margin, so substract the margin here!!
  // TODO: consider checking, if the current border really includes the
  // margin. Consider:
  // 1. Not only MarginBorder adds margin
  // 2. Calling getBorderInsets(null) is not appropriate, since some
  // Borders can't handle null values.
  Insets margin = textField.getMargin();
  if (margin != null) {
    insets.left -= margin.left;
    insets.right -= margin.right;
    insets.top -= margin.top;
    insets.bottom -= margin.bottom;
  }
  return insets;
}

代码示例来源:origin: org.bidib.jbidib.swinglabs.swingx/swingx-core

/**
 * Returns the insets of the original border (without the margin! Beware of
 * {@link MarginBorder}!).
 * 
 * @return the insets of the border delegate
 */
public Insets getRealBorderInsets() {
  if (borderDelegate == null) {
    //SwingX 1287: null borders are possible and give no insets
    return new Insets(0, 0, 0, 0);
  }
  Insets insets = borderDelegate.getBorderInsets(textField);
  // for some reason, all LnFs add the margin to the insets.
  // we want the insets without the margin, so substract the margin here!!
  // TODO: consider checking, if the current border really includes the
  // margin. Consider:
  // 1. Not only MarginBorder adds margin
  // 2. Calling getBorderInsets(null) is not appropriate, since some
  // Borders can't handle null values.
  Insets margin = textField.getMargin();
  if (margin != null) {
    insets.left -= margin.left;
    insets.right -= margin.right;
    insets.top -= margin.top;
    insets.bottom -= margin.bottom;
  }
  return insets;
}

代码示例来源:origin: org.japura/japura-gui

@Override
 public void propertyChange(PropertyChangeEvent evt) {
  if (evt.getPropertyName().equals("margin")) {
   Insets margin = getField().getMargin();
   if (margin == null) {
    getField().setBorder(null);
   } else {
    Border border =
      BorderFactory.createEmptyBorder(margin.top, margin.left,
        margin.bottom, margin.right);
    getField().setBorder(border);
   }
  }
 }
});

代码示例来源:origin: chatty/chatty

goal.setBorder(game.getBorder());
goal.setLinkListener(new MyLinkListener());
goal.setMargin(game.getMargin());
add(goal, gbc);

代码示例来源:origin: org.gosu-lang.gosu/gosu-lab

public Insets getBorderInsets( Component c, Insets insets )
 {
  Insets margin = null;
  if( c instanceof AbstractButton )
  {
   margin = ((AbstractButton)c).getMargin();
  }
  else if( c instanceof JToolBar )
  {
   margin = ((JToolBar)c).getMargin();
  }
  else if( c instanceof JTextComponent )
  {
   margin = ((JTextComponent)c).getMargin();
  }
  else if( c instanceof JComboBox )
  {
   margin = ((JTextField)((JComboBox)c).getEditor().getEditorComponent()).getMargin();
  }
  insets.top = (margin != null ? margin.top : 0) + thickness;
  insets.left = (margin != null ? margin.left : 0) + thickness;
  insets.bottom = (margin != null ? margin.bottom : 0) + thickness;
  insets.right = (margin != null ? margin.right : 0) + thickness;
  return insets;
 }
}

相关文章

微信公众号

最新文章

更多

JTextField类方法