public void setFont(Font f) {
    if (f != null) {
      String str = f.getName();
      int style = f.getStyle();
      String size = "" + f.getSize();

      for (int i = 0; i < fontList.getModel().getSize(); i++) {
        String listStr = ((String) fontList.getModel().getElementAt(i)).toLowerCase();

        if (listStr.equals(str.toLowerCase())) {
          Object value = fontList.getModel().getElementAt(i);
          fontList.setSelectedValue(value, true);
          fontBox.setText((String) value);
          break;
        }
      }

      switch (style) {
        case Font.PLAIN:
          styleList.setSelectedIndex(0);
          break;
        case Font.ITALIC:
          styleList.setSelectedIndex(2);
          break;
        case Font.BOLD:
          styleList.setSelectedIndex(1);
          break;
        case Font.BOLD | Font.ITALIC:
          styleList.setSelectedIndex(3);
          break;
      }

      boolean found = false;
      for (int i = 0; i < sizeList.getModel().getSize(); i++) {
        String listStr = ((String) sizeList.getModel().getElementAt(i)).toLowerCase();

        if (listStr.equals(size.toLowerCase())) {
          Object value = sizeList.getModel().getElementAt(i);
          sizeList.setSelectedValue(value, true);
          sizeBox.setText((String) value);
          found = true;
          break;
        }
      }
      if (!found) {
        sizeBox.setText(size);
      }
    }
  }
Exemple #2
0
 public void adjustFont(int w, int h) {
   if (h <= 0) return;
   int oldH = rHeight;
   if (font == null) {
     font = getFont();
     fontH = font.getSize();
     rHeight = fontH;
   }
   nHeight = h;
   if (fontH >= h) rHeight = h - 2;
   else rHeight = fontH;
   if ((rHeight < 10) && (fontH > 10)) rHeight = 10;
   if (oldH != rHeight) {
     // Font  curFont = font.deriveFont((float) rHeight);
     Font curFont = DisplayOptions.getFont(font.getName(), font.getStyle(), rHeight);
     setFont(curFont);
   }
   if (rHeight > h) rHeight = h;
 }
  private void updateText() {
    Font font = getFont();
    String styleString;
    switch (font.getStyle()) {
      case Font.PLAIN:
        styleString = jEdit.getProperty("font-selector.plain");
        break;
      case Font.BOLD:
        styleString = jEdit.getProperty("font-selector.bold");
        break;
      case Font.ITALIC:
        styleString = jEdit.getProperty("font-selector.italic");
        break;
      case Font.BOLD | Font.ITALIC:
        styleString = jEdit.getProperty("font-selector.bolditalic");
        break;
      default:
        styleString = "UNKNOWN!!!???";
        break;
    }

    setText(font.getName() + ' ' + font.getSize() + ' ' + styleString);
  }
 ParentDirectoryRenderer() {
   plainFont = UIManager.getFont("Tree.font");
   if (plainFont == null) plainFont = jEdit.getFontProperty("metal.secondary.font");
   boldFont = new Font(plainFont.getName(), Font.BOLD, plainFont.getSize());
 }