Link to home
Start Free TrialLog in
Avatar of pigmentarts
pigmentartsFlag for United Kingdom of Great Britain and Northern Ireland

asked on

button.setPreferredSize error

Not sure why i have an error here, could someone explain?

Button button = new Button("ClickMe");
               button.setPreferredSize(new Dimension(200, 80));
               add(button, BorderLayout.CENTER);
               button.addActionListener(new ActionListener()
                {
                            public void actionPerformed(ActionEvent e)
                            {
                button_actionPerformed(e);
                // logic to handle the button click event
                          }
                });
Avatar of aozarov
aozarov

is this method defined "button_actionPerformed(e);" ?
What is the error message?
do you have the right imports?
import java.awt.*;
import java.awt.event.*;
replace
button.setPreferredSize with button.setSize
ASKER CERTIFIED SOLUTION
Avatar of aozarov
aozarov

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
There is no setPreferredSize(..) for AWT components though you have it for Swing componets. (e.g. JButton).
Avatar of pigmentarts

ASKER

ah thats why then. oopss.

>>button.setPreferredSize with button.setSize  did take away the error but did not change the size of the button.

But you saved yourself with the next bit ;)
going to try n understand the event bit now :(

its four in the mornin so gimmie time >_<
Hmm, UK?