olá a todos bem to tentando na seguinte linha , supostamente deveria criar um listener dependendo do nome do botao porem isto nao ocorre oque devo fazer ?
class bPanel extends JPanel {
public bPanel ()
{
//creates the layout and set its to the panel
GridBagLayout gbl = new GridBagLayout();
GridBagConstraints c = new GridBagConstraints();
setLayout(gbl);
c.gridx=0;
c.gridy=0;
makebutton("Abrir Arquivo",gbl,c);
c.gridx=0;
c.gridy=1;
c.ipadx=15;
makebutton("Abrir Texto",gbl,c);
}
protected void makebutton(String name, GridBagLayout gbl,GridBagConstraints c)
{
JButton button =new JButton(name);
if(name.equals("Abrir Arquivo"))
{
button.addActionListener(new
ActionListener(){
public void actionPerformed(ActionEvent e) {
JFileChooser chooser = new JFileChooser();
int result = chooser.showOpenDialog(null);
if (result==JFileChooser.APPROVE_OPTION);
{
String file =chooser.getSelectedFile().getPath();
//labelPanel.
}
}
});
}else if(name.equals("Abrir Texto"));
{
button.addActionListener(new
ActionListener(){
public void actionPerformed(ActionEvent e) {
String Message =JOptionPane.showInputDialog("a message");
}
});
}
//set the component constants
gbl.setConstraints(button, c);
add(button);
}
}
agradeço a ajuda ,até mais