Article View: aus.computers.java
Article #1001Re: Newbie question
From: Tom Davies
Date: Fri, 10 Dec 1999 00:00
Date: Fri, 10 Dec 1999 00:00
38 lines
2423 bytes
2423 bytes
Neil Milne wrote: > > Hi All (or any, as the case may be) - > > I'm fairly new to Java programming and have been hacking around a bit in > JBuilder2 (nice tool, pity about the bugs). At the moment I'm putting > together a simple applet to teach myself more about dynamic object > handling more than anything. > > I've got an extension of a JPanel (call it ObjectPanel) which is being > used to contain a bunch of other objects. These other objects are also > derived from JPanel (lets just call these Object1's), but contain a > ShapeControl, text, etc. and are plotted onto the parent ObjectPanel. > There may be many Object1's, but only one ObjectPanel. OK, so far so > good - now I want to be able to move these Object1's around in > ObjectPanel, but I'm not sure how to go about it. > > I've tried putting the mousedrag even listener on either ObjectPanel or > Object1, but am unsure as to how to move the panel to the co-ordinates > dictated by the mouseevent passed into the listener. I looked at a > bunch of examples but they basically just dealt with boxes and graphical > things painted on the object and called something like > object.SetLocation(...) or simply adjusted components and re-called the > repaint() method which included the code to repaint all the on screen > graphics, which is not something I'm doing manually since the child > objects are being derived from JPanels. > > Help! Thanks in advance - > > Neil. Let me just get this straight -- you have a JPanel to which you have added some other JPanels, and you want to be able to click on the panels and drag them around with the mouse. Is that right? Tom
Technical Details
Message-ID:
<3850514C.C1D0AA74@smartchat.net.au>Path:
arc1-ca.pugleaf.net!unknown!not-for-mailReferences:
<384DF346.1DC7C893@senet.com.au>Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 10d6db,11cfd207a946f410 X-Google-Attributes: gid10d6db,public From: Tom Davies <tom@smartchat.net.au> Subject: Re: Newbie question Date: 1999/12/10 Message-ID: <3850514C.C1D0AA74@smartchat.net.au> X-Deja-AN: 558545600 Content-Transfer-Encoding: 7bit References: <384DF346.1DC7C893@senet.com.au> To: Neil Milne <nmilne@senet.com.au> X-Accept-Language: en Content-Type: text/plain; charset=us-ascii X-Complaints-To: abuse@connect.com.au X-Trace: merki.connect.com.au 944744022 24418 210.8.3.11 (9 Dec 1999 12:53:42 GMT) Organization: Customer of Connect.com.au Pty. Ltd. Mime-Version: 1.0 NNTP-Posting-Date: 9 Dec 1999 12:53:42 GMT Newsgroups: aus.computers.java