• Post Reply Bookmark Topic Watch Topic
  • New Topic

how to disable resize button  RSS feed

 
arun mahajan
Ranch Hand
Posts: 305
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello,
I tried to find he answer in this forum and there are some answers but not what I am looking for. My objective is to have a window where a end user can minimize,close but cannot resize.
The problem is if I use setresizable() method it does not provide me the minimize button.
Can some body help me to acheive this?
regards,
Arun
 
Nathan Pruett
Bartender
Posts: 4121
IntelliJ IDE Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Add a ComponentListener to the window that keeps the frame at a specific size in the componentResized() method.

-Nate
 
Greg Brouelette
Ranch Hand
Posts: 144
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If it's a JFrame I think you can just use
public void setResizable(boolean resizable)
with false as the argument. This leaves the minimize and maximize system icon as well as the close icon, but you just can't resize the JFrame.
 
arun mahajan
Ranch Hand
Posts: 305
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks a lot for all your answer.
I tried with setResizable() but it works with java 1.3 and above only.
In any case one can achieve the same with Nathan's suggestion. Following is the code for reference.
Thanks a lot for all your support.
regards,
ARun
Code:-
********
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
public class testResize extends JFrame
{
Container cont;

public testResize()
{
cont = getContentPane();
cont.setBackground(new Color(110,129,161));
cont.setFont(new Font("arial",Font.BOLD,11));
cont.setLayout(null);
addWindowListener(new WindowAdapter() {
public void windowClosing(WindowEvent e) {
System.exit(0);
}
});
addComponentListener(new ComponentAdapter() {
public void componentResized(ComponentEvent e) {
setSize(350,350);
}
});
}
public static void main(String args[])
{
testResize ls=new testResize();
ls.setTitle("Resize Trial!!");
ls.setSize(350,350);
ls.setVisible(true);
}
}
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!