javax.swing.JCheckBox.getPreferredSize()方法的使用及代码示例

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

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

JCheckBox.getPreferredSize介绍

暂无

代码示例

代码示例来源:origin: zitmen/thunderstorm

@Override
  public Dimension getPreferredSize() {
    return saveCheckBox.getPreferredSize();     //same size as saveCheckBox
  }
};

代码示例来源:origin: JetBrains/jediterm

@Override
public Dimension getPreferredSize() {
 Dimension size = super.getPreferredSize();
 if (myAnchor != null && myAnchor != this) {
  Dimension anchorSize = myAnchor.getPreferredSize();
  size.width = Math.max(size.width, anchorSize.width);
  size.height = Math.max(size.height, anchorSize.height);
 }
 return size;
}

代码示例来源:origin: SKCraft/Launcher

public TableColumnAdjuster(JTable table) {
  this(table, 16);
  checkBoxWidth = (int) new JCheckBox().getPreferredSize().getWidth();
}

代码示例来源:origin: org.icepdf.os/icepdf-viewer

public Dimension getPreferredSize() {
  Dimension d_check = checkBox.getPreferredSize();
  Dimension d_label = treeLabel.getPreferredSize();
  return new Dimension(d_check.width + d_label.width,
      (d_check.height < d_label.height ?
          d_label.height : d_check.height));
}

代码示例来源:origin: Jamling/SmartIM

@Override
public Dimension getPreferredSize() {
  Dimension dCheck = check.getPreferredSize();
  Dimension dLabel = label.getPreferredSize();
  return new Dimension(dCheck.width + dLabel.width,
      dCheck.height < dLabel.height ? dLabel.height : dCheck.height);
}

代码示例来源:origin: org.n52.wps/52n-wps-install-wizard

public Dimension getPreferredSize() {
 Dimension d_check = check.getPreferredSize();
 Dimension d_label = label.getPreferredSize();
 return new Dimension(d_check.width  + d_label.width,
  (d_check.height < d_label.height ?
   d_label.height : d_check.height));
}

代码示例来源: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: org.netbeans.modules/org-netbeans-modules-cnd-refactoring

private void setColumnWidth(int a) {
  TableColumn col = jTableFields.getColumnModel().getColumn(a);
  JCheckBox box = new JCheckBox();
  int width = (int) box.getPreferredSize().getWidth();
  col.setPreferredWidth(width);
  col.setMinWidth(width);
  col.setMaxWidth(width);
  col.setResizable(false);        
}

代码示例来源:origin: SKCraft/Launcher

@Override
public void setModel(TableModel dataModel) {
  super.setModel(dataModel);
  try {
    getColumnModel().getColumn(0).setMaxWidth((int) new JCheckBox().getPreferredSize().getWidth());
  } catch (ArrayIndexOutOfBoundsException e) {
  }
}

代码示例来源:origin: org.netbeans.modules/org-netbeans-modules-localhistory

@Override
public Dimension getPreferredSize() {
  if (stringDisplayer != null) {
    stringDisplayer.setFont(getFont());
  }
  Dimension d_check = check == null ? null: check.getPreferredSize();
  d_check = d_check == null ? new Dimension(0, checkDim.height) : d_check;
  Dimension d_label = stringDisplayer == null
      ? null : stringDisplayer.getPreferredSize();
  d_label = d_label == null ? new Dimension(0, 0) : d_label;
  return new Dimension(d_check.width  + d_label.width, (d_check.height < d_label.height ? d_label.height : d_check.height));
}

代码示例来源:origin: org.netbeans.modules/org-netbeans-modules-php-project

@Override
public Dimension getPreferredSize() {
  stringDisplayer.setFont(getFont());
  Dimension dCheck = check.getPreferredSize();
  Dimension dLabel = stringDisplayer.getPreferredSize();
  return new Dimension(dCheck.width  + dLabel.width, (dCheck.height < dLabel.height ? dLabel.height : dCheck.height));
}

代码示例来源:origin: com.synaptix/SynaptixSwing

public DefaultCheckBoxFilter(String id, String name, int width, String title, boolean useDefault, Boolean defaultValue) {
  super();
  this.id = id;
  this.name = name;
  checkBox = new JCheckBox(title == null ? "" : title);
  checkBox.setPreferredSize(new Dimension(width, checkBox.getPreferredSize().height));
  if (useDefault) {
    defaultCheckBox = new JCheckBox(title == null ? "Coché" : title);
    defaultCheckBox.setPreferredSize(new Dimension(width, defaultCheckBox.getPreferredSize().height));
    setDefaultValue(defaultValue);
  }
  initialize();
}

代码示例来源:origin: net.sf.sfac/sfac-core

protected void layoutExtraComponents(Container cont) {
  Dimension dim = checkBox.getPreferredSize();
  int posX = x + CONTROL_BUTTON_SPACE;
  int posY = y + ((getUpdatedInsets(cont).top - dim.height) / 2);
  checkBox.setBounds(posX, posY, dim.width, dim.height);
}

代码示例来源:origin: org.netbeans.modules/org-netbeans-modules-localhistory

@Override
public void doLayout() {
  Dimension d_check = check == null ? new Dimension(0, 0) : check.getPreferredSize();
  Dimension d_label = stringDisplayer == null ? new Dimension (0,0) : stringDisplayer.getPreferredSize();
  int y_check = 0;
  if (d_check.height < d_label.height) {
    y_check = (d_label.height - d_check.height) / 2;
  }
  
  if (check != null) {
    check.setLocation(0, y_check);
    check.setBounds(0, y_check, d_check.width, d_check.height);
    if (checkBounds == null)
      checkBounds = check.getBounds();
  }
}

代码示例来源:origin: org.protege/protege-editor-core-application

public void layoutContainer(Container parent) {
    cb.setSize(cb.getPreferredSize());
    cb.setLocation(2, 2);
    parent.getInsets();
    list.setBounds(20, 0, parent.getWidth() - 20, parent.getHeight());
    ListModel listModel = list.getModel();
    for (int i = 0; i < listModel.getSize(); i++) {
      JCheckBox cb = item2CheckBoxMap.get(listModel.getElementAt(i));
      if (cb != null) {
        Rectangle bounds = list.getCellBounds(i, i);
        cb.setBounds(0, bounds.y, bounds.height + 20, bounds.height);
      }
    }
  }
}

代码示例来源:origin: protegeproject/protege

public void layoutContainer(Container parent) {
    cb.setSize(cb.getPreferredSize());
    cb.setLocation(2, 2);
    parent.getInsets();
    list.setBounds(20, 0, parent.getWidth() - 20, parent.getHeight());
    ListModel listModel = list.getModel();
    for (int i = 0; i < listModel.getSize(); i++) {
      JCheckBox cb = item2CheckBoxMap.get(listModel.getElementAt(i));
      if (cb != null) {
        Rectangle bounds = list.getCellBounds(i, i);
        cb.setBounds(0, bounds.y, bounds.height + 20, bounds.height);
      }
    }
  }
}

代码示例来源:origin: com.jidesoft/jide-oss

public CheckBoxTreeCellRenderer(TreeCellRenderer renderer, TristateCheckBox checkBox) {
  _protoType = new TristateCheckBox();
  if (checkBox == null) {
    _checkBox = createCheckBox();
  }
  else {
    _checkBox = checkBox;
  }
  _emptyBox = (JComponent) Box.createHorizontalStrut(_protoType.getPreferredSize().width);
  setLayout(new BorderLayout(0, 0));
  setOpaque(false);
  _actualTreeRenderer = renderer;
}

代码示例来源:origin: org.netbeans.modules/org-netbeans-modules-php-project

@Override
public void doLayout() {
  Dimension dCheck = check.getPreferredSize();
  Dimension dLabel = stringDisplayer.getPreferredSize();
  int yCheck = 0;
  if (dCheck.height < dLabel.height) {
    yCheck = (dLabel.height - dCheck.height) / 2;
  }
  check.setLocation(0, yCheck);
  check.setBounds(0, yCheck, dCheck.width, dCheck.height);
  if (checkBounds == null) {
    checkBounds = check.getBounds();
  }
}

代码示例来源:origin: SKCraft/Launcher

public DefaultTable() {
  setShowGrid(false);
  setRowHeight((int) (Math.max(getRowHeight(), new JCheckBox().getPreferredSize().getHeight() - 2)));
  setIntercellSpacing(new Dimension(0, 0));
  setFillsViewportHeight(true);
  setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
}

代码示例来源:origin: Jamling/SmartIM

@Override
public void doLayout() {
  Dimension dCheck = check.getPreferredSize();
  Dimension dLabel = label.getPreferredSize();
  int yCheck = 0;
  int yLabel = 0;
  if (dCheck.height < dLabel.height)
    yCheck = (dLabel.height - dCheck.height) / 2;
  else
    yLabel = (dCheck.height - dLabel.height) / 2;
  check.setLocation(0, yCheck);
  check.setBounds(0, yCheck, dCheck.width, dCheck.height);
  label.setLocation(dCheck.width, yLabel);
  label.setBounds(dCheck.width, yLabel, dLabel.width, dLabel.height);
}

相关文章

JCheckBox类方法