28.12.2012 Views

Core JFC Java Foundation Classes 2nd edition - Read

Core JFC Java Foundation Classes 2nd edition - Read

Core JFC Java Foundation Classes 2nd edition - Read

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

Working with Internal Frames 1457<br />

replaced by a restore button and the system menu is affected in<br />

the same way as it is with the maximize button. This property<br />

and the resizable property are independent of each other.<br />

Changing Internal Frame Properties<br />

All of the properties that can be set using the constructors also have the usual<br />

methods that you can use to get their current values, or to change them after<br />

the frame has been constructed, ft is very unlikely, for example, that you<br />

would want to use the default constructor for JInternalFrame unless you<br />

wanted to conditionally assign attributes using the following methods:<br />

public void setClosable(boolean closable);<br />

public boolean isClosable();<br />

public void setResizable(boolean resizable);<br />

public boolean isResizable();<br />

public void setlconifiable(boolean iconifiable);<br />

public boolean islconifiable();<br />

public void setMaximizable(boolean maximizable);<br />

public boolean isMaximizable();<br />

public void setTitle(String title);<br />

public String getTitleO;<br />

Changing any of these attributes (other than the title) once the frame has<br />

been made visible for the first time is not advisable. What happens is that the<br />

property change becomes effective, but the frame's visual appearance and its<br />

menu don't reflect it. For example, if you create a frame that can be closed,<br />

the menu (if it exists) will contain a Close item and (unless you are using the<br />

Motif look-and-feel) a close button will appear on the frame. If you then<br />

invoke setClosable (false), the menu item and the close button remain,<br />

but all attempts to close the frame using either of them will be ineffective.<br />

Setting an Internal Frame's Caption-Bar Icon<br />

Like JFrame, an internal frame can have an icon that is displayed at the left<br />

of the title bar. Unlike the JFrame icon which is actually an Image, the icon<br />

for an internal frame can be anything that implements the Icon interface, of<br />

which Imagelcon is one particular example. If you want to supply an icon,<br />

best results are obtained with one that is 16 pixels high and wide. To associate<br />

the icon with the frame, use the following method:<br />

public void setFramelcon(Icon icon);

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!