Beispiel #1
0
  public AboutDialog(View view) {
    super(view, jEdit.getProperty("about.title"), true);

    JPanel content = new JPanel(new BorderLayout());
    content.setBorder(new EmptyBorder(12, 12, 12, 12));
    setContentPane(content);

    content.add(BorderLayout.CENTER, new AboutPanel());

    JPanel buttonPanel = new JPanel();
    buttonPanel.setLayout(new BoxLayout(buttonPanel, BoxLayout.X_AXIS));
    buttonPanel.setBorder(new EmptyBorder(12, 0, 0, 0));

    buttonPanel.add(Box.createGlue());
    close = new JButton(jEdit.getProperty("common.close"));
    close.addActionListener(new ActionHandler());
    getRootPane().setDefaultButton(close);
    buttonPanel.add(close);
    buttonPanel.add(Box.createGlue());
    content.add(BorderLayout.SOUTH, buttonPanel);

    pack();
    setResizable(false);
    setLocationRelativeTo(view);
    show();
  }
    public DisplayUserDirectory() {
      GridBagLayout gbl = new GridBagLayout();
      GridBagConstraints gbc = new GridBagConstraints();
      setLayout(gbl);

      gbc.anchor = GridBagConstraints.NORTHWEST;
      gbc.fill = GridBagConstraints.HORIZONTAL;

      hmlabel.setForeground(Color.black);
      add(hmlabel, gbc);
      add(Box.createHorizontalStrut(10), gbc);
      gbc.gridwidth = GridBagConstraints.REMAINDER;
      add(hmdir, gbc);
      add(Box.createVerticalStrut(15), gbc);

      gbc.gridwidth = 1;
      vjlabel.setForeground(Color.black);
      add(vjlabel, gbc);
      add(Box.createHorizontalStrut(10), gbc);
      gbc.gridwidth = GridBagConstraints.REMAINDER;
      add(vjdir, gbc);
      add(Box.createVerticalStrut(0), gbc);

      gbc.gridwidth = 1;
      vjlabel2.setForeground(Color.black);
      add(vjlabel2, gbc);
      setBorder(
          new CompoundBorder(
              // i18n
              // BorderFactory.createTitledBorder(" User_Directories "),
              BorderFactory.createTitledBorder(Util.getAdmLabel("_admin_User_Directories")),
              BorderFactory.createEmptyBorder(10, 10, 10, 10)));
    }
Beispiel #3
0
  public void setEntity(java.lang.Object ent) {
    Method[] methods = ent.getClass().getDeclaredMethods();
    box.removeAll();
    for (Method m : methods) {
      if (m.getName().toLowerCase().startsWith("get")) {
        String attName = m.getName().substring(3);
        Object result;
        try {
          result = m.invoke(ent, new Object[] {});
          String value = "null";
          if (result != null) value = result.toString();
          JPanel attPane = new JPanel(new FlowLayout(FlowLayout.LEFT));
          attPane.add(new JLabel(attName + " : " + m.getReturnType().getName() + " = " + value));
          box.add(attPane);
        } catch (IllegalArgumentException e) {

          e.printStackTrace();
        } catch (IllegalAccessException e) {

          e.printStackTrace();
        } catch (InvocationTargetException e) {

          e.printStackTrace();
        }
      }
    }
  }
  public HelpUI(Frame parent, String title) {
    sidebar = new Sidebar();
    sidebar.setBorder(new EmptyBorder(10, 10, 10, 10));
    infoView = new JTextPane();
    Dimension d1 = sidebar.getPreferredSize();
    infoView.setPreferredSize(new Dimension(d1.width * 3, d1.height - 5));
    infoView.setEditable(false);

    MouseAdapter ma =
        new MouseAdapter() {
          @Override
          public void mouseClicked(MouseEvent me) {
            SidebarOption sopt = (SidebarOption) me.getComponent();
            if (sel != null) {
              sel.setSelected(false);
              sel.repaint();
            }
            sel = sopt;
            sel.setSelected(true);
            sel.repaint();
            renderInfo();
          }
        };

    general = new SidebarOption("General Info", HELP_GENERAL_LOC);
    general.addMouseListener(ma);
    sidebar.add(general);

    sidebar.add(Box.createVerticalStrut(scy(10)));

    artifact = new SidebarOption("Artifacts", HELP_ARTIFACTS_LOC);
    artifact.addMouseListener(ma);
    sidebar.add(artifact);

    sidebar.add(Box.createVerticalStrut(scy(10)));

    net = new SidebarOption("Networking", HELP_NET_LOC);
    net.addMouseListener(ma);
    sidebar.add(net);

    sidebar.add(Box.createVerticalStrut(scy(10)));

    gpl = new SidebarOption("License", HELP_GPL_LOC);
    gpl.addMouseListener(ma);
    sidebar.add(gpl);

    general.setSelected(true);
    sel = general;

    sidebar.add(Box.createVerticalGlue());

    add(BorderLayout.WEST, sidebar);
    add(BorderLayout.CENTER, new JScrollPane(infoView));
    setResizable(false);
    pack();
    setLocationRelativeTo(parent);
    setTitle(title);

    renderInfo();
  }
Beispiel #5
0
  /** OptionPaneDemo Constructor */
  public OptionPaneDemo(SwingSet2 swingset) {
    // Set the title for this demo, and an icon used to represent this
    // demo inside the SwingSet2 app.
    super(swingset, "OptionPaneDemo", "toolbar/JOptionPane.gif");

    JPanel demo = getDemoPanel();

    demo.setLayout(new BoxLayout(demo, BoxLayout.X_AXIS));

    JPanel bp =
        new JPanel() {
          public Dimension getMaximumSize() {
            return new Dimension(getPreferredSize().width, super.getMaximumSize().height);
          }
        };
    bp.setLayout(new BoxLayout(bp, BoxLayout.Y_AXIS));

    bp.add(Box.createRigidArea(VGAP30));
    bp.add(Box.createRigidArea(VGAP30));

    bp.add(createInputDialogButton());
    bp.add(Box.createRigidArea(VGAP15));
    bp.add(createWarningDialogButton());
    bp.add(Box.createRigidArea(VGAP15));
    bp.add(createMessageDialogButton());
    bp.add(Box.createRigidArea(VGAP15));
    bp.add(createComponentDialogButton());
    bp.add(Box.createRigidArea(VGAP15));
    bp.add(createConfirmDialogButton());
    bp.add(Box.createVerticalGlue());

    demo.add(Box.createHorizontalGlue());
    demo.add(bp);
    demo.add(Box.createHorizontalGlue());
  }
 public ConstraintsPanel() {
   setLayout(new BoxLayout(this, BoxLayout.Y_AXIS));
   add(new DisplayUserDirectory());
   add(Box.createVerticalStrut(15));
   add(new DisplayParentDirectory("", "", false));
   add(Box.createVerticalStrut(15));
   add(new DisplayTemplate("", ""));
   add(Box.createVerticalStrut(15));
   add(new DisplayResults());
   add(Box.createVerticalStrut(15));
 }
Beispiel #7
0
  void initComponents() {
    JPanel mainPanel = new JPanel(new BorderLayout());
    JPanel buttonPanel = new JPanel();
    buttonPanel.setLayout(new BoxLayout(buttonPanel, BoxLayout.X_AXIS));
    Color bgColor = Color.getHSBColor(0.58f, 0.17f, 0.95f);
    buttonPanel.setBackground(bgColor);
    Border empty = BorderFactory.createEmptyBorder(5, 5, 5, 5);
    buttonPanel.setBorder(empty);

    textField = new JTextField(75);
    buttonPanel.add(textField);

    buttonPanel.add(Box.createHorizontalStrut(10));
    searchPHI = new JButton("Search PHI");
    searchPHI.addActionListener(this);
    buttonPanel.add(searchPHI);

    buttonPanel.add(Box.createHorizontalStrut(10));
    searchTrial = new JButton("Search Trial IDs");
    searchTrial.addActionListener(this);
    buttonPanel.add(searchTrial);

    buttonPanel.add(Box.createHorizontalStrut(20));
    buttonPanel.add(Box.createHorizontalGlue());
    saveAs = new JCheckBox("Save As...");
    saveAs.setBackground(bgColor);
    buttonPanel.add(saveAs);

    mainPanel.add(buttonPanel, BorderLayout.NORTH);

    JScrollPane scrollPane = new JScrollPane();
    textPane = new ColorPane();
    // textPane.setEditable(false);
    scrollPane.setViewportView(textPane);
    mainPanel.add(scrollPane, BorderLayout.CENTER);

    JPanel footerPanel = new JPanel();
    footerPanel.setLayout(new BoxLayout(footerPanel, BoxLayout.X_AXIS));
    footerPanel.setBackground(bgColor);
    message = new JLabel("Ready...");
    footerPanel.add(message);
    mainPanel.add(footerPanel, BorderLayout.SOUTH);

    setTitle(windowTitle);
    addWindowListener(
        new WindowAdapter() {
          public void windowClosing(WindowEvent evt) {
            System.exit(0);
          }
        });
    getContentPane().add(mainPanel, BorderLayout.CENTER);
    pack();
    centerFrame();
  }
 /**
  * Create the toolbar. By default this reads the resource file for the definition of the toolbar.
  */
 private Component createToolbar() {
   toolbar = new JToolBar();
   String[] toolKeys = SCSUtility.tokenize(getResourceString("toolbar"));
   for (int i = 0; i < toolKeys.length; i++) {
     if (toolKeys[i].equals("-")) {
       toolbar.add(Box.createHorizontalStrut(5));
     } else {
       toolbar.add(createTool(toolKeys[i]));
     }
   }
   toolbar.add(Box.createHorizontalGlue());
   return toolbar;
 }
  /**
   * Immediately shows the popup at the specified point. {@link getContent()} is called to get the
   * content of the popup.
   *
   * @param showAt Show at the specified point.
   */
  public void show(Point showAt) {

    this.removeAll();

    Box content = new Box(BoxLayout.Y_AXIS);
    UIUtils.setPadding(content, 5, 5, 5, 5);
    content.add(this.getContent());

    this.add(content);

    // For some reason we need to set the size manually.
    content.setPreferredSize(new Dimension(310, content.getPreferredSize().height));

    this.viewer.showPopupAt(this, showAt, true);
  }
Beispiel #10
0
  public Header() {

    super(BoxLayout.LINE_AXIS);

    this.label = new JLabel();

    this.label.setAlignmentY(Component.TOP_ALIGNMENT);
    this.label.setOpaque(false);
    // this.label.setVerticalAlignment (SwingConstants.TOP);

    // this.label.setVerticalTextPosition (SwingConstants.TOP);

    this.add(this.label);
    this.add(Box.createHorizontalGlue());

    this.paintProvider =
        new GradientPainter(Header.defaultPaintLeftColor, Header.defaultPaintRightColor);

    this.setPadding(Header.defaultPadding);

    Font f = this.getFont().deriveFont(Font.BOLD, 14);

    this.setFont(f);
    this.setTitleColor(Header.defaultTitleColor);
  }
    public DisplayResults() {
      GridBagLayout gbl = new GridBagLayout();
      GridBagConstraints gbc = new GridBagConstraints();
      setLayout(gbl);

      gbc.anchor = GridBagConstraints.NORTHWEST;
      gbc.fill = GridBagConstraints.HORIZONTAL;

      text.setForeground(Color.black);
      add(text, gbc);
      gbc.gridy = 0;
      gbc.gridwidth = GridBagConstraints.REMAINDER;
      add(emptyLabel, gbc);
      add(Box.createVerticalStrut(0), gbc);
      add(emptyLabel, gbc);

      /*	 gbc.gridy = 1;
      VTextMsg result = new VTextMsg(sshare, vnmrif, null);
      result.setPreferredSize(new Dimension(300, 30));
      result.setForeground(Color.black);
      add( result, gbc );
      */
      setBorder(
          new CompoundBorder(
              BorderFactory.createTitledBorder("  Results  "),
              BorderFactory.createEmptyBorder(10, 10, 10, 10)));
    }
  /**
   * Adds a JLabel and three JRadioButton instances in a ButtonGroup to the given panel with a
   * GridBagLayout, and returns the buttons in an array.
   */
  private JRadioButton[] addRadioButtonTriplet(String labelText, JPanel panel) {
    GridBagConstraints labelConstraints = new GridBagConstraints();
    labelConstraints.anchor = GridBagConstraints.WEST;
    labelConstraints.insets = new Insets(2, 10, 2, 10);

    GridBagConstraints buttonConstraints = new GridBagConstraints();
    buttonConstraints.insets = labelConstraints.insets;

    GridBagConstraints lastGlueConstraints = new GridBagConstraints();
    lastGlueConstraints.gridwidth = GridBagConstraints.REMAINDER;
    lastGlueConstraints.weightx = 1.0;

    // Create the radio buttons.
    JRadioButton radioButton0 = new JRadioButton();
    JRadioButton radioButton1 = new JRadioButton();
    JRadioButton radioButton2 = new JRadioButton();

    // Put them in a button group.
    ButtonGroup buttonGroup = new ButtonGroup();
    buttonGroup.add(radioButton0);
    buttonGroup.add(radioButton1);
    buttonGroup.add(radioButton2);

    // Add the label and the buttons to the panel.
    panel.add(new JLabel(labelText), labelConstraints);
    panel.add(radioButton0, buttonConstraints);
    panel.add(radioButton1, buttonConstraints);
    panel.add(radioButton2, buttonConstraints);
    panel.add(Box.createGlue(), lastGlueConstraints);

    return new JRadioButton[] {radioButton0, radioButton1, radioButton2};
  }
    protected void initComponents() {
      int border = 2;
      this.setLayout(new BoxLayout(this, BoxLayout.Y_AXIS));
      this.setBorder(BorderFactory.createEmptyBorder(4, 4, 4, 4));

      // Description label
      JPanel descriptionPanel = new JPanel(new GridLayout(0, 1, 0, 0));
      descriptionPanel.setBorder(BorderFactory.createEmptyBorder(border, border, border, border));
      String text = thread.getRetrievable().getName();
      text = text.length() > 40 ? text.substring(0, 37) + "..." : text;
      descriptionLabel = new JLabel(text);
      descriptionPanel.add(descriptionLabel);
      this.add(descriptionPanel);

      // Progrees and cancel button
      JPanel progressPanel = new JPanel();
      progressPanel.setLayout(new BoxLayout(progressPanel, BoxLayout.X_AXIS));
      progressPanel.setBorder(BorderFactory.createEmptyBorder(border, border, border, border));
      progressBar = new JProgressBar(0, 100);
      progressBar.setPreferredSize(new Dimension(100, 16));
      progressPanel.add(progressBar);
      progressPanel.add(Box.createHorizontalStrut(8));
      cancelButton = new JButton("Cancel");
      cancelButton.setBackground(Color.RED);
      cancelButton.addActionListener(
          new ActionListener() {
            public void actionPerformed(ActionEvent event) {
              cancelButtonActionPerformed(event);
            }
          });
      progressPanel.add(cancelButton);
      this.add(progressPanel);
    }
  /**
   * Constructor of class Wizard
   *
   * @param parent the parent frame
   * @param name the title of the dialog
   * @param modal whether the dialog should be modal
   */
  public Wizard(JFrame parent, String name, boolean modal) {
    super(parent, name, modal);

    // Code inspired by http://java.sun.com/developer/technicalArticles/GUI/swing/wizard/

    listeners = new LinkedList<WizardListener>();
    returnCode = -1;
    this.parent = parent;

    panelMap = new HashMap<Object, WizardPanel>();
    panels = new Vector<WizardPanel>();
    firstPanel = null;
    currentPanel = null;

    handler = new EventHandler();

    // Create the main panel

    JPanel buttonPanel = new JPanel();
    Box buttonBox = new Box(BoxLayout.X_AXIS);

    cardPanel = new JPanel();
    cardPanel.setBorder(new EmptyBorder(new Insets(5, 10, 5, 10)));

    cardLayout = new CardLayout();
    cardPanel.setLayout(cardLayout);
    backButton = new JButton("Back");
    nextButton = new JButton("Next");
    cancelButton = new JButton("Cancel");

    backButton.addActionListener(handler);
    nextButton.addActionListener(handler);
    cancelButton.addActionListener(handler);

    backButton.setEnabled(false);

    buttonPanel.setLayout(new BorderLayout());
    buttonPanel.add(new JSeparator(), BorderLayout.NORTH);

    buttonBox.setBorder(new EmptyBorder(new Insets(5, 10, 5, 10)));
    buttonBox.add(backButton);
    buttonBox.add(Box.createHorizontalStrut(10));
    buttonBox.add(nextButton);
    buttonBox.add(Box.createHorizontalStrut(30));
    buttonBox.add(cancelButton);
    buttonPanel.add(buttonBox, java.awt.BorderLayout.EAST);
    getContentPane().add(buttonPanel, java.awt.BorderLayout.SOUTH);
    getContentPane().add(cardPanel, java.awt.BorderLayout.CENTER);

    pack();
  }
  public void createFileChooserDemo() {
    theImage = new JLabel("");
    jpgIcon = createImageIcon("filechooser/jpgIcon.jpg", "jpg image");
    gifIcon = createImageIcon("filechooser/gifIcon.gif", "gif image");

    JPanel demoPanel = getDemoPanel();
    demoPanel.setLayout(new BoxLayout(demoPanel, BoxLayout.Y_AXIS));

    JPanel innerPanel = new JPanel();
    innerPanel.setLayout(new BoxLayout(innerPanel, BoxLayout.X_AXIS));

    demoPanel.add(Box.createRigidArea(VGAP20));
    demoPanel.add(innerPanel);
    demoPanel.add(Box.createRigidArea(VGAP20));

    innerPanel.add(Box.createRigidArea(HGAP20));

    // Create a panel to hold buttons
    JPanel buttonPanel =
        new JPanel() {
          public Dimension getMaximumSize() {
            return new Dimension(getPreferredSize().width, super.getMaximumSize().height);
          }
        };
    buttonPanel.setLayout(new BoxLayout(buttonPanel, BoxLayout.Y_AXIS));

    buttonPanel.add(Box.createRigidArea(VGAP15));
    buttonPanel.add(createPlainFileChooserButton());
    buttonPanel.add(Box.createRigidArea(VGAP15));
    buttonPanel.add(createPreviewFileChooserButton());
    buttonPanel.add(Box.createRigidArea(VGAP15));
    buttonPanel.add(createCustomFileChooserButton());
    buttonPanel.add(Box.createVerticalGlue());

    // Create a panel to hold the image
    JPanel imagePanel = new JPanel();
    imagePanel.setLayout(new BorderLayout());
    imagePanel.setBorder(new BevelBorder(BevelBorder.LOWERED));
    JScrollPane scroller = new JScrollPane(theImage);
    scroller.getVerticalScrollBar().setUnitIncrement(10);
    scroller.getHorizontalScrollBar().setUnitIncrement(10);
    imagePanel.add(scroller, BorderLayout.CENTER);

    // add buttons and image panels to inner panel
    innerPanel.add(buttonPanel);
    innerPanel.add(Box.createRigidArea(HGAP30));
    innerPanel.add(imagePanel);
    innerPanel.add(Box.createRigidArea(HGAP20));
  }
Beispiel #16
0
  public ComboBoxDemo2() {
    setLayout(new BoxLayout(this, BoxLayout.PAGE_AXIS));
    String[] patternExamples = {
      "dd MMMMM yyyy",
      "dd.MM.yy",
      "MM/dd/yy",
      "yyyy.MM.dd G 'at' hh:mm:ss z",
      "EEE, MMM d, ''yy",
      "h:mm a",
      "H:mm:ss:SSS",
      "K:mm a,z",
      "yyyy.MMMMM.dd GGG hh:mm aaa"
    };

    currentPattern = patternExamples[0];

    // Set up the UI for selecting a pattern.
    JLabel patternLabel1 = new JLabel("Enter the pattern string or");
    JLabel patternLabel2 = new JLabel("select one from the list:");

    JComboBox patternList = new JComboBox(patternExamples);
    patternList.setEditable(true);
    patternList.addActionListener(this);

    // Create the UI for displaying result.
    JLabel resultLabel = new JLabel("Current Date/Time", JLabel.LEADING); // == LEFT
    result = new JLabel(" ");
    result.setForeground(Color.black);
    result.setBorder(
        BorderFactory.createCompoundBorder(
            BorderFactory.createLineBorder(Color.black),
            BorderFactory.createEmptyBorder(5, 5, 5, 5)));

    // Lay out everything.
    JPanel patternPanel = new JPanel();
    patternPanel.setLayout(new BoxLayout(patternPanel, BoxLayout.PAGE_AXIS));
    patternPanel.add(patternLabel1);
    patternPanel.add(patternLabel2);
    patternList.setAlignmentX(Component.LEFT_ALIGNMENT);
    patternPanel.add(patternList);

    JPanel resultPanel = new JPanel(new GridLayout(0, 1));
    resultPanel.add(resultLabel);
    resultPanel.add(result);

    patternPanel.setAlignmentX(Component.LEFT_ALIGNMENT);
    resultPanel.setAlignmentX(Component.LEFT_ALIGNMENT);

    add(patternPanel);
    add(Box.createRigidArea(new Dimension(0, 10)));
    add(resultPanel);

    setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10));

    reformat();
  } // constructor
Beispiel #17
0
public class AttributesPanel extends JComponent {
  private boolean settingcollection = false;
  private Box box = Box.createVerticalBox();

  Vector tobeduplicated = new Vector();

  public AttributesPanel() {
    this.setLayout(new BorderLayout());
    super.add(box, BorderLayout.CENTER);
  }

  public void setEntity(java.lang.Object ent) {
    Method[] methods = ent.getClass().getDeclaredMethods();
    box.removeAll();
    for (Method m : methods) {
      if (m.getName().toLowerCase().startsWith("get")) {
        String attName = m.getName().substring(3);
        Object result;
        try {
          result = m.invoke(ent, new Object[] {});
          String value = "null";
          if (result != null) value = result.toString();
          JPanel attPane = new JPanel(new FlowLayout(FlowLayout.LEFT));
          attPane.add(new JLabel(attName + " : " + m.getReturnType().getName() + " = " + value));
          box.add(attPane);
        } catch (IllegalArgumentException e) {

          e.printStackTrace();
        } catch (IllegalAccessException e) {

          e.printStackTrace();
        } catch (InvocationTargetException e) {

          e.printStackTrace();
        }
      }
    }
  }

  public static void main(String[] args) throws IllegalArgumentException, IllegalAccessException {

    JFrame jf = new JFrame();

    AttributesPanel colpal = new AttributesPanel();
    colpal.setEntity(new FrameFact("hola"));
    colpal.setEntity(new FrameFact("hola"));
    jf.getContentPane().add(colpal);
    jf.pack();
    jf.show();
    jf.pack();
  }
}
 public Component getListCellRendererComponent(
     JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) {
   if (containerBox == null) {
     containerBox = Box.createHorizontalBox();
     checkBox = new JCheckBox();
     checkBox.setEnabled(isEnabled());
     checkBox.setFont(getFont());
     checkBox.setFocusPainted(false);
     checkBox.setBorderPainted(true);
     checkBox.setBorder(
         isSelected ? UIManager.getBorder("List.focusCellHighlightBorder") : noFocusBorder);
     containerBox.add(checkBox);
   }
   checkBox.setBackground(isSelected ? getSelectionBackground() : getBackground());
   checkBox.setForeground(isSelected ? getSelectionForeground() : getForeground());
   if (value != null) {
     ListItem item = (ListItem) value;
     checkBox.setText(item.dataItem.toString());
     checkBox.setSelected(item.selected);
   }
   return containerBox;
 }
Beispiel #19
0
  private static JPanel createTextFieldAndListPanel(
      String label, JTextField textField, JList list) {
    GridBagLayout layout = new GridBagLayout();
    JPanel panel = new JPanel(layout);

    GridBagConstraints cons = new GridBagConstraints();
    cons.gridx = cons.gridy = 0;
    cons.gridwidth = cons.gridheight = 1;
    cons.fill = GridBagConstraints.BOTH;
    cons.weightx = 1.0f;

    JLabel _label = new JLabel(jEdit.getProperty(label));
    layout.setConstraints(_label, cons);
    panel.add(_label);

    cons.gridy = 1;
    Component vs = Box.createVerticalStrut(6);
    layout.setConstraints(vs, cons);
    panel.add(vs);

    cons.gridy = 2;
    layout.setConstraints(textField, cons);
    panel.add(textField);

    cons.gridy = 3;
    vs = Box.createVerticalStrut(6);
    layout.setConstraints(vs, cons);
    panel.add(vs);

    cons.gridy = 4;
    cons.gridheight = GridBagConstraints.REMAINDER;
    cons.weighty = 1.0f;
    JScrollPane scroller = new JScrollPane(list);
    layout.setConstraints(scroller, cons);
    panel.add(scroller);

    return panel;
  }
Beispiel #20
0
  protected void paintComponent(Graphics g) {

    if (this.paintProvider != null) {

      Paint p = this.paintProvider.getPaint(this);

      Graphics2D g2d = (Graphics2D) g;

      int w = this.getWidth();
      int h = this.getHeight();

      g2d.setPaint(p);
      g2d.fillRect(0, 0, w, h);

      this.setOpaque(false);
    }

    super.paintComponent(g);

    // this.setOpaque (true);

  }
    private JTextField addField(JPanel directoryPanel, String label, String defaultText) {
      JTextField field = new JTextField(defaultText);

      directoryPanel.add(new JLabel(label, SwingConstants.RIGHT));

      Box fieldBox = new Box(BoxLayout.Y_AXIS);
      fieldBox.add(Box.createGlue());
      Dimension dim = field.getPreferredSize();
      dim.width = Integer.MAX_VALUE;
      field.setMaximumSize(dim);
      fieldBox.add(field);
      fieldBox.add(Box.createGlue());
      directoryPanel.add(fieldBox);
      JButton choose = new JButton("Choose...");
      choose.setRequestFocusEnabled(false);
      choose.addActionListener(new ActionHandler(field));
      directoryPanel.add(choose);

      return field;
    }
Beispiel #22
0
  public GuideCertInstallPane() {
    super();
    setLayout(new GridBagLayout());

    ResourceSet resource = KeyCertUtility.getKeyCertWizardResourceSet();

    setBorder(
        new TitledBorder(
            new CompoundBorder(
                new EtchedBorder(),
                new EmptyBorder(
                    COMPONENT_SPACE, COMPONENT_SPACE, COMPONENT_SPACE, COMPONENT_SPACE)),
            resource.getString("GuideCertInstallPane", "title")));

    int y = 0;

    GridBagUtil.constrain(
        this,
        new MultilineLabel(resource.getString("GuideCertInstallPane", "explain")),
        0,
        ++y,
        1,
        1,
        1.0,
        0.0,
        GridBagConstraints.NORTH,
        GridBagConstraints.BOTH,
        0,
        0,
        SEPARATED_COMPONENT_SPACE,
        0);

    GridBagUtil.constrain(
        this,
        Box.createVerticalGlue(),
        0,
        ++y,
        1,
        1,
        1.0,
        1.0,
        GridBagConstraints.NORTH,
        GridBagConstraints.BOTH,
        0,
        0,
        0,
        0);

    GridBagUtil.constrain(
        this,
        new JLabel(resource.getString(null, "clickNextToContinue")),
        0,
        ++y,
        1,
        1,
        1.0,
        0.0,
        GridBagConstraints.NORTH,
        GridBagConstraints.BOTH,
        0,
        0,
        0,
        0);
  }
Beispiel #23
0
  // {{{ init() method
  private void init() {
    EditBus.addToBus(this);

    /* Setup panes */
    JPanel content = new JPanel(new BorderLayout(12, 12));
    content.setBorder(new EmptyBorder(12, 12, 12, 12));
    setContentPane(content);

    tabPane = new JTabbedPane();
    tabPane.addTab(jEdit.getProperty("manage-plugins.title"), manager = new ManagePanel(this));
    tabPane.addTab(
        jEdit.getProperty("update-plugins.title"), updater = new InstallPanel(this, true));
    tabPane.addTab(
        jEdit.getProperty("install-plugins.title"), installer = new InstallPanel(this, false));
    EditBus.addToBus(installer);
    content.add(BorderLayout.CENTER, tabPane);

    tabPane.addChangeListener(new ListUpdater());

    /* Create the buttons */
    Box buttons = new Box(BoxLayout.X_AXIS);

    ActionListener al = new ActionHandler();
    mgrOptions = new JButton(jEdit.getProperty("plugin-manager.mgr-options"));
    mgrOptions.addActionListener(al);
    pluginOptions = new JButton(jEdit.getProperty("plugin-manager.plugin-options"));
    pluginOptions.addActionListener(al);
    done = new JButton(jEdit.getProperty("plugin-manager.done"));
    done.addActionListener(al);

    buttons.add(Box.createGlue());
    buttons.add(mgrOptions);
    buttons.add(Box.createHorizontalStrut(6));
    buttons.add(pluginOptions);
    buttons.add(Box.createHorizontalStrut(6));
    buttons.add(done);
    buttons.add(Box.createGlue());

    getRootPane().setDefaultButton(done);

    content.add(BorderLayout.SOUTH, buttons);

    setDefaultCloseOperation(DISPOSE_ON_CLOSE);

    setIconImage(GUIUtilities.getPluginIcon());

    pack();
    GUIUtilities.loadGeometry(this, parent, "plugin-manager");
    GUIUtilities.addSizeSaver(this, parent, "plugin-manager");
    setVisible(true);
  } // }}}
  public void doInit() {

    final InviteResponseMessageBox _this = this;

    if (!this.message.isDealtWith()) {

      // Show the response.
      this.responseBox = new Box(BoxLayout.Y_AXIS);

      this.add(this.responseBox);

      JComponent l =
          UIUtils.createBoldSubHeader(
              String.format(
                  "%s the invitation", (this.message.isAccepted() ? "Accepted" : "Rejected")),
              (this.message.isAccepted()
                  ? Constants.ACCEPTED_ICON_NAME
                  : Constants.REJECTED_ICON_NAME));

      this.responseBox.add(l);
      this.responseBox.setBorder(UIUtils.createPadding(5, 5, 0, 5));

      if (this.message.isAccepted()) {

        if ((this.message.getEditorName() != null) || (this.message.getEditorAvatar() != null)) {

          JTextPane desc =
              UIUtils.createHelpTextPane(
                  "Additionally they provided the following name/avatar.", this.projectViewer);

          this.responseBox.add(Box.createVerticalStrut(5));

          this.responseBox.add(desc);
          desc.setBorder(null);
          desc.setSize(new Dimension(UIUtils.getPopupWidth() - 20, desc.getPreferredSize().height));

          Box editorInfo = new Box(BoxLayout.X_AXIS);
          editorInfo.setAlignmentX(Component.LEFT_ALIGNMENT);
          editorInfo.setBorder(UIUtils.createPadding(5, 5, 5, 5));

          this.responseBox.add(editorInfo);

          if (this.message.getEditorAvatar() != null) {

            JLabel avatar = new JLabel();

            avatar.setAlignmentY(Component.TOP_ALIGNMENT);
            avatar.setVerticalAlignment(SwingConstants.TOP);

            editorInfo.add(avatar);
            avatar.setOpaque(false);

            avatar.setIcon(
                new ImageIcon(UIUtils.getScaledImage(_this.message.getEditorAvatar(), 50)));

            avatar.setBorder(
                new CompoundBorder(UIUtils.createPadding(0, 0, 0, 5), UIUtils.createLineBorder()));
          }

          if (this.message.getEditorName() != null) {

            JLabel name = new JLabel(this.message.getEditorName());
            editorInfo.add(name);

            name.setBorder(null);
            name.setAlignmentY(Component.TOP_ALIGNMENT);
            name.setVerticalAlignment(JLabel.TOP);
            name.setAlignmentX(Component.LEFT_ALIGNMENT);
            name.setFont(
                name.getFont()
                    .deriveFont((float) UIUtils.getScaledFontSize(14))
                    .deriveFont(java.awt.Font.PLAIN));
          }
        }
      }

      final EditorEditor ed = this.message.getEditor();

      JButton ok = new JButton("Ok, got it");

      ok.addActionListener(
          new ActionAdapter() {

            public void actionPerformed(ActionEvent ev) {

              try {

                if (_this.message.isAccepted()) {

                  ed.setEditorStatus(EditorEditor.EditorStatus.current);

                  if (_this.message.getEditorName() != null) {

                    ed.setName(_this.message.getEditorName());
                  }

                  if (_this.message.getEditorAvatar() != null) {

                    ed.setAvatar(_this.message.getEditorAvatar());
                  }

                  EditorsEnvironment.updateEditor(ed);

                  // Is this response for an invite message or just out of the blue from a web
                  // service invite?
                  if (!EditorsEnvironment.hasSentMessageOfTypeToEditor(
                      ed, InviteMessage.MESSAGE_TYPE)) {

                    EditorsEnvironment.sendUserInformationToEditor(ed, null, null, null);
                  }

                } else {

                  ed.setEditorStatus(EditorEditor.EditorStatus.rejected);

                  EditorsEnvironment.updateEditor(ed);
                }

                _this.message.setDealtWith(true);

                EditorsEnvironment.updateMessage(_this.message);

                _this.responseBox.setVisible(false);

              } catch (Exception e) {

                Environment.logError("Unable to update editor: " + ed, e);

                UIUtils.showErrorMessage(
                    _this.projectViewer,
                    "Unable to update {editor}, please contact Quoll Writer support for assitance.");

                return;
              }
            }
          });

      JButton[] buts = new JButton[] {ok};

      JPanel bb = UIUtils.createButtonBar2(buts, Component.LEFT_ALIGNMENT);
      bb.setOpaque(false);
      bb.setAlignmentX(Component.LEFT_ALIGNMENT);
      bb.setBorder(UIUtils.createPadding(5, 0, 0, 0));

      this.responseBox.add(bb);

      return;
    }

    boolean accepted = this.message.isAccepted();
    String iconName = (accepted ? Constants.ACCEPTED_ICON_NAME : Constants.REJECTED_ICON_NAME);

    String message = "Accepted invitation to be {an editor}";

    if (!accepted) {

      message = "Rejected invitation to be {an editor}";
    }

    JComponent h = UIUtils.createBoldSubHeader(message, iconName);

    this.add(h);
  }
  /**
   * Create the pixel location panel
   *
   * @param labelFont the font for the labels
   * @return the location panel
   */
  public JPanel createLocationPanel(Font labelFont) {

    // create a location panel
    JPanel locationPanel = new JPanel();
    locationPanel.setLayout(new FlowLayout());
    Box hBox = Box.createHorizontalBox();

    // create the labels
    rowLabel = new JLabel("Row:");
    colLabel = new JLabel("Column:");

    // create the text fields
    colValue = new JTextField(Integer.toString(colIndex + numberBase), 6);
    colValue.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            displayPixelInformation(colValue.getText(), rowValue.getText());
          }
        });
    rowValue = new JTextField(Integer.toString(rowIndex + numberBase), 6);
    rowValue.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            displayPixelInformation(colValue.getText(), rowValue.getText());
          }
        });

    // set up the next and previous buttons
    setUpNextAndPreviousButtons();

    // set up the font for the labels
    colLabel.setFont(labelFont);
    rowLabel.setFont(labelFont);
    colValue.setFont(labelFont);
    rowValue.setFont(labelFont);

    // add the items to the vertical box and the box to the panel
    hBox.add(Box.createHorizontalGlue());
    hBox.add(rowLabel);
    hBox.add(rowPrevButton);
    hBox.add(rowValue);
    hBox.add(rowNextButton);
    hBox.add(Box.createHorizontalStrut(10));
    hBox.add(colLabel);
    hBox.add(colPrevButton);
    hBox.add(colValue);
    hBox.add(colNextButton);
    locationPanel.add(hBox);
    hBox.add(Box.createHorizontalGlue());

    return locationPanel;
  }
Beispiel #26
0
  /** Create and layout the visual components. */
  private void initComponents() {
    setTitle("Chart Settings");
    setSize(new Dimension(450, 375));
    setResizable(false);

    addWindowListener(
        new java.awt.event.WindowAdapter() {
          public void windowClosing(java.awt.event.WindowEvent evt) {
            closeDialog(evt);
          }
        });

    Box mainView = new Box(VERTICAL);
    getContentPane().add(mainView);

    Box row;

    Box yAxisView = new Box(VERTICAL);
    yAxisView.setBorder(border);
    mainView.add(yAxisView);

    yAutoScaleCheckbox = new JCheckBox("Auto Scale");
    yAutoScaleCheckbox.addActionListener(
        new java.awt.event.ActionListener() {
          public void actionPerformed(java.awt.event.ActionEvent evt) {
            yAutoScaleCheckboxActionPerformed(evt);
          }
        });
    row = new Box(HORIZONTAL);
    row.add(Box.createHorizontalGlue());
    row.add(yAutoScaleCheckbox);
    yAxisView.add(row);

    yAxisMinValueField = new JTextField(10);
    yAxisMinValueField.setMaximumSize(yAxisMinValueField.getPreferredSize());
    yAxisMinValueField.setHorizontalAlignment(javax.swing.JTextField.RIGHT);
    yAxisMinValueField.addFocusListener(
        new FocusAdapter() {
          public void focusGained(FocusEvent event) {
            yAxisMinValueField.selectAll();
          }

          public void focusLost(FocusEvent event) {
            yAxisMinValueField.setCaretPosition(0);
            yAxisMinValueField.moveCaretPosition(0);
          }
        });
    row = new Box(HORIZONTAL);
    row.add(Box.createHorizontalGlue());
    row.add(new JLabel("Min:"));
    row.add(yAxisMinValueField);
    yAxisView.add(row);

    yAxisMaxValueField = new JTextField(10);
    yAxisMaxValueField.setMaximumSize(yAxisMaxValueField.getPreferredSize());
    yAxisMaxValueField.setHorizontalAlignment(javax.swing.JTextField.RIGHT);
    yAxisMaxValueField.addFocusListener(
        new FocusAdapter() {
          public void focusGained(FocusEvent event) {
            yAxisMaxValueField.selectAll();
          }

          public void focusLost(FocusEvent event) {
            yAxisMaxValueField.setCaretPosition(0);
            yAxisMaxValueField.moveCaretPosition(0);
          }
        });
    row = new Box(HORIZONTAL);
    row.add(Box.createHorizontalGlue());
    row.add(new JLabel("Max:"));
    row.add(yAxisMaxValueField);
    yAxisView.add(row);

    yAxisDivisionsField = new JTextField(10);
    yAxisDivisionsField.setMaximumSize(yAxisDivisionsField.getPreferredSize());
    yAxisDivisionsField.setHorizontalAlignment(JTextField.RIGHT);
    yAxisDivisionsField.addFocusListener(
        new FocusAdapter() {
          public void focusGained(FocusEvent event) {
            yAxisDivisionsField.selectAll();
          }

          public void focusLost(FocusEvent event) {
            yAxisDivisionsField.setCaretPosition(0);
            yAxisDivisionsField.moveCaretPosition(0);
          }
        });
    row = new Box(HORIZONTAL);
    row.add(Box.createHorizontalGlue());
    row.add(new JLabel("Major Divisions:"));
    row.add(yAxisDivisionsField);
    yAxisView.add(row);

    Box buttonView = new Box(HORIZONTAL);
    mainView.add(buttonView);
    buttonView.add(Box.createHorizontalGlue());

    JButton revertButton = new JButton("Revert");
    revertButton.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent event) {
            revertButtonActionPerformed(event);
          }
        });
    buttonView.add(revertButton);

    JButton applyButton = new JButton("Apply");
    applyButton.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent event) {
            applyButtonActionPerformed(event);
          }
        });
    buttonView.add(applyButton);

    pack();
  }
  /**
   * Creates a new <code>AddPersonDialog</code> with a given owner <code>JFrame</code> and <code>
   * FamilyTree</code>.
   */
  public AddPersonDialog(JFrame owner, FamilyTree tree) {
    super(owner, "Add New Person", true /* modal */);

    Container pane = this.getContentPane();
    pane.setLayout(new BorderLayout());

    JPanel infoPanel = new JPanel();
    infoPanel.setLayout(new GridLayout(0, 2));
    Border infoBorder = BorderFactory.createEmptyBorder(5, 5, 5, 5);
    infoPanel.setBorder(infoBorder);

    infoPanel.add(new JLabel("id:"));
    final JTextField idField = new JTextField();
    infoPanel.add(idField);

    final ButtonGroup group = new ButtonGroup();

    final JRadioButton male = new JRadioButton("male", true);
    group.add(male);
    infoPanel.add(male);

    final JRadioButton female = new JRadioButton("female");
    group.add(female);
    infoPanel.add(female);

    infoPanel.add(new JLabel("First name:"));
    final JTextField firstNameField = new JTextField();
    infoPanel.add(firstNameField);

    infoPanel.add(new JLabel("Middle name:"));
    final JTextField middleNameField = new JTextField();
    infoPanel.add(middleNameField);

    infoPanel.add(new JLabel("Last name:"));
    final JTextField lastNameField = new JTextField();
    infoPanel.add(lastNameField);

    infoPanel.add(new JLabel("Date of Birth:"));
    final JTextField dobField = new JTextField();
    infoPanel.add(dobField);

    infoPanel.add(new JLabel("Date of Death:"));
    final JTextField dodField = new JTextField();
    infoPanel.add(dodField);

    infoPanel.add(new JLabel("Father:"));
    JPanel fatherPanel = new JPanel();
    fatherPanel.setLayout(new FlowLayout());
    final JTextField fatherText = new JTextField("Click to choose");
    fatherText.setEditable(false);
    fatherText.addMouseListener(
        new MouseAdapter() {
          public void mouseClicked(MouseEvent e) {
            // Pop up a PersonChooseDialog, place name in TextField
            System.out.println("Clicked father");
          }
        });
    fatherPanel.add(fatherText);
    infoPanel.add(fatherPanel);

    infoPanel.add(new JLabel("Mother:"));
    JPanel motherPanel = new JPanel();
    motherPanel.setLayout(new FlowLayout());
    final JTextField motherText = new JTextField("Click to choose");
    motherText.setEditable(false);
    motherText.addMouseListener(
        new MouseAdapter() {
          public void mouseClicked(MouseEvent e) {
            // Pop up a PersonChooseDialog, place name in TextField
            System.out.println("Clicked mother");
          }
        });
    motherPanel.add(motherText);
    infoPanel.add(motherPanel);

    pane.add(infoPanel, BorderLayout.NORTH);

    // "Add" and "Cancel" buttons
    JPanel buttonPanel = new JPanel();
    buttonPanel.setLayout(new BoxLayout(buttonPanel, BoxLayout.X_AXIS));
    buttonPanel.add(Box.createHorizontalGlue());

    JButton addButton = new JButton("Add");
    addButton.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            // Create a new person based on the information entered in
            // this dialog
            int id = 0;
            try {
              id = Integer.parseInt(idField.getText());

            } catch (NumberFormatException ex) {
              error("Invalid id: " + idField.getText());
              return;
            }

            String text = null;

            text = dobField.getText();
            Date dob = null;
            if (text != null && !text.equals("")) {
              dob = parseDate(dobField.getText());
              if (dob == null) {
                // Parse error
                return;
              }
            }

            text = dodField.getText();
            Date dod = null;
            if (text != null && !text.equals("")) {
              dod = parseDate(dodField.getText());
              if (dod == null) {
                // Parse error
                return;
              }
            }

            Person.Gender gender;
            if (group.getSelection().equals(male)) {
              gender = Person.MALE;

            } else {
              gender = Person.FEMALE;
            }

            // Okay, everything parsed alright
            newPerson = new Person(id, gender);
            newPerson.setFirstName(firstNameField.getText());
            newPerson.setMiddleName(middleNameField.getText());
            newPerson.setLastName(lastNameField.getText());
            newPerson.setDateOfBirth(dob);
            newPerson.setDateOfDeath(dod);

            if (mother != null) {
              newPerson.setMother(mother);
            }

            if (father != null) {
              newPerson.setFather(father);
            }

            // We're all happy
            AddPersonDialog.this.dispose();
          }
        });
    buttonPanel.add(addButton);

    buttonPanel.add(Box.createHorizontalGlue());

    JButton cancelButton = new JButton("Cancel");
    cancelButton.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            // Read my lips, no new Person!

            AddPersonDialog.this.newPerson = null;

            AddPersonDialog.this.dispose();
          }
        });
    buttonPanel.add(cancelButton);

    buttonPanel.add(Box.createHorizontalGlue());

    pane.add(buttonPanel, BorderLayout.SOUTH);
  }
  public ErrorListDialog(
      Frame frame, String title, String caption, Vector messages, boolean showPluginMgrButton) {
    super(frame, title, true);

    JPanel content = new JPanel(new BorderLayout(12, 12));
    content.setBorder(new EmptyBorder(12, 12, 12, 12));
    setContentPane(content);

    Box iconBox = new Box(BoxLayout.Y_AXIS);
    iconBox.add(new JLabel(UIManager.getIcon("OptionPane.errorIcon")));
    iconBox.add(Box.createGlue());
    content.add(BorderLayout.WEST, iconBox);

    JPanel centerPanel = new JPanel(new BorderLayout());

    JLabel label = new JLabel(caption);
    label.setBorder(new EmptyBorder(0, 0, 6, 0));
    centerPanel.add(BorderLayout.NORTH, label);

    JList errors = new JList(messages);
    errors.setCellRenderer(new ErrorListCellRenderer());
    errors.setVisibleRowCount(Math.min(messages.size(), 4));

    JScrollPane scrollPane =
        new JScrollPane(
            errors, JScrollPane.VERTICAL_SCROLLBAR_ALWAYS, JScrollPane.HORIZONTAL_SCROLLBAR_ALWAYS);
    Dimension size = scrollPane.getPreferredSize();
    size.width = Math.min(size.width, 400);
    scrollPane.setPreferredSize(size);

    centerPanel.add(BorderLayout.CENTER, scrollPane);

    content.add(BorderLayout.CENTER, centerPanel);

    Box buttons = new Box(BoxLayout.X_AXIS);
    buttons.add(Box.createGlue());

    ok = new JButton(jEdit.getProperty("common.ok"));
    ok.addActionListener(new ActionHandler());

    if (showPluginMgrButton) {
      pluginMgr = new JButton(jEdit.getProperty("error-list.plugin-manager"));
      pluginMgr.addActionListener(new ActionHandler());
      buttons.add(pluginMgr);
      buttons.add(Box.createHorizontalStrut(6));
    }

    buttons.add(ok);

    buttons.add(Box.createGlue());
    content.add(BorderLayout.SOUTH, buttons);

    getRootPane().setDefaultButton(ok);

    pack();
    setLocationRelativeTo(frame);
    show();
  }
Beispiel #29
0
  private void init(Font font) {
    JPanel content = new JPanel(new BorderLayout());
    content.setBorder(new EmptyBorder(12, 12, 12, 12));
    setContentPane(content);

    JPanel listPanel = new JPanel(new GridLayout(1, 3, 6, 6));

    String[] fonts;
    try {
      fonts = getFontList();
    } catch (Exception e) {
      Log.log(Log.ERROR, this, "Broken Java implementation!");

      Log.log(Log.ERROR, this, e);

      fonts = new String[] {"Broken Java implementation!"};
    }

    JPanel familyPanel =
        createTextFieldAndListPanel(
            "font-selector.family", familyField = new JTextField(), familyList = new JList(fonts));
    listPanel.add(familyPanel);

    String[] sizes = {"9", "10", "12", "14", "16", "18", "24"};
    JPanel sizePanel =
        createTextFieldAndListPanel(
            "font-selector.size", sizeField = new JTextField(), sizeList = new JList(sizes));
    listPanel.add(sizePanel);

    String[] styles = {
      jEdit.getProperty("font-selector.plain"),
      jEdit.getProperty("font-selector.bold"),
      jEdit.getProperty("font-selector.italic"),
      jEdit.getProperty("font-selector.bolditalic")
    };

    JPanel stylePanel =
        createTextFieldAndListPanel(
            "font-selector.style", styleField = new JTextField(), styleList = new JList(styles));
    styleField.setEditable(false);
    listPanel.add(stylePanel);

    familyList.setSelectedValue(font.getFamily(), true);
    familyField.setText(font.getFamily());
    sizeList.setSelectedValue(String.valueOf(font.getSize()), true);
    sizeField.setText(String.valueOf(font.getSize()));
    styleList.setSelectedIndex(font.getStyle());
    styleField.setText((String) styleList.getSelectedValue());

    ListHandler listHandler = new ListHandler();
    familyList.addListSelectionListener(listHandler);
    sizeList.addListSelectionListener(listHandler);
    styleList.addListSelectionListener(listHandler);

    content.add(BorderLayout.NORTH, listPanel);

    preview =
        new JLabel(jEdit.getProperty("font-selector.long-text")) {
          public void paintComponent(Graphics g) {
            if (fontSelector != null) fontSelector.setAntiAliasEnabled(g);
            super.paintComponent(g);
          }
        };
    preview.setBorder(new TitledBorder(jEdit.getProperty("font-selector.preview")));

    updatePreview();

    Dimension prefSize = preview.getPreferredSize();
    prefSize.height = 50;
    preview.setPreferredSize(prefSize);

    content.add(BorderLayout.CENTER, preview);

    JPanel buttons = new JPanel();
    buttons.setLayout(new BoxLayout(buttons, BoxLayout.X_AXIS));
    buttons.setBorder(new EmptyBorder(12, 0, 0, 0));
    buttons.add(Box.createGlue());

    ok = new JButton(jEdit.getProperty("common.ok"));
    ok.addActionListener(new ActionHandler());
    getRootPane().setDefaultButton(ok);
    buttons.add(ok);

    buttons.add(Box.createHorizontalStrut(6));

    cancel = new JButton(jEdit.getProperty("common.cancel"));
    cancel.addActionListener(new ActionHandler());
    buttons.add(cancel);

    buttons.add(Box.createGlue());

    content.add(BorderLayout.SOUTH, buttons);

    pack();
    setLocationRelativeTo(getParent());
    setVisible(true);
  }
 @Override
 public void paintComponent(Graphics g) {
   g.drawImage(back, 0, 0, null);
   super.paintComponent(g);
 }