Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / General / September 2007

Tip: Looking for answers? Try searching our database.

JPanel resize with mouse problem

Thread view: 
iherage@gmail.com - 25 Sep 2007 22:08 GMT
Hello,

I have a question about how to resize the JPanel with mouse.

There are mainPanel, jPanel1 and jPanel2. The Layout of mainPanel is
BorderLayout. jPanel1 is added to the west while jPanel2 is added to
the center.
What I am going to implement is to move the mouse over the border of
jPanel1, then it shall change to Cursor.E_RESIZE_CURSOR. And with the
move of the mouse, jPanel1 and jPanel2 shall be resized.

Anyone has ideas about this? I have googled again and again and try it
myself. But I still cannot make it.

Can anyone provide some help for me. Thank you for the help.
Knute Johnson - 25 Sep 2007 22:46 GMT
> Hello,
>
[quoted text clipped - 11 lines]
>
> Can anyone provide some help for me. Thank you for the help.

I don't know how to do that but why don't you just use
a JFrame instead.  It will do exactly what you want and
handle the cursor and everything.

Signature

Knute Johnson
email s/nospam/knute/

Roedy Green - 25 Sep 2007 23:01 GMT
>I have a question about how to resize the JPanel with mouse.

Resizing a panel implies other Components will have to change size and
position as well.  Perhaps you might want to rethink and use Frames or
JFrames which can be sized or resized independently, without any
programming effort.

The problem I foresee is every micro change implies a validate/repaint
of the whole app. That might not be smooth or fast enough..

You can check by simulating with timed programmatic micro changes ho
the panels  with validate/repaints, or by seeing the response to
changing the shape of the entire app Frame. You want to run these
experiments on the least skookum computer that will be running your
app.

Signature

Roedy Green Canadian Mind Products
The Java Glossary
http://mindprod.com

iherage@gmail.com - 25 Sep 2007 23:26 GMT
On 9 26 ,   12 01 , Roedy Green <see_webs...@mindprod.com.invalid>
wrote:
> On Tue, 25 Sep 2007 14:08:32 -0700, iher...@gmail.com wrote, quoted or
> indirectly quoted someone who said :
[quoted text clipped - 18 lines]
> Roedy Green Canadian Mind Products
> The Java Glossaryhttp://mindprod.com

The two panels are resided in the mainPanel. And I want to change one
panel's width without the mouse.Of course the other pane's width will
be affected.
There are a few questions left.
1. Which component should register to listen to the event?
2. How to determine the mouse is moving over the border of the two
panels.
3. I think the method that will be used is the setPerferredSize(), but
I do not the detailed implementation.

I have tried myself by implementing a simple program but failed.
Anyone who has experience in the java gui programming knows this?
Please give some hints. Thank you for the help.
Knute Johnson - 25 Sep 2007 23:32 GMT
> On 9 26 ,   12 01 , Roedy Green <see_webs...@mindprod.com.invalid>
> wrote:
[quoted text clipped - 33 lines]
> Anyone who has experience in the java gui programming knows this?
> Please give some hints. Thank you for the help.

Until you explain exactly what you want your GUI to do we are going to
have a hard time helping you.  So please describe simply what you want
your GUI to do.

Signature

Knute Johnson
email s/nospam/knute/

Andrew Thompson - 26 Sep 2007 00:28 GMT
On Sep 26, 7:08 am, iher...@gmail.com wrote:
...
> I have a question about how to resize the JPanel with mouse.

Put it in an JSplitPane.

As for your latter question 'without mouse', try
JSplitPane + JButton(s) - "Bigger"/"Smaller".

But I say that with little more understanding of
your questions than as expressed by Knute.

Andrew T.
Andrew Thompson - 26 Sep 2007 01:31 GMT
>On Sep 26, 7:08 am, iher...@gmail.com wrote:
>...
[quoted text clipped - 4 lines]
>As for your latter question 'without mouse', try
>JSplitPane + JButton(s) - "Bigger"/"Smaller".

I got an email from the OP stating..
"no. I am asked to use the just the JPanel, not JSplitPane."

Now, in case you are confused. Do *not* send me email.
I reposted your comment here on the assumption that you
simply clicked the wrong button when replying.

Please take more care in future which buttons you click,
as further emails from you to me will be deleted without
being read.

Signature

Andrew Thompson
http://www.athompson.info/andrew/

iherage@gmail.com - 26 Sep 2007 10:25 GMT
> >On Sep 26, 7:08 am, iher...@gmail.com wrote:
> >...
[quoted text clipped - 20 lines]
>
> Message posted via JavaKB.comhttp://www.javakb.com/Uwe/Forums.aspx/java-general/200709/1

Sorry. Yes I clicked the wrong button. I am very sorry for that!
I think the Split Panes will work now.

Thank you very much
Andrew Thompson - 26 Sep 2007 12:29 GMT
...
>Sorry. Yes I clicked the wrong button. I am very sorry for that!

It's cool.  ( I am saying that, guessing that means
you intend to take a little more care with the buttons. ;)

>I think the Split Panes will work now.

Excellent.  Glad you got a workable solution, &
since it is more like what the end-user would expect,
I am thinking they will be grateful as well.  :-)

Signature

Andrew Thompson
http://www.athompson.info/andrew/



Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.