[code] public void UITexto()
{
//DoubleDiferenteZero = NumberFormat.getNumberInstance();
//DoubleDiferenteZero.setMinimumFractionDigits(1);
//Criando Labels com as Mensagens a serem exibidas
LabelA = new JLabel(MsgA);
LabelB = new JLabel(MsgB);
LabelC = new JLabel(MsgC);
LabelPrecisao = new JLabel(MsgPrecisao);
LabelEscala = new JLabel(MsgEscala);
//Crianto os FormattedTextField e setando-os
FTFA = new JFormattedTextField(NumberFormat.getNumberInstance());
FTFA.setValue(a);
FTFA.setColumns(5);
FTFA.addPropertyChangeListener("value", this);
FTFB = new JFormattedTextField(NumberFormat.getNumberInstance());
FTFB.setValue(b);
FTFB.setColumns(5);
FTFB.addPropertyChangeListener("value", this);
FTFC = new JFormattedTextField(NumberFormat.getNumberInstance());
FTFC.setValue(c);
FTFC.setColumns(5);
FTFC.addPropertyChangeListener("value", this);
FTFPrecisao = new JFormattedTextField(NumberFormat.getNumberInstance());
FTFPrecisao.setValue(precisao);
FTFPrecisao.setColumns(4);
FTFPrecisao.addPropertyChangeListener("value", this);
FTFEscala = new JFormattedTextField(NumberFormat.getNumberInstance());
FTFEscala.setValue(escala);
FTFEscala.setColumns(4);
FTFEscala.addPropertyChangeListener("value", this);
//Unindo os labels aos FTF
LabelA.setLabelFor(FTFA);
LabelB.setLabelFor(FTFB);
LabelC.setLabelFor(FTFC);
LabelPrecisao.setLabelFor(FTFPrecisao);
LabelEscala.setLabelFor(FTFEscala);
//Juntando os Labels criados em um único painel
JPanel PainelABC = new JPanel();
PainelABC.add(LabelA);
PainelABC.add(FTFA);
PainelABC.add(LabelB);
PainelABC.add(FTFB);
PainelABC.add(LabelC);
PainelABC.add(FTFC);
JPanel PainelPE = new JPanel(new GridLayout(2,2));
PainelPE.add(LabelPrecisao);
PainelPE.add(FTFPrecisao);
PainelPE.add(LabelEscala);
PainelPE.add(FTFEscala);
PainelABC.setBackground(Color.white);
PainelPE.setBackground(Color.white);
this.setLayout(null);
//Adicionando os painéis
setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 0));
this.add(PainelABC);
Dimension Dim = PainelABC.getPreferredSize();
PainelABC.setBounds(220,334, Dim.width, Dim.height);
this.add(PainelPE);
Dim = PainelPE.getPreferredSize();
PainelPE.setBounds(5,30, Dim.width, Dim.height);
//Criando e adicionando os botões
JButton BPlotarGrafico = new JButton("Plotar Gráfico");
//JButton BPrecisao = new JButton("Alterar Precisão");
//JButton BEscala = new JButton(" Alterar Escala ");
this.add(BPlotarGrafico);
//this.add(BPrecisao);
//this.add(BEscala);
Dim = BPlotarGrafico.getPreferredSize();
BPlotarGrafico.setBounds(45,336,Dim.width,Dim.height);
//Dim = BPrecisao.getPreferredSize();
//BPrecisao.setBounds(5,75,Dim.width,Dim.height);
//BEscala.setBounds(5,105,Dim.width,Dim.height);
BPlotarGrafico.setActionCommand("Plotar");
BPlotarGrafico.addActionListener(this);
}
public void propertyChange(PropertyChangeEvent e)
{
Object source = e.getSource();
if (source == FTFA) {
a = ((Number)FTFA.getValue()).doubleValue();
}
else if (source == FTFB) {
b = ((Number)FTFB.getValue()).doubleValue();
}
else if (source == FTFC) {
c = ((Number)FTFC.getValue()).doubleValue();
}
else if (source == FTFPrecisao) {
precisao = ((Number)FTFPrecisao.getValue()).doubleValue();
}
else if (source == FTFEscala) {
escala = ((Number)FTFEscala.getValue()).intValue();
}
}[/code]
não tá correto ? quando eu altero o value do FTFA por exemplo, ele entra no propertyChange mas não entra no if (source == FTFA)