¿Cómo puedo permitir que un usuario cambie su fuente en un JTextPane usando un JComboBox?

Estoy encontrando la cantidad de documentación / tutoriales útiles en internet que faltan cuando se trata del tema de JTextPanes. Estoy tratando de hacer un simple procesador de texto, y quiero que pueda seleccionar una familia de fuentes de un JComboBox que se rellene a sí mismo en función de las fuentes que el usuario haya instalado en su sistema. Sin embargo, no importa lo que intente con la experimentación, no puedo averiguar cómo hacer que funcione.

Lo que tengo es una clase de barra de herramientas que está construida a partir de un JTextPane. Actualmente, tiene un montón de botones de estilo que funcionan para establecer la alineación y el texto en negrita, cursiva y subrayado.

Aquí está mi código:

<code>/**
* The StyleBar is used to customize styles in a Styled Document. It will take a
* JTextPane as an argument for its constructor and then all actions to be taken
* will affect the text in it.
*
* @author Andrew
*/
public class StyleBar extends JToolBar {

    private JLabel fontLbl;
    private JComboBox fontBox;

        // ...Irrelevant stuff to the problem at hand.

    /**
    * The initEvents method is used to initialize the necessary events for the
    * tool bar to actually do its job. It establishes the focus listener to the
    * buttons on the bar, and gives each one its individual functionality. It 
    * also establishes the Font Selection interface.
    */
    public void initEvents() {
        //For each item in the tool bar, add the focus listener as well as the
        //formatting listeners:
        boldFormat.addActionListener(new StyledEditorKit.BoldAction()); //boldFormat is
        boldFormat.addActionListener(resetFocus);                       //a JButton

        //Ditto for my italicsFormat and underlineFormat button(s) in the toolbar

        leftAlign.addActionListener(new StyledEditorKit.AlignmentAction(null,
                StyleConstants.ALIGN_LEFT));
        leftAlign.addActionListener(resetFocus);    //This listener just resets focus
                                                    //back onto the TextPane.

        //Ditto for my right and centerAlign buttons

        //Set up the Font list, and add a listener to the combo box
        buildFontMenu();
    }

    /**
    * The buildFontMenu detects all of the SYstem's available fonts and adds 
    * them to the Font Selection box.
    */
    public void buildFontMenu(){
        GraphicsEnvironment ge = 
                GraphicsEnvironment.getLocalGraphicsEnvironment();
        final String[] fontNames = ge.getAvailableFontFamilyNames();
        for (int i = 0; i < fontNames.length; i++){
            //What do I do here to take the entry at String[i] and make it so that when
            //the user selects it it sets the font Family in a similar way to that of
            //pressing the boldFormat button or the leftAlign button?
        }
    }

    //Everything else is irrelevant
</code>

Entonces, para resumir mi problema: no tengo idea de cómo configurar correctamente el oyente para el ComboBox, de modo que a) sea sensible a la fuente individual seleccionada yb) de alguna manera use StyledEditorKit.FontFamilyAction para facilitar la vida

Slash, si me estoy acercando a algo sobre esto de la manera incorrecta, me encantaría escucharlo de la manera correcta. Como dije, mis fuentes en internet no son muy claras sobre el tema.

¡Muchas gracias!

Respuestas a la pregunta(2)

Su respuesta a la pregunta