pigmentarts
asked on
button.setPreferredSize error
Not sure why i have an error here, could someone explain?
Button button = new Button("ClickMe");
button.setPreferredSize(ne w Dimension(200, 80));
add(button, BorderLayout.CENTER);
button.addActionListener(n ew ActionListener()
{
public void actionPerformed(ActionEven t e)
{
button_actionPerformed(e);
// logic to handle the button click event
}
});
Button button = new Button("ClickMe");
button.setPreferredSize(ne
add(button, BorderLayout.CENTER);
button.addActionListener(n
{
public void actionPerformed(ActionEven
{
button_actionPerformed(e);
// logic to handle the button click event
}
});
do you have the right imports?
import java.awt.*;
import java.awt.event.*;
import java.awt.*;
import java.awt.event.*;
replace
button.setPreferredSize with button.setSize
button.setPreferredSize with button.setSize
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
There is no setPreferredSize(..) for AWT components though you have it for Swing componets. (e.g. JButton).
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 ;)
>>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 ;)
ASKER
going to try n understand the event bit now :(
its four in the mornin so gimmie time >_<
its four in the mornin so gimmie time >_<
Hmm, UK?
What is the error message?