• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • paul wheaton
  • Ron McLeod
  • Jeanne Boyarsky
Sheriffs:
  • Paul Clapham
Saloon Keepers:
  • Tim Holloway
  • Roland Mueller
Bartenders:

how to disable resize button

 
Ranch Hand
Posts: 305
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Bartender
Posts: 4121
IntelliJ IDE Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Add a ComponentListener to the window that keeps the frame at a specific size in the componentResized() method.

-Nate
 
Ranch Hand
Posts: 144
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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);
}
}
 
Happily living in the valley of the dried frogs with a few tiny ads.
Clean our rivers and oceans from home
https://www.kickstarter.com/projects/paulwheaton/willow-feeders
reply
    Bookmark Topic Watch Topic
  • New Topic