Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.java.gui > #1612
| From | "Michael Dunn" <michael.dunn@THRWHITE.remove-dii-this> |
|---|---|
| Subject | Re: How to disable maximu |
| Message-ID | <4643d097$1@dnews.tpgi.com.au> (permalink) |
| Newsgroups | comp.lang.java.gui |
| References | <1178831980.559902.309550@h2g2000hsg.googlegroups.com> |
| Date | 2011-04-27 15:34 +0000 |
| Organization | TDS.net |
To: comp.lang.java.gui
"hardemr" <emrahayanoglu@gmail.com> wrote in message
news:1178831980.559902.309550@h2g2000hsg.googlegroups.com...
> 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();
}
});
}
}
---
* Synchronet * The Whitehouse BBS --- whitehouse.hulds.com --- check it out free usenet!
--- Synchronet 3.15a-Win32 NewsLink 1.92
Time Warp of the Future BBS - telnet://time.synchro.net:24
Back to comp.lang.java.gui | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
How to disable maximum&mi "hardemr" <hardemr@THRWHITE.remove-dii-this> - 2011-04-27 15:34 +0000 Re: How to disable maximu "Michael Dunn" <michael.dunn@THRWHITE.remove-dii-this> - 2011-04-27 15:34 +0000 Re: How to disable maximu "Andrew Thompson" <andrew.thompson@THRWHITE.remove-dii-this> - 2011-04-27 15:34 +0000
csiph-web