Trocar fonte taskpanes (@Actions)

7 respostas
victorgilc

Salve galera!

Tenho um jtaskPane, que tem um arquivo .properties relacionado a ele, no task trabalho com @Action, e no properties defino o nome dos @Action.
Como faço pra mudar a fonte do nome dos @Action que estão dentro do task? :shock:

vlw

7 Respostas

Marky.Vasconcelos

Da onde vem essa anotação @Action?
Essa informação nos ajuda a resolver seu problema.

victorgilc

é como se fosse o evento action performed de um botão
e gostaria de trocar a fonte “do nome desse botão” se é q me entedes

Marky.Vasconcelos

Não entendo o que voce quer fazer, voce quer mudar o nome do botão?

victorgilc

a fonte(sansserif por exemplo) e tb o tamanho( de 20 pra 10 por exemplo)

Marky.Vasconcelos

Pode postar código por favor? Não tenho idéia de como voce vai resolver isso através da @Action sendo que ela é só um ActionListener.

victorgilc

segue o código

package exproperties;

import com.sun.swingset3.DemoProperties;
import java.awt.Font;

import java.beans.PropertyVetoException;
import java.lang.reflect.Method;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.swing.JInternalFrame;
import javax.swing.JLayeredPane;

import org.jdesktop.application.Action;
import org.jdesktop.application.Application;
import org.jdesktop.application.ApplicationActionMap;
import org.jdesktop.swingx.JXTaskPane;

/**
 *
 * @author victor
 */
@DemoProperties(value = "Aplicativos",
category = "",
description = "Descrição da barra de menus",
sourceFiles = {
    "exproperties/ExPizza.java", "exproperties/resources/ExPizza.properties"
})
public class ExPizza extends javax.swing.JFrame {

    private JXTaskPane PrimeiroGroup;
    private JXTaskPane SegundoGroup;
    private JXTaskPane TerceiroGroup;

    public ExPizza() {
        initComponents();
        createTaskPane();
        bind();
        setResizable(false);
        pack();
        setFont(new Font("SansSerif", Font.PLAIN, 10));
        Application.getInstance().getContext().getResourceMap(getClass()).injectComponents(this);
    }

    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">                          
    private void initComponents() {

        jXTPContainerTeste = new org.jdesktop.swingx.JXTaskPaneContainer();
        desk = new javax.swing.JDesktopPane();

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
        setTitle("Formulario");

        jXTPContainerTeste.setName("jXTPContainerTeste"); // NOI18N

        desk.setEnabled(false);
        desk.setName("desk"); // NOI18N

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jXTPContainerTeste, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(desk, javax.swing.GroupLayout.PREFERRED_SIZE, 419, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addComponent(desk, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, 244, Short.MAX_VALUE)
                    .addComponent(jXTPContainerTeste, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, 244, Short.MAX_VALUE))
                .addContainerGap())
        );

        pack();
    }// </editor-fold>                        
    private void createTaskPane()
    {
        PrimeiroGroup = new JXTaskPane();
        PrimeiroGroup.setName("PrimeiroGroupteste");
        PrimeiroGroup.setFont(new Font("SansSerif", Font.PLAIN, 10));
        jXTPContainerTeste.add(PrimeiroGroup);

        SegundoGroup = new JXTaskPane();
        SegundoGroup.setName("SegundoGroupteste");
        SegundoGroup.setFont(new Font("SansSerif", Font.PLAIN, 10));
        jXTPContainerTeste.add(SegundoGroup);

        TerceiroGroup = new JXTaskPane();
        TerceiroGroup.setName("TerceiroGroupteste");
        TerceiroGroup.setFont(new Font("SansSerif", Font.PLAIN, 10));
        jXTPContainerTeste.add(TerceiroGroup);
    }

    private void bind() {
        ApplicationActionMap map = Application.getInstance().getContext().getActionMap(this);

        PrimeiroGroup.add(map.get("caracteristicas"));

        SegundoGroup.add(map.get("cliente"));

        TerceiroGroup.add(map.get("entrega"));
    }

    private void addInternal(JInternalFrame frameInterno)
    {
        boolean temp = false;
         try {
            for (JInternalFrame frame : desk.getAllFrames()) {
                frame.setIcon(true);
                if (frame.getClass() == frameInterno.getClass()) {
                    temp = true;
                    frame.setIcon(false);
                    frame.setSelected(true);
                }
            }
        } catch (PropertyVetoException ex) {
            System.out.println("ERRO");
        }
        if (!temp) {
            frameInterno.setVisible(true);
            desk.add(frameInterno, JLayeredPane.MODAL_LAYER);
            desk.setSelectedFrame(frameInterno);
        }
    }

    private void instance1(String nameclasse)
    {
        Object[] PARAM = null;
        try {
            Method metodo = Class.forName(nameclasse).getDeclaredMethod("getInstance", new Class[]{});
            addInternal((JInternalFrame) metodo.invoke(null, PARAM));
        } catch (Exception ex) {
            Logger.getLogger(SinglePizzaJInternalFrame.class.getName()).log(Level.SEVERE, null, ex);
        }
    }
     private void instance2(String nameclasse)
    {
        Object[] PARAM = null;
        try {
            Method metodo = Class.forName(nameclasse).getDeclaredMethod("getInstance", new Class[]{});
            addInternal((JInternalFrame) metodo.invoke(null, PARAM));
        } catch (Exception ex) {
            Logger.getLogger(SingleDClienteJInternalFrame.class.getName()).log(Level.SEVERE, null, ex);
        }
    }
      private void instance3(String nameclasse)
    {
        Object[] PARAM = null;
        try {
            Method metodo = Class.forName(nameclasse).getDeclaredMethod("getInstance", new Class[]{});
            addInternal((JInternalFrame) metodo.invoke(null, PARAM));
        } catch (Exception ex) {
            Logger.getLogger(SingleDClienteJInternalFrame.class.getName()).log(Level.SEVERE, null, ex);
        }
    }

    @Action
    public void caracteristicas()
    {
        instance1("exproperties.SinglePizzaJInternalFrame");
    }
    @Action
    public void cliente() 
    {
        instance2("exproperties.SingleDClienteJInternalFrame");
    }

    @Action
    public void entrega() 
    {
        instance3("exproperties.SingleDEntregaJInternalFrame");
    }

    public static void main(String args[]) {
        java.awt.EventQueue.invokeLater(new Runnable() {

            public void run() {
                new ExPizza().setVisible(true);
            }
        });
    }
    // Variables declaration - do not modify                     
    private javax.swing.JDesktopPane desk;
    private org.jdesktop.swingx.JXTaskPaneContainer jXTPContainerTeste;
    // End of variables declaration                   
}

tem o properties tb

#PrimeiroGroup.title=&File and Folder Tasks
PrimeiroGroupteste.title=Características Pizza
PrimeiroGroupteste.mnemonic=70
#PrimeiroGroup.icon=images/tasks-email.png
PrimeiroGroupteste.special=false
#SegundoGroup.title=&Office Tasks
SegundoGroupteste.title=Dados Cliente
SegundoGroupteste.mnemonic=79
SegundoGroupteste.collapsed=false
SegundoGroupteste.scrollOnExpand=true
#TerceiroGroup.title=&See Also
TerceiroGroupteste.title=Dados Entrega
TerceiroGroupteste.mnemonic=83
#UtilitariosGroup.title=&Details

#@Actions
caracteristicas.Action.text=Selecione as Caracterísiticas
#delete.Action.icon=images/tasks-recycle.png
cliente.Action.text=Informe Dados Cliente
#write.Action.icon=images/tasks-writedoc.png
entrega.Action.text=Informe Dados Entrega
#exploreInternet.Action.icon=images/tasks-internet.png
entrega.Action.shortDescription=A cool web resource
victorgilc

Não deu pra ter uma idéia? :smiley:

Criado 7 de dezembro de 2010
Ultima resposta 9 de dez. de 2010
Respostas 7
Participantes 2