how do i show the buttons that i create in an applet with this code?
private JButton B1;
private JButton B2;
public void init()
{
// JApplet init with your code.
B1 = new JButton("Button 1"
;
B1.addActionListener(new ButtonActionListener()); // reg
B2 = new JButton("Button 2"
;
B2.addActionListener(new ButtonActionListener()); // reg
// more code you may want in the init.
}
// Inner Class for the Buttons.
class ButtonActionListener implements ActionListener
{
public void actionPerformed(ActionEvent ev)
{
if (ev.getSource() == B1)
{
// your code here for Button 1
}
if (ev.getSource() == B2)
{
// your code here for Button 2
}
}
}
pls help me!
private JButton B1;
private JButton B2;
public void init()
{
// JApplet init with your code.
B1 = new JButton("Button 1"
B1.addActionListener(new ButtonActionListener()); // reg
B2 = new JButton("Button 2"
B2.addActionListener(new ButtonActionListener()); // reg
// more code you may want in the init.
}
// Inner Class for the Buttons.
class ButtonActionListener implements ActionListener
{
public void actionPerformed(ActionEvent ev)
{
if (ev.getSource() == B1)
{
// your code here for Button 1
}
if (ev.getSource() == B2)
{
// your code here for Button 2
}
}
}
pls help me!