 |
AppletTalk.com Java discussions newsgroups
|
| View previous topic :: View next topic |
| Author |
Message |
hardemr Guest
|
Posted: Fri May 11, 2007 2:19 am Post subject: How to disable maximum&minimum icon on the jframe |
|
|
Hello Everyone,
I have a problem. How can i disable maximum and minimum icon on the
jFrame?
Best Regards,
Emrah
Ankara/Turkey |
|
| Back to top |
|
 |
Michael Dunn Guest
|
Posted: Fri May 11, 2007 7:09 am Post subject: Re: How to disable maximum&minimum icon on the jframe |
|
|
"hardemr" <emrahayanoglu (AT) gmail (DOT) com> wrote in message
news:1178831980.559902.309550 (AT) h2g2000hsg (DOT) googlegroups.com...
| Quote: | Hello Everyone,
I have a problem. How can i disable maximum and minimum icon on the
jFrame?
|
this works OK using java 1.5.0_05 on win xp,
but not guaranteed to work using other versions/platforms
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
class Testing
{
int count = 0;
public void buildGUI()
{
JFrame.setDefaultLookAndFeelDecorated(true);
JFrame f = new JFrame();
f.setSize(400,300);
f.setLocationRelativeTo(null);
f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
disableMinMax(f);
f.setVisible(true);
}
public void disableMinMax(Component comp)
{
if (comp instanceof JButton && count < 2)
{
comp.setEnabled(false);
MouseListener[] listeners = comp.getMouseListeners();
for(int x = 0, y = listeners.length; x < y; x++) comp.removeMouseListener(listeners[x]);
count++;
}
if (comp instanceof Container)
{
Component[] comps = ((Container)comp).getComponents();
for(int x = 0, y = comps.length; x < y; x++)
{
disableMinMax(comps[x]);
}
}
}
public static void main(String[] args)
{
SwingUtilities.invokeLater(new Runnable(){
public void run(){
new Testing().buildGUI();
}
});
}
} |
|
| Back to top |
|
 |
Andrew Thompson Guest
|
Posted: Fri May 11, 2007 7:11 am Post subject: Re: How to disable maximum&minimum icon on the jframe |
|
|
hardemr wrote:
| Quote: | ... How can i disable maximum and minimum icon on the
jFrame?
|
A JFrame? To get part of that, you can simply lock
the size of the frame..
<sscce>
import javax.swing.JFrame;
class UnResizableFrame extends JFrame {
public static void main(String[] args) {
JFrame f = new JFrame("Not Resizable");
f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
f.setSize(400,200);
f.setLocation(50,50);
// lock the size
f.setResizable(false);
f.setVisible(true);
}
}
</sscce>
..the JFrame can still be minimized to the taskbar,
in this example.
--
Andrew Thompson
http://www.athompson.info/andrew/
Message posted via JavaKB.com
http://www.javakb.com/Uwe/Forums.aspx/java-gui/200705/1 |
|
| Back to top |
|
 |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
|