In my text editor, I give the option to change text through a JComboBox and a StyledEditorKit. The only problem is that once I select a size in the combo box (and it changes the selected text), and then select a new selection of text, the value in the combo box stays the same as the previous selection, regardless of the actual size.
I saw this post, but I don't really understand the given answer.
Here's the code I use to change the font
JComboBox<?> fontSizeCombo = new JComboBox<Object>(sizes.toArray());
fontSizeCombo.setFocusable(false);
fontSizeCombo.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
new StyledEditorKit.FontSizeAction("myaction-", (int) ((JComboBox<?>) e.getSource()).getSelectedItem()).actionPerformed(e);
}
});
"sizes" just contains ints ranging from 8 to 112 by increments of 4.
Any help is greatly appreciated.