javax.swing.JList.getFont()方法的使用及代码示例

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

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

JList.getFont介绍

暂无

代码示例

代码示例来源:origin: sarxos/webcam-capture

@Override
  public Component getListCellRendererComponent(JList<? extends Webcam> list, Webcam webcam, int i, boolean selected, boolean focused) {

    if (selected) {
      setBackground(list.getSelectionBackground());
      setForeground(list.getSelectionForeground());
    } else {
      setBackground(list.getBackground());
      setForeground(list.getForeground());
    }

    setText(webcam.getName());
    setFont(list.getFont());

    return this;
  }
}

代码示例来源:origin: org.bitbucket.goalhub.simpleide/jedit

private void propertiesChanged()
{
  list.setFont(jEdit.getFontProperty("view.font"));
  list.setFixedCellHeight(list.getFontMetrics(list.getFont())
        .getHeight());
} //}}}

代码示例来源:origin: org.netbeans.api/org-openide-dialogs

Font f = new JList().getFont();
int size = f.getSize();
try {

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

public Component getListCellRendererComponent(JList<? extends Node> list, Node node, int index, boolean isSelected, boolean cellHasFocus) {
    String html = "<html><b>" + StringUtils.humanizeName(node.getName()) + "</b> - " + node.getDescription() + "</html>";
    setText(html);
    if (isSelected) {
      setBackground(Theme.NODE_SELECTION_ACTIVE_BACKGROUND_COLOR);
    } else {
      setBackground(Theme.NODE_SELECTION_BACKGROUND_COLOR);
    }
    setEnabled(list.isEnabled());
    setFont(list.getFont());
    int iconSize = NetworkView.NODE_ICON_SIZE;
    int nodePadding = NetworkView.NODE_PADDING;
    BufferedImage bi = new BufferedImage(iconSize + nodePadding * 2, iconSize + nodePadding * 2, BufferedImage.TYPE_INT_ARGB);
    Graphics g = bi.createGraphics();
    g.setColor(NetworkView.portTypeColor(node.getOutputType()));
    g.fillRect(0, 0, iconSize + nodePadding * 2, iconSize + nodePadding * 2);
    g.drawImage(NetworkView.getImageForNode(node, repository), nodePadding, nodePadding, iconSize, iconSize, null, null);
    setIcon(new ImageIcon(bi));
    setBorder(Theme.BOTTOM_BORDER);
    setOpaque(true);
    return this;
  }
}

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

setFont(list.getFont());
setOpaque(true);
return this;

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

public Renderer(JList list) {
  setFont(list.getFont());
  fgColor = list.getForeground();
  bgColor = list.getBackground();
  bgColorDarker = new Color(
      Math.abs(bgColor.getRed() - DARKER_COLOR_COMPONENT),
      Math.abs(bgColor.getGreen() - DARKER_COLOR_COMPONENT),
      Math.abs(bgColor.getBlue() - DARKER_COLOR_COMPONENT));
  bgSelectionColor = list.getSelectionBackground();
  fgSelectionColor = list.getSelectionForeground();
}

代码示例来源:origin: stackoverflow.com

String[] items = { "one", "<html>normal <b>bold</b> normal</html>" };
JList list = new JList( items );
list.setFont( list.getFont().deriveFont(Font.PLAIN) );

代码示例来源:origin: org.nuiton.jaxx/jaxx-widgets

protected void createTo() {
  $objectMap.put("to", to = new JList());
  
  to.setName("to");
  if (to.getFont() != null) {
    to.setFont(to.getFont().deriveFont((float) 11));
  }
  to.addMouseListener(JAXXUtil.getEventListener(MouseListener.class, "mouseClicked", this, "doMouseClicked__on__to"));
}

代码示例来源:origin: stackoverflow.com

public class CheckboxListCellRenderer extends JCheckBox implements ListCellRenderer {

  public Component getListCellRendererComponent(JList list, Object value, int index, 
      boolean isSelected, boolean cellHasFocus) {

    setComponentOrientation(list.getComponentOrientation());
    setFont(list.getFont());
    setBackground(list.getBackground());
    setForeground(list.getForeground());
    setSelected(isSelected);
    setEnabled(list.isEnabled());

    setText(value == null ? "" : value.toString());  

    return this;
  }
}

代码示例来源:origin: de.sciss/syntaxpane

@Override
public Dimension getPreferredSize() {
  Font font = list.getFont();
  Graphics g = getGraphics();
  FontMetrics fm = g.getFontMetrics(font);
  // total text for this component:
  String total = getMemberName() + getArguments() + getReturnType() + "  ";
  return new Dimension(fm.stringWidth(total) + 20, Math.max(fm.getHeight(), 16));
}

代码示例来源:origin: de.sciss/jsyntaxpane

@Override
public Dimension getPreferredSize() {
  Font font = list.getFont();
  Graphics g = getGraphics();
  FontMetrics fm = g.getFontMetrics(font);
  // total text for this component:
  String total = getMemberName() + getArguments() + getReturnType() + "  ";
  return new Dimension(fm.stringWidth(total) + 20, Math.max(fm.getHeight(), 16));
}

代码示例来源:origin: org.fudaa.business/fudaa-common-corba

public Component getListCellRendererComponent(final JList _list, final Object _value, final int _index,
   final boolean _isSelected, final boolean _cellHasFocus) {
  r_.setText((String) _value);
  r_.setFont(_list.getFont());
  r_.setBackground(_list.getBackground());
  return r_;
 }
}

代码示例来源:origin: org.fudaa.framework.ctulu/ctulu-bu

public final Component getListCellRendererComponent
  (JList _list, Object _value, int _index, boolean _selected, boolean _cellHasFocus)
 {
  setTask((BuTask)_value);
  this.setFont(_list.getFont());
  this.setBackground(_list.getBackground());
  this.setForeground(_list.getForeground());
  return this;
 }
}

代码示例来源:origin: omegat-org/omegat

@Override
public int getPreferredHeight() {
  Rectangle bounds = getList().getCellBounds(0, 0);
  return (int) (getModifiedRowCount() * (bounds == null ? getList().getFont().getSize() : bounds.getHeight()));
}

代码示例来源:origin: robotframework/SwingLibrary

public Component getListCellRendererComponent(JList list, Object value,
    int index, boolean isSelected, boolean cellHasFocus) {
  if (isSelected) {
    setBackground(list.getSelectionBackground());
    setForeground(list.getSelectionForeground());
  } else {
    setBackground(list.getBackground());
    setForeground(list.getForeground());
  }
  String pet = "Pet" + index;
  setUhOhText(pet + " (no image)", list.getFont());
  return this;
}

代码示例来源:origin: org.fudaa.framework.ctulu/ctulu-ui

public static void updateListCellRenderer(final JComponent _target, final JList _list, final int _index,
  final boolean _isSelected, final boolean _cellHasFocus) {
 _target.setComponentOrientation(_list.getComponentOrientation());
 if (_isSelected) {
  _target.setBackground(_list.getSelectionBackground());
  _target.setForeground(_list.getSelectionForeground());
 } else {
  _target.setBackground(_list.getBackground());
  _target.setForeground(_list.getForeground());
 }
 _target.setEnabled(_list.isEnabled());
 _target.setFont(_list.getFont());
 _target.setBorder(_cellHasFocus ? UIManager.getBorder("List.focusCellHighlightBorder") : BORDER_NO_FOCUS);
}

代码示例来源:origin: sensepost/yeti

public Component getListCellRendererComponent(
      JList list, Object value, int index,
      boolean isSelected, boolean hasFocus) {
    setEnabled(list.isEnabled());
    setSelected(((CheckListItem) value).isSelected());
    setFont(list.getFont());
    setBackground(list.getBackground());
    setForeground(list.getForeground());
    setText(value.toString());
    return this;
  }
}

代码示例来源:origin: robo-code/robocode

public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean hasFocus) {
    setEnabled(list.isEnabled());
    setSelected(((CheckListItem) value).isSelected());
    setFont(list.getFont());
    if (isSelected) {
      setBackground(list.getSelectionBackground());
      setForeground(list.getSelectionForeground());            
    } else {
      setBackground(list.getBackground());
      setForeground(list.getForeground());
    }
    setText(value.toString());
    return this;
  }
}

代码示例来源:origin: link-intersystems/blog

@Override
public Component getListCellRendererComponent(JList<? extends E> list,
    E value, int index, boolean isSelected, boolean cellHasFocus) {
  setComponentOrientation(list.getComponentOrientation());
  setFont(list.getFont());
  setText(String.valueOf(value));
  setBackground(list.getBackground());
  setForeground(list.getForeground());
  setSelected(isSelected);
  setEnabled(list.isEnabled());
  return this;
}

代码示例来源:origin: digital-preservation/droid

/**
 * {@inheritDoc}
 * 
 */
@Override
public Component getListCellRendererComponent(JList list, Object value,
    int index, boolean isSelected, boolean cellHasFocus) {
  CheckListCellModel row = (CheckListCellModel) value;
  setSelected(row.isSelected());
  setText(row.getLabel());
  setFont(list.getFont());
  setBackground(list.getBackground());
  return this;
}

相关文章

JList类方法