Author |
Message |
FileFantasy
|
Posted: Sun Jan 14, 2007 12:37 am Post subject: Is it possible to make a window resizable only vertically? |
|
|
Because as far as I know, there's only .setResizable(boolean) to change both at the same time, right? I kinda don't want the user to screw with the width though... |
|
|
|
|
|
Sponsor Sponsor
|
|
|
[Gandalf]
|
Posted: Sun Jan 14, 2007 6:23 am Post subject: RE:Is it possible to make a window resizable only vertically? |
|
|
I don't think so... At best, you could run a check every time the window is resized, and set the width back to what it was before. |
|
|
|
|
|
FileFantasy
|
Posted: Wed Jan 17, 2007 8:29 pm Post subject: RE:Is it possible to make a window resizable only vertically? |
|
|
How would I go about doing that? Because I can't seem to change the width / length of my JFrame after the inital run, where I used JFrame.pack()
And I also don't know how to check for when the JFrame's size is changed. Can someone help me on that too? Thanks. |
|
|
|
|
|
ericfourfour
|
Posted: Wed Jan 17, 2007 9:01 pm Post subject: RE:Is it possible to make a window resizable only vertically? |
|
|
Is it not frame.getDimensions ().setWidth (double)? |
|
|
|
|
|
FileFantasy
|
Posted: Mon Jan 22, 2007 11:26 am Post subject: RE:Is it possible to make a window resizable only vertically? |
|
|
And how do I make it so that it sets width every time the frame is resized? Is there a listener or anything? |
|
|
|
|
|
FileFantasy
|
Posted: Wed Feb 14, 2007 2:28 pm Post subject: Re: Is it possible to make a window resizable only vertically? |
|
|
Problem still not solved, please help. Thanks. |
|
|
|
|
|
HellblazerX
|
Posted: Wed Feb 14, 2007 3:57 pm Post subject: Re: Is it possible to make a window resizable only vertically? |
|
|
I don't think there is a listener for what you're proposing. There's a WindowStateListener, but I think that only applies when the window is minimized or maximized. |
|
|
|
|
|
ericfourfour
|
Posted: Wed Feb 14, 2007 5:11 pm Post subject: Re: Is it possible to make a window resizable only vertically? |
|
|
I googled: "java window resize listener".
The first page was this http://java.sun.com/docs/books/tutorial/uiswing/events/componentlistener.html
On that page it contained this (I modified it a bit because it was originally in a table):
Quote: componentHidden(ComponentEvent)
Called after the listened-to component is hidden as the result of the setVisible method being called.
componentMoved(ComponentEvent)
Called after the listened-to component moves, relative to its container. For example, if a window is moved, the window fires a component-moved event, but the components it contains do not.
componentResized(ComponentEvent)
Called after the listened-to component's size (rectangular bounds) changes.
componentShown(ComponentEvent)
Called after the listened-to component becomes visible as the result of the setVisible method being called.
Look at that! I found your answer in 1 minute using google. You, however, had to wait a month for someone to hold your hand and do it for you. |
|
|
|
|
|
Sponsor Sponsor
|
|
|
FileFantasy
|
Posted: Thu Feb 15, 2007 5:31 pm Post subject: RE:Is it possible to make a window resizable only vertically? |
|
|
Well, congratulations on being a lot more familiar with finding answers on your own with google then.
Perhaps people like me are just not good enough to find answers in 1 minute using google, or find an answer at all for that matter. Maybe I've tried and couldn't find anything and that's why I come here to ask for Index -> Programming, Java -> Java Help?
I'm sorry that I can't think of the correct key words to search, forgive me, please? Ok? |
|
|
|
|
|
ericfourfour
|
Posted: Thu Feb 15, 2007 11:35 pm Post subject: RE:Is it possible to make a window resizable only vertically? |
|
|
Well then I guess I should show you how to make good search strings.
I prefer: language + class/library + specific action. It works 95% of the time with Java since it is a well known language and there are tons of tutorials for it. ("java frame resize listener" would have been a better search string).
Some research into AWT (since you are using the Frame class) would have held promising as well. You would have known that components have dimensions and can be resized. You would have then looked at the Component class first to find a related listener for what you are trying to do.
You just can't sit on your ass and do nothing for one month until someone finds the answer for you. You have got to search. Do some research. Find information on your own. In the end you will be more satisfied knowing you figured it out yourself and you will also become a more independent thinker. |
|
|
|
|
|
|