Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

JDialog fixed height [duplicate]

Possible Duplicate:
JDialog allow user to only change width of the dialog

I have a JDialog that I would like the width to be resizable, but the height not.

This is my current code:

addComponentListener(new ComponentAdapter() {
    @Override
    public void componentResized(ComponentEvent e) {
        setLocation(getLocation().x, getLocation().y + (getHeight() - staticHeight));
        setSize(new Dimension(getWidth(), staticHeight));
        super.componentResized(e);
    }
});

Problem is, that code gets called after the window is resized. Making the window resize and then flicker back.

I would like to make it so when the user trys to drag the height of the window it does nothing.

like image 648
Josh Avatar asked May 08 '12 15:05

Josh


1 Answers

  • you can't directly stop resizing,

  • you can't block basic property of containers,

  • container because from Native OS and are built on its properties,

  • and limitations for resizing is screen size

  • rest are (with code) Resizing Components by @camickr

  • there are dirty hack based on AbsoluteLayout, and I don't suggest using that

  • block resize if there is any flickering or freeze during resize

like image 199
mKorbel Avatar answered Sep 19 '22 02:09

mKorbel