Exemple #1
0
  public FontChooser(FormDialog dialog, Font font) {
    super(dialog);
    setTitle("Choose Font");

    setLayout(new FormLayout(FormLayout.VERTICAL, FormLayout.CENTER));
    ((FormLayout) getLayout()).setResizeConstant(true);
    fontBox =
        new JComboBox(
            GraphicsEnvironment.getLocalGraphicsEnvironment().getAvailableFontFamilyNames());

    sizeField = new JTextField();
    sizeField.setColumns(2);

    styleBox = new JComboBox();
    styleBox.addItem("Plain");
    styleBox.addItem("Bold");
    styleBox.addItem("Italic");

    setCurrentFont(font);

    FormFactory factory = new FormFactory(this);
    this.add(factory.label(fontBox, "Font"));
    this.add(factory.label(sizeField, "Size"));
    this.add(factory.label(styleBox, "Style"));
  }
Exemple #2
0
 public void applyChanges() {
   Font font =
       new Font(
           (String) fontBox.getSelectedItem(),
           styleBox.getSelectedIndex(),
           Integer.parseInt(sizeField.getText()));
   setReturnValue(font);
 }
Exemple #3
0
 public void setCurrentFont(Font font) {
   sizeField.setText(String.valueOf(font.getSize()));
   fontBox.setSelectedItem(font.getName());
   styleBox.setSelectedIndex(font.getStyle());
 }