Drag and drop of a 2D diagram ??
Hello
Iam using JPanel for the drawing area container.I want the following functionality:
When I click and release a button I must be able to draw a diagram ( circle ,square etc)
How can I do this
Thanks in advance
I am working on a similar project.
Using canvas instead of a JPanel might be a more proper choice.
You add a mouse listener to the canvas, which returns the coordinates of the click occured. See the documentation,
the code goes something like this:
yourCanvas.addMouseListener(new MouseAdapter(Event evt)
public void mouseClicked(MouseEvent e)
System.out.println("Mouse click occured");
});MouseAdapter is an interface, see the docs, which methods it declares. One of the methods is mouseClicked(), which you have to override to perform actions you wish.
To draw a rectangle, you got to use:
Graphics g = yourCanvas.getGraphics();
g.drawRect(int x,int y,int width, int height);See Graphics or Graphics2D in the docs to be aware what possibilities for drawing you have.
For better understanding use the tutorials, e.g. BufferedShapeMover.java on http://java.sun.com.
I hope this helped a little.
I have similar proble with MOVING the objects I have drawn, I still use to repaint or updated the canvas, together with the mouse listeners. This seem not very clever to me, but I didn't find any component, which could be placed to a container and dragged with a mouse.
good luck
Similar Messages
-
Hi! I'm trying to archive (for myself and others for easy access) about 50 fairly complex .ai files in a single Illustrator Default PDF and maintain editability and preserve layer and grouping integrity for every separate file, and, i'm probably going to have to do this hundreds of times (at least!) in the future. Once i save the initial first pdf file through Illustrator (wish didn't even have to do this, but seems no way to do in Bridge), then open the resulting pdf w Acrobat Pro, can i then just select an entire folder's worth of ai files in Bridge, drag and drop them into the pages panel and still have the dragged and dropped files also preserve all their AI info and layer/ group integrity? An if not, thinking if not based on 20 similar experiments, what's a fast way to do this. Doing this manually each time: opening each file in AI then saving as AI pdf, then combining and arranging them all after the fact, would be, well, fairly effed in terms of time, carpal tunnel, arthritis etc. Experimented w Bridge PDF Output batching (terrible rasterized lo-res results, but great for its intended purpose) and just dragging and dropping into Acrobat (lose complicated layer names and info, all flattened to single layer). Any help most appreciated, and as i do not have regular access to das interwebs (i live on a boat) would appreciate and heed gentle admonishment if i've misposted or broached any community etiquette here. I've researched this as well as i can but can't find anything efficient/ elegant not involving InDesign, and even then the details are skimpy. Thank You! Getting mentally exhausted and not a little loopy. Keep in mind had to teach myself both Illustrator, Acrobat etc with access to the very limited offline help menus (the boat), so a complex answer involving learning InDesign would be learning curve can't even imagine with everything else struggling to do. But if you're willing to babystep diagram it out for me or can find me a link that does i will not only be eternally grateful but will do my durndest to master it and pass it on....Thanks Again! lil mc szpf
PS If it helps I'm running the diligent dogged dusty beloved workhorse CS4 Design Premium on 27" monitor 2010 Mac (OS X 10.6.8), and took advantage of rare housesitting net access to install all most recent updates of everything, i'm barely competent w AI, PS, BR and been tackling Acrobat for past couple of months now....im glad that somebody is atleast trying. perhaps i need to be more clear.
i will step by step describe the issue in detail.
1) i open an email that contains an attachment .dxf or .pdf
2) i click on the attachment shown in the email and aprompt comes up asking if i want to open or save the attachment.
3) i select save. (by default it saves to a downloads folder. but i have also chosen to use other folders (when i did that it wouldnt save them)
4) i highlight the downloads arrow on the right top side of my browser and click it
5) it pulls down a list of the files that i USED to be able to click and drag onto my destop, or anyplace i chose
6) used to be when i clicked and held the left mouse button down on top of a file of my choosing it would highlight and as i began to drag, a ghost image would appear of the file i was dragging. showing a (/) symbol next to it showing i couldnt drop the file within the browser and a + simbol showing that i could drop the file when the file was hovering over a place where i could drop the file such as my desktop or other folder. now, when i click and hold on the file.... I DONT get anything. when i drag. nothing follows. while i am "dragging" in the area that is my browser, i get the pointy finger icon. as soon as i enter an area where i could have dropped the file as before, i get my standard cursor arrow.
its really as if the drag and drop feature just dosent work IN FIREFOX.
i can drag and drop files all day long everyplace else. -
OK - Here's my problem. Just moving from AS2 to AS3 and
trying to create a drag and drop template. I need to re-use a
single drag selection multiple times, to multiple targets and then
graded. For example, say I was building a car by dragging parts
over to a car frame. I need to be able to drag a copy of a tire to
the car frame 4 times in any random order. Drag 2 doors in any
order, or drag one item like a hood... etc, then grade to make sure
all are in the right place.
I have succedded in dragging a specific Drag item to a
specific Target and give feedback as it is dropped (either "wrong",
"correct" or "Good Job, Completed"), but having a bear of a time
trying to figure out how to use one Drag item for multiple Targets.
Anybody have a sample template FLA of the same concept that I
can build from?
Many, Many, Thanks!What I am trying to do is to be able to use one of each of
the images on the left multiple times, and put them in the correct
position on the diagram in any order and then checked after student
drops the item on a target. (sample sent to email)
I have 1 for 1 working (working targets have green
highlight), but can’t figure out how for instance, drag 2
barrels in any order, 6 red squares over in any order and 2 orange
circles over in any random order. I am stuck on 1 drag item for one
specific target only.
I would like the selections to remain to the left and copies
of them created and dragged to the targets. (currently they are
removed from the left when dragged) -
How do I drag and drop an action onto a task flow?
In How to pass View Object bind variable from ADF page John states that
You should also consider dragging-and-dropping the executeWithParams operation on your task flow and wiring it to occur before your page instead of putting it in the page definition of the page itself - this way it is more clear what is happening, and is the recommended approach for 11g apps. When you drag-and-drop the operation, you can use the dialog to bind the parameter to your page-flow-scoped variable by supplying the proper EL there.
How can I drag and drop the executeWithParams method onto a task flow. I am using 11.1.1.5.0 on LINUX?
I'm presuming I a need a method action in my page flow.
I have the following action defined in my page def file:
<action IterBinding="localizedCustomerHierarchyViewIterator"
id="executeQueryWithParamsForLocalizedCustomerHierarchyView"
InstanceName="BusinessRulesAMDataControl.LocalizedCustomerHierarchyView"
DataControl="BusinessRulesAMDataControl" RequiresUpdateModel="true"
Action="executeWithParams">
<NamedData NDName="RootEntityId"
NDValue="#{pageFlowScope.recommendationRule.customerEntityId"
NDType="java.lang.Long" NDOption="3"/>
<NamedData NDName="Language"
NDValue="#{pageFlowScope.recommendationRule.language}"
NDType="java.lang.String" NDOption="3"/>
</action>In summary, it appears you need the following artifacts in order to initialize a view object from parameters before rendering a .jsff view that relies on that view
1) a method-call in task flow.xml file:
<method-call id="executeWithParamsLocalizedCustomerHierarchyView">
<method id="__5">#{bindings.executeWithParamsLocalizedCustomerHierarchyView.execute}</method>
<outcome id="__12">
<fixed-outcome id="__9">initializedLocalizedCustomerHierarchy</fixed-outcome>
</outcome>
</method-call>
2) a control flow rule in the task flow .xml file whose source is (1) and whose destination is the view for which you want to intiialize a view object that supports an iterator that is bound to a list, tree, etc.
3) an entry for the execute action in the databindings.cpx file
<page path="/WEB-INF/[email protected]calizedCustomerHierarchyView"
usageId="oracle_apps_br_view_RecommendationRulePFPageDef"/>
4) the page def must be defined in the databindings.cpx file
5) the page def needs to define action and iterator and list (or otherwise) that is used in UI.
<iterator id="localizedCustomerHierarchyViewIterator"
Binds="LocalizedCustomerHierarchyView"
DataControl="BusinessRulesAMDataControl" RangeSize="25" Refresh="never">
<sortCriteria>
<sort attribute="Level" ascending="true"/>
</sortCriteria>
</iterator>
<action IterBinding="localizedCustomerHierarchyViewIterator"
id="executeWithParamsLocalizedCustomerHierarchyView"
InstanceName="BusinessRulesAMDataControl.LocalizedCustomerHierarchyView"
DataControl="BusinessRulesAMDataControl" RequiresUpdateModel="true"
Action="executeWithParams">
<NamedData NDName="RootEntityId"
NDValue="#{pageFlowScope.recommendationRule.customerEntityId}"
NDType="java.lang.Long"/>
<NamedData NDName="Language"
NDValue="#{pageFlowScope.recommendationRule.language}"
NDType="java.lang.String"/>
</action>
<list ListOperMode="navigation"
IterBinding="localizedCustomerHierarchyViewIterator"
id="customerLocalizedEntityHierarchyList">
<AttrNames>
<Item Value="EntityName"/>
</AttrNames>
</list>
6) a backing bean that provides the functions to initialize the parameters for execution
The easiest way to get most of this is to drag the ExecuteWithParams from within the view in the datacontrols panel right onto the task flow diagram. The downside is that you are left with some pretty poorly named artifacts...
Did I miss anything?
-Klaus
Edited by: klaus gross on Sep 29, 2011 1:00 PM -
Drag and drop not working 2012 and Win 7
This used to work, but somewhere along the way I lost the ability to drag and drop file paths and LV snippets onto a LV block diagram. Has anyone else seen this? I don't think it's a windows issue. And it works in LV2011.
PaulG.
"I enjoy talking to you. Your mind appeals to me. It resembles my own mind except that you happen to be insane." -- George Orwell
Solved!
Go to Solution.Paul,
ok, standard support question on Windows: Does this also occur after reboot?
And my question refers to the right click >> Run as administrator option. It was not the question if your login has administrative rights.... sorry for the confusion.
Norbert
CEO: What exactly is stopping us from doing this?
Expert: Geometry
Marketing Manager: Just ignore it. -
Specify multiple correct targets in a drag and drop?
Is it possible to specify more than one correct target in a drag and drop interaction (i am creating a quiz where the learner has to label a diagram of the urinary system and there are 2 kidney labels they have to correctly drop onto the diagram, however i would like either label to be correct if dragged onto the 2 kidneys - if i've explained this clearly?)
Sorry, overlooked this question. Lot can be solved from that window, glad you found out yourself.
-
I have never been so frustrated before in my life with any phone. I find it obnoxious as it is that I cannot simply drag and drop files (especially MP3's) straight from my PC directly into my phone, which I have been used to doing up until now. Everyone who convinced me to get the iPhone has instructed me that my frustration can be fixed by downloading iTunes and syncing it all up via that program (which I have never used before). So, I downloaded the program successfully, however when I connect the iPhone 4 to the PC and iTunes is open, I get an error message that 'iTunes cannot read the content of the iPhone "iPhone" and that I should go to the Preferences tab of the iPhone and select 'restore' to restore this phone to factory settings. First of all, I don't understand why I need to do that. I have already downloaded apps and other important things in the 2 days that I have the phone. I am also scared that it will erase my contacts. This is such a headache. Music is very imporatant to me, but I am getting so frustrated that I don't have freedom over the phone which I thought was supposed to be one of the best out there. I would really appreciate help in this matter. I am sure the phone is great but I am on the verge of taking it back and getting something else.
Hey joshuafromisr,
If you resintall iTunes, it should fix the issue. The following document will go over how to remove iTunes fully and then reinstall. Depending on what version of Windows you're running you'll either follow the directions here:
Removing and Reinstalling iTunes, QuickTime, and other software components for Windows XP
http://support.apple.com/kb/HT1925
or here:
Removing and reinstalling iTunes, QuickTime, and other software components for Windows Vista or Windows 7
http://support.apple.com/kb/HT1923
Best,
David -
When I drag and drop a website icon from the Forefox address bar to the desk top, the short cut is created but the icon that appears is the firefox Icon. I want to disply the icon from the website that the short cut refers to. I have checked all I can think of in my computer to no avail.
You have to assign the favicon yourself to the desktop shortcut (right-click the shortcut: Properties) after you have dragged the link to the desktop.
You can usually find the favicon in Tools >Page Info > Media and save the icon there.
Otherwise use the main domain of the website and add favicon.ico (e.g. mozilla.com/favicon.ico ) to display the favicon in a tab and save that image to a folder. -
Hi, Im not a frequent forum poster, as most of my questions can be found already answered on them!
This is a question Ive had for a long time and it amazes me that no-one else seems to ask it. I check at each OS upgrade but its never there...
Is there any way of dragging and dropping an iCal event showing in week view across to a date in the left sidebar monthly calendar?
I was able to do this years ago in MS Outlook, and utilized it all the time when I needed to push things back, now I have to open the event and select an new date in the drop-down calendar for each & every event I want to move to a new month at the end of the month.
If its definitely not possible, how to you ask apple to consider including it - it doesnt seem like a particularly difficult task.
Thankyou
Andrew.Andrew,
Is there any way of dragging and dropping an iCal event showing in week view across to a date in the left sidebar monthly calendar?
No, but you can use cut/paste. Cut (⌘X) the event, then click on the week where you want to move the event, and Paste (⌘V).
If you have a suggestion for Apple to change that method use: Apple - Mac OS X - Feedback. -
Why does not drag and drop work?!
Hello,
I am trying to implent a drag and drop from a table to an icon representing a trash.
The drop handler fails in converting the selected rows to a list:
com.sun.el.MethodExpressionImpl@87d9c00d javax.el.ELException: java.lang.ClassCastException: java.lang.String cannot be cast to java.util.List
Could you help me to understand why? Below are the details.
This is the af:table:
<af:table var="row" rowBandingInterval="0" id="t1"
value="#{bindings.MyView1.collectionModel}"
rowSelection="multiple"
columnStretching="last"
horizontalGridVisible="false"
verticalGridVisible="false" fetchSize="-1"
autoHeightRows="6" width="190"
disableColumnReordering="true">
<af:column sortable="true" headerText="Entry" id="c1"
align="start">
<af:outputText value="#{row.Description}" id="ot1"/>
</af:column>
<af:dragSource actions="MOVE" defaultAction="MOVE"
discriminant="delete"/>
</af:table>
This is the drop area:
<af:image source="Images/empty_trash_32.png" id="i2">
<af:dropTarget dropListener="#{backingBeanScope.DropHandlerBean.dropHandler}"
actions="MOVE">
<af:dataFlavor flavorClass="org.apache.myfaces.trinidad.model.RowKeySet"
discriminant="delete"/>
</af:dropTarget>
</af:image>
This is the failing listener listener (the failing point is bold):
public DnDAction dropHandler(DropEvent dropEvent) {
DnDAction dnda = DnDAction.NONE;
if (dropEvent.getProposedAction() == DnDAction.MOVE) { // delete
RichTable table = (RichTable)dropEvent.getDragComponent();
//determine the rows that are dragged over
Transferable t = dropEvent.getTransferable();
//when looking for data, use the same discriminator as defined
//on the drag source
DataFlavor<RowKeySet> df =
DataFlavor.getDataFlavor(RowKeySet.class, "delete");
RowKeySet rks = t.getData(df);
if (rks == null) {
return DnDAction.NONE;
Iterator iter = rks.iterator();
while (iter.hasNext()) {
//get next selected row key
System.out.println(rks.toArray().length); // the number of selected rows is ok
List key = (List)iter.next(); // here gives: java.lang.ClassCastException: java.lang.String cannot be cast to java.util.List
//make row current so we can access it
table.setRowKey(key);
//the table model represents its row by the ADF binding class,
//which is JUCtrlHierNodeBinding
JUCtrlHierNodeBinding rowBinding =
(JUCtrlHierNodeBinding)table.getRowData();
Row row = (Row)rowBinding.getRow();
//delete row;
row.remove();
//activate animation
dnda = DnDAction.MOVE;
return dnda;
thanks.I did try, I obtained this:
java.lang.NullPointerException
Why NullPointerException?
I don't know if this helps, but consider that the collection model comes from a ViewObject built on three EOs with many fields, although the table only shows one column.
This is the Iterator in my pageDef:
<table IterBinding="MyView1Iterator" id="MyView1">
<AttrNames>
<Item Value="Cod1"/>
<Item Value="Cod2"/>
<Item Value="Cod3"/>
<Item Value="Cod4"/>
<Item Value="Description"/>
<Item Value="Cod5"/>
</AttrNames>
</table>
Any idea?
I will see the Key content with the debugger. -
Did my first back up today using external hard drive and time machine now i can't drag and drop
Hi, i did my first back up today using time machine it all went onto my external hard drive fine. Now i cant drag and drop anyhting. I assume ive cahnged some settings in time machine but cant figure it out what to do can some one help ?
thanksBrandbasher wrote:
Thanks Pondini but i have closed time machine, removed external hard drive.
Did you eject it first?
Now i cant drag and drop anything on my desk top, or mail or any other application. Ive tried moving folders, documents none of it works. Even moving around documents within a folder, it wont let me chnage the position of files.
That shouldn't be related to Time Machine (especially if the backups aren't mounted).
What happens when you try those things? Do you get any messages? Anything you can post a screenshot of?
Have you tried a Restart?
Does it happen in another user account? (If you don't have one, create one via System Prefs > Users & Groups.) -
Drag and Drop (re-order) Thumbnails in Organizer
I am using Photoshop Elements version 5.0.2
I would like to re-order pictures in an order that will make sense for me in my business. I suppose I can go through each pix and change the time on them, so I can then sort by time stamp.
Is there an easier way to do this? I was hopeful that I could drag and drop them in Thumbnail view - but I cannot.
Thank you,
Jamie>Is there anyway to delete the photos in the main well, without losing them from my collection?
As I understand the design, the main well is intended to be all the photos that you are managing with Photoshop Elements.
Collections are used to display a specific group of those photos in your chosen sequence for any given activity.
I suspect that since you are using a consumer product such as Photoshop Elements for your business purpose, you may need to make some compromises like having a default (the main photo well) display sequence which you see first when starting PSE that is not what you would choose.
This is not bad if PSE does what you want - just additional steps to switch to the Collection view and also to maintain (drag and drop) the sequencing of the collection when you add additional photo files to a Collection. -
Problems with ListViews Drag and Drop
I'm surprised that there isn't an Active X control that can do this more
easily? Would
be curious to find out if there is - although we aren't really embracing the
use of
them within Forte because it locks you into the Microsoft arena.
---------------------- Forwarded by Peggy Lynn Adrian/AM/LLY on 02/03/98 01:33
PM ---------------------------
"Stokesbary, Michael" <[email protected]> on 02/03/98 12:19:52 PM
Please respond to "Stokesbary, Michael" <[email protected]>
To: "'[email protected]'" <[email protected]>
cc:
Subject: Problems with ListViews Drag and Drop
I am just curious as to other people's experiences with the ListView
widget when elements in it are set to be draggable. In particular, I am
currently trying to design an interface that looks a lot like Windows
Explorer where a TreeView resides on the left side of the window and a
ListView resides on the right side. Upon double clicking on the
ListView, if the current node that was clicked on was a folder, then the
TreeView expands this folder and the contents are then displayed in the
ListView, otherwise, it was a file and it is brought up in Microsoft
Word. All this works great if I don't have the elements in the ListView
widget set to be draggable. If they are set to be draggable, then I am
finding that the DoubleClick event seems to get registered twice along
with the ObjectDrop event. This is not good because if I double click
and the current node is a folder, then it will expand this folder in the
TreeView, display the contents in the ListView, grab the node that is
now displayed where that node used to be displayed and run the events
for that as well. What this means, is that if this is a file, then Word
is just launched and no big deal. Unfortunately, if this happens to be
another directory, then the previous directory is dropped into this
current directory and a recursive copy gets performed, giving me one
heck of a deep directory tree for that folder.
Has anybody else seen this, or am I the only lucky one to experience.
If need be, I do have this exported in a .pex file if anybody needs to
look at it more closely.
Thanks in advance.
Michael Stokesbary
Software Engineer
GTE Government Systems Corporation
tel: (650) 966-2975
e-mail: [email protected]here is the required code....
private static class TreeDragGestureListener implements DragGestureListener {
public void dragGestureRecognized(DragGestureEvent dragGestureEvent) {
// Can only drag leafs
JTree tree = (JTree) dragGestureEvent.getComponent();
TreePath path = tree.getSelectionPath();
if (path == null) {
// Nothing selected, nothing to drag
System.out.println("Nothing selected - beep");
tree.getToolkit().beep();
} else {
DefaultMutableTreeNode selection = (DefaultMutableTreeNode) path
.getLastPathComponent();
if (selection.isLeaf()) {
TransferableTreeNode node = new TransferableTreeNode(
selection);
dragGestureEvent.startDrag(DragSource.DefaultCopyDrop,
node, new MyDragSourceListener());
} else {
System.out.println("Not a leaf - beep");
tree.getToolkit().beep();
} -
I purchased an mp3 from a private website on my laptop. The itunes library i sync ipod to is on my desktop, so i copied the mp3 onto a flash drive and then into my desktop in the Downloads folder and Desktop folder as well as the itunes music folder, 3 places. I opened itunes on the desktop and read the instructions for importing music that's already in my computer. Neither the drag-and-drop or the Add File to Library method works. I've tried both ways over and over. Cannot figure out what the problem is. I do note that the name of the mp3 file doesn't show the .mp3 extension, it appears as simply it's title, Eating Healthy, without any extension at all. Could the filename be the problem, or do you have any other idea what I'm doing wrong? My OS is Windows 7, using IE9. Thanks.
ADDENDUM AFTER READING ANOTHER DISCUSSION HERE: I have now tried right clicking the song in Windows Explorer and choosing Open With, clicking itunes. The mp3 plays in itunes but does not add to the library.I don't have a Recently Added playlist. However, I discovered that the file I had named Eating Healthy was given the name You Can Enjoy Eating Healthy when it copied to iTunes. I'm guessing iTunes pulled the full name of the piece from the internet. Upshot--the mp3 did transfer to iTunes on all 3 tries, but I was looking in my alphabetized list under E, not Y, so I didn't see it there. Thanks for your help.
-
Using drag and drop property in forms.
Hi all,
I want to use drag and drop property in a form during
runtime.I am using oracle 7.3.I don't want to call any
another application.
Is there any way?
Thx in advance.Mona ! First tell your problem in brief ..Actually what you want
on runtime ...would you like to fetching the data from one item
to another or change the position of any item or
pushbutton ...or what..give detail ...obviously i can help you..
there are many commands like set_item_property ,
get_item_property but right now i could not understand your
prob ..tell me in brief..
You can ask me at [email protected]..
-Anwar
Maybe you are looking for
-
I recently downloaded itunes 4.9 and now it wont open. There are no error messages popping up at all when i am trying to open it. My computer is also having trouble shutting down now, weird "end program" messages keep popping up. I have been reading
-
GR IR clearance for previous periods
HI, Our client is trying to clear GR IR Account via F.13. The OB74 settings was configured as WAERS (Currency )as Criteria 1 and PRCTR (Profit Center) as Criteria 2 for the Account Type u201CSu201D. Because of this setting the GR IR account got wrong
-
I'm trying to open a small .pdf file Photoshop is telling me it wont open, that there is not enough ram. It's not on all files, I tried re-saving the file it is messing up on but it still does it. I'm running the newest macbook pro with 16g ram 300gi
-
The date update from TFS online are not visible on Project pro
Hi everyone, I updated the start date and the finish date from TFS online, i saved and refresh the page. Then On the Project pro i clicked on refresh. The update are not visible on project pro. I don't no why because when i change the title of the t
-
There are tables(and columns) like: 'Clients'(clientID) 'Houses' (houseID) 'Visits' (clientID, houseID, visit_date) 'Contracts'(contractID, houseID, clientID, rentDate_from, rentDate_end) I have problem with writing MS SQL query of this kind: how man