One way is to store your frame somewhere in your MIActionListener. With
minimum changes in your code you can write like this
menulistener.addActionListener(new MIActionListener(this));
class MIActionListener implements ActionListener{
Frame f;
MIActionListener(Frame f) { this.f = f; }
public void actionPerformed(ActionEvent Ae){
f.setBounds(...); //...
}
}
Commonly used (but probably not the best) way to shorten code is to use
anonymous internal class in this manner:
menulistener.addActionListener(new MIActionListener()
{
public void actionPerformed(ActionEvent Ae){
JFrame.this.setBounds(...); //...
}
});
Hope this helps
All the Best
Pavel
ALPESH KOTHARI wrote:
>
> Hello all,
>
> I am developing a GUI using JAVA 2 on linux.
>
> There is one menuitem, which when pressed should resize my main window.
> But I am not exactly able to write the resize code in the
> actionlistener..
>
> class xxx extends JFrame{
> .
> .
> .
>
> menulistener.addActionListener(new MIActionListener());
>
> .
> .
>
> }
>
> class MIActionListener implements ActionListener{
> public void ActionPerformed(ActionEvent Ae){
> //To write a code so as the resize the
> //main window of xxx.
> }
> }
>
> So what can I do?
>
> This may be a silly question, but I would thank if someone answers it.
> THanking YOU
> Alpesh
>
>
>
> ===
> KOTHARI ALPESH D.
> STUDENT M. TECH.
> CEDT
> INDIAN INSTITUTE OF SCIENCE
> BANGALORE-560 012
> INDIA
> __________________________________________________
> Do You Yahoo!?
> Bid and sell for free at http://auctions.yahoo.com
>
> ----------------------------------------------------------------------
> To UNSUBSCRIBE, email to [EMAIL PROTECTED]
> with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]
----------------------------------------------------------------------
To UNSUBSCRIBE, email to [EMAIL PROTECTED]
with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]