/** * Pops up a dialog for selecting the font. */ public void selectFont() { FontChooser chooser; if (getParentDialog() != null) chooser = new FontChooser(getParentDialog()); else chooser = new FontChooser(getParentFrame()); chooser.setCurrent(getFont()); chooser.setModalityType(ModalityType.DOCUMENT_MODAL); chooser.setVisible(true); setTextFont(chooser.getCurrent()); }
public void actionPerformed(ActionEvent e) { chooser.setVisible(true); Font myNewFont = chooser.getCurrent(); System.out.println("You chose " + myNewFont); label.setFont(myNewFont); frame.pack(); chooser.dispose(); } });
/** * finishes the initialization, by setting size/location. */ @Override protected void finishInit() { super.finishInit(); pack(); setLocationRelativeTo(null); }
public void actionPerformed(ActionEvent e) { m_FontPanel.setCurrent(m_Current); dispose(); setVisible(false); } });
final FontChooser chooser = new FontChooser(frame); chooser.setCurrent(null); frame.getContentPane().setLayout(new GridLayout(0, 1)); label.setFont(chooser.getCurrent()); frame.getContentPane().add(label);
/** * Initializes the widgets. */ @Override protected void initGUI() { super.initGUI(); m_FontPanel = new FontChooserPanelWithPreview(); getContentPane().add(m_FontPanel, BorderLayout.CENTER); m_ButtonOK = new JButton("OK"); m_ButtonOK.setMnemonic('O'); m_PanelButtonsRight.add(m_ButtonOK); m_ButtonOK.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { m_Current = m_FontPanel.getCurrent(); dispose(); setVisible(false); } }); m_ButtonCancel = new JButton("Cancel"); m_ButtonCancel.setMnemonic('C'); m_PanelButtonsRight.add(m_ButtonCancel); m_ButtonCancel.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { m_FontPanel.setCurrent(m_Current); dispose(); setVisible(false); } }); }
final FontChooser chooser = new FontChooser(frame); chooser.setCurrent(null); frame.getContentPane().setLayout(new GridLayout(0, 1)); label.setFont(chooser.getCurrent()); frame.getContentPane().add(label);
public void actionPerformed(ActionEvent e) { m_Current = m_FontPanel.getCurrent(); dispose(); setVisible(false); } });
/** * Performs the actual choosing of an object. * * @return the chosen object or null if none chosen */ protected Font doChoose() { if (m_FontChooser == null) { if (GUIHelper.getParentDialog(this) != null) m_FontChooser = new FontChooser(GUIHelper.getParentDialog(this)); else m_FontChooser = new FontChooser(GUIHelper.getParentFrame(this)); } m_FontChooser.setCurrent(getCurrent()); m_FontChooser.setVisible(true); return m_FontChooser.getCurrent(); }
public void actionPerformed(ActionEvent e) { chooser.setVisible(true); Font myNewFont = chooser.getCurrent(); System.out.println("You chose " + myNewFont); label.setFont(myNewFont); frame.pack(); chooser.dispose(); } });