Hallo Leute,
habe ein Problem. Die Schriftart im JEditorPane ändert sich leider nicht.
Quellcode:
Wäre nett wenn ihr mir helfen könntet...;-)
Viele Grüße
Trigoor
habe ein Problem. Die Schriftart im JEditorPane ändert sich leider nicht.

Quellcode:
Code:
import javax.swing.Action;
import javax.swing.JButton;
public class frmRtf extends JPanel implements ActionListener{
private JMenuItem mntmArial;
private JEditorPane editorPane;
private JMenuItem mntmVerdana;
public static void main(String[] args) {
JFrame frm = new JFrame();
frm.getContentPane().add(new frmRtf());
frm.setVisible(true);
frm.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frm.setBounds(100, 100, 920, 593);
}
/**
* Create the panel.
*/
public frmRtf() {
setLayout(new BorderLayout(0, 0));
editorPane = new JEditorPane();
add(editorPane);
RTFEditorKit rtf = new RTFEditorKit();
editorPane.setEditorKit(rtf);
JMenuBar menuBar = new JMenuBar();
add(menuBar, BorderLayout.NORTH);
JMenu mnNewMenu = new JMenu("Schriftarten");
menuBar.add(mnNewMenu);
mntmArial = new JMenuItem("Arial");
mntmArial.setFont(new Font("Arial", Font.PLAIN, 12));
mnNewMenu.add(mntmArial);
JMenuItem mntmCourier = new JMenuItem("Courier");
mntmCourier.setFont(new Font("Courier New", Font.PLAIN, 12));
mnNewMenu.add(mntmCourier);
JMenuItem mntmTimesNewRoman = new JMenuItem("Times New Roman");
mntmTimesNewRoman.setFont(new Font("Times New Roman", Font.PLAIN, 12));
mnNewMenu.add(mntmTimesNewRoman);
mntmVerdana = new JMenuItem("Verdana");
mntmVerdana.addActionListener(this);
mntmVerdana.setFont(new Font("Verdana", Font.PLAIN, 12));
mnNewMenu.add(mntmVerdana);
}
public void actionPerformed(ActionEvent e) {
if (e.getSource() == mntmVerdana) {
do_mntmVerdana_actionPerformed(e);
editorPane.setFont(new Font("Verdana", Font.PLAIN, 12));
}
if (e.getSource() == mntmArial) {
do_mntmNewMenuItem_actionPerformed(e);
editorPane.setFont(new Font("Arial", Font.PLAIN, 12));
}
}
protected void do_mntmNewMenuItem_actionPerformed(ActionEvent e) {
}
protected void do_mntmVerdana_actionPerformed(ActionEvent e) {
}
}
Wäre nett wenn ihr mir helfen könntet...;-)
Viele Grüße
Trigoor