How To Disable The Minimize, Maximize And Close Buttons Of A Java Applet ? Can We Customize Them?
I want to disable the buttons of the applet itself, not of any frame of that applet.
This is not possible. You'd think that by you could do this by replacing the JApplet's RootPane with one created from a customized JInternalFrame. Here's the code:
JInternalFrame m_jif = new JInternalFrame();
public void init()
{
JMenuBar jMenuBar = new JMenuBar();
JMenu jMenu = new JMenu("File");
jMenuBar.add(jMenu);
m_jif.setJMenuBar(jMenuBar);
m_jif.setClosable(false);
m_jif.setMaximizable(false);
m_jif.setIconifiable(false);
m_jif.setResizable(false);
JRootPane rp = m_jif.getRootPane();
this.setRootPane(rp);
}
This doesn't work, however. The only thing you can do is to call this.getResizable(false) to disable the maximize button, and to listen for close and iconify events and counteract them. Happy coding!
JInternalFrame m_jif = new JInternalFrame();
public void init()
{
JMenuBar jMenuBar = new JMenuBar();
JMenu jMenu = new JMenu("File");
jMenuBar.add(jMenu);
m_jif.setJMenuBar(jMenuBar);
m_jif.setClosable(false);
m_jif.setMaximizable(false);
m_jif.setIconifiable(false);
m_jif.setResizable(false);
JRootPane rp = m_jif.getRootPane();
this.setRootPane(rp);
}
This doesn't work, however. The only thing you can do is to call this.getResizable(false) to disable the maximize button, and to listen for close and iconify events and counteract them. Happy coding!
This is not possible. You'd think that by you could do this by replacing the JApplet's RootPane with one created from a customized JInternalFrame. Here's the code:
JInternalFrame m_jif = new JInternalFrame();
public void init()
{
JMenuBar jMenuBar = new JMenuBar();
JMenu jMenu = new JMenu("File");
jMenuBar.add(jMenu);
m_jif.setJMenuBar(jMenuBar);
m_jif.setClosable(false);
m_jif.setMaximizable(false);
m_jif.setIconifiable(false);
m_jif.setResizable(false);
JRootPane rp = m_jif.getRootPane();
this.setRootPane(rp);
}
This doesn't work, however. The only thing you can do is to call this.getResizable(false) to disable the maximize button, and to listen for close and iconify events and counteract them. Happy coding!
JInternalFrame m_jif = new JInternalFrame();
public void init()
{
JMenuBar jMenuBar = new JMenuBar();
JMenu jMenu = new JMenu("File");
jMenuBar.add(jMenu);
m_jif.setJMenuBar(jMenuBar);
m_jif.setClosable(false);
m_jif.setMaximizable(false);
m_jif.setIconifiable(false);
m_jif.setResizable(false);
JRootPane rp = m_jif.getRootPane();
this.setRootPane(rp);
}
This doesn't work, however. The only thing you can do is to call this.getResizable(false) to disable the maximize button, and to listen for close and iconify events and counteract them. Happy coding!
import java.awt.*;
import java.awt.event.*;
public class WindowEventEg extends Frame
implements WindowListener
{
WindowEventEg()
{
addWindowListener(this);
setSize(200,200);
setVisible(true);
}
public void windowOpened(WindowEvent e)
{
System.out.println("Window opened.");
}
public void windowClosed(WindowEvent e)
{
System.out.println("Window closed.");
System.exit(0);
}
public void windowClosing(WindowEvent e)
{
System.out.println("Window closing.");
dispose();
}
public void windowIconified(WindowEvent e)
{
System.out.println("Window iconified.");
}
public void windowDeiconified(WindowEvent e)
{
System.out.println("Window deiconified.");
}
public void windowActivated(WindowEvent e)
{
System.out.println("Window activated.");
}
public void windowDeactivated(WindowEvent e)
{
System.out.println("Window deactivated.");
}
public static void main(String []args)
{
new WindowEventEg();
}
}
import java.awt.event.*;
public class WindowEventEg extends Frame
implements WindowListener
{
WindowEventEg()
{
addWindowListener(this);
setSize(200,200);
setVisible(true);
}
public void windowOpened(WindowEvent e)
{
System.out.println("Window opened.");
}
public void windowClosed(WindowEvent e)
{
System.out.println("Window closed.");
System.exit(0);
}
public void windowClosing(WindowEvent e)
{
System.out.println("Window closing.");
dispose();
}
public void windowIconified(WindowEvent e)
{
System.out.println("Window iconified.");
}
public void windowDeiconified(WindowEvent e)
{
System.out.println("Window deiconified.");
}
public void windowActivated(WindowEvent e)
{
System.out.println("Window activated.");
}
public void windowDeactivated(WindowEvent e)
{
System.out.println("Window deactivated.");
}
public static void main(String []args)
{
new WindowEventEg();
}
}