Swing/AWT/SWT :: JTree - Drag And Drop Inside One Tree - Java 1.6

Jul 16, 2008

I am trying to drag and drop tree nodes within the same JTree. I have a code which uses Java 1.2 java.awt.dnd.I would like to use TransferHandler and newer implementation.I have found a code which works when JTree is drop target but there is no code where Jtree is drag source and drop target.

View Replies


ADVERTISEMENT

Swing/AWT/SWT :: How To Use JTable Drag And Drop From Netbeans Palette

May 3, 2014

I am still learning how to perfectly use the netbeans palette. I just created a GUI and want to use jTable on it. I have also dragged and dropped jTable component on my GUI. What should I do thereafter? My aim is to allow user input figures into cells, sum up the figures and enter same into a database. I have not used jTable before in java.

View Replies View Related

Swing/AWT/SWT :: How To Drag And Drop Component Within Layout Manager

May 28, 2014

For example, say I have I BoxLayout with a few JButtons in it. How could I make it such that I could drag a JButton such that it could be in front or behind the others?

I've thought about using ComponentMover and just switching to a null layout right before moving it and switch it back right after like bellow, but I'm not sure how to make it keep the change in order.

import java.awt.LayoutManager;
import java.awt.event.MouseEvent;
public class LayoutComponentMover extends ComponentMover
{
private LayoutManager layout;

[code]....

View Replies View Related

Passing File Path To Servlet Using Drag And Drop Method In Java Web

Jun 18, 2014

currently I am doing my java web application project ,and it has following steps 1) Upload the txt files 2) java servlet gets the txt file's url , read the data and do the calculation 3) pass the results

I almost finished the second step , and working on the first step .Since there are so many input files at a given time , i have to use drag and drop method to get the file's location.how to pass file's path to servlet.( servlet code can read the data from the given txt file path )software used - tomcat and netbeans 8.0

View Replies View Related

JSP :: Drag And Drop Form Fields

Feb 28, 2014

I have a web application. I want to generate the UI part(basically html/jsp pages) to be generated dynamically using drag and drop of elements.So is there is any way that I can:

1: Have drag and drop of elements in jsps?
2: How I can create and store back the form attributes dynamically?

View Replies View Related

Move Object During Drag And Drop

Jan 23, 2014

I am just trying to understand during a drag and drop how can I transfer the actual object instead of just creating a new one. I believe I am close but I cannot nail down where I am going wrong. Here is my code I am using to test this.

First/Main:

Java Code:

package main;
import javax.swing.SwingUtilities;
public class Main {
public static void main(String[] args) {
SwingUtilities.invokeLater(new Runnable(){

[Code] ......

When I drag the JPanels it just copies and makes a new one. I tested this by having a sysout send to the console a private int that I set during the initial creation of the object.

View Replies View Related

Drag And Drop Using Robot Class

Jun 4, 2014

Is it possible to do drag and drop using robot class instead of using TransferHandler class?

View Replies View Related

JavaFX 2.0 :: Drag And Drop TilePane

Jan 27, 2015

Any example of a drag and drop tilePanel with VBox as the children? Basically we would like to reorder the list based on user dragging a VBOX.

View Replies View Related

Drag N Drop MP3 File Using JFilechooser To JTable

Jan 21, 2014

including Drag n Drop a mp3 file using jFilechooser to jTable

View Replies View Related

Drag And Drop Word To Match Image

Feb 13, 2014

Any tips or any way?

View Replies View Related

JSP :: Drag And Drop Images (single Or Multiple) To Upload

May 12, 2014

I am working on a piece of a code - drag multiple files from local window and drop it into a DIV in my application. And then I want to bind the file into Struts which is where I am having issues right now, snippet below :

<form id="upload" action="http://localhost:8080/XXX/xxx.page" method="POST" enctype="multipart/form-data">
<fieldset>
<legend>HTML File Upload</legend>
<input type="hidden" id="MAX_FILE_SIZE" name="MAX_FILE_SIZE" value="300000" />

[Code] ...

Is it an issue when I give the inputType name as userImage?

View Replies View Related

Possible To Drag And Drop Controls From DB To Form Design In Netbeans

Feb 6, 2014

Is it possible to "drag & drop" controls from a db to the form design in Netbeans? InVB this is possible. How about Java - Netbeans?

View Replies View Related

JavaFX 2.0 :: TreeView - Performing Drag / Drop With No Selection

Jul 14, 2014

How do I keep an item (TreeItem) from being selected when performing a drag -n- drop? I don't want it to be selected because it will end up making the target disappear (selection of TreeItem changes target panel).
 
Related question: Is there a way to "veto" a tree selection change as well?

View Replies View Related

Swing/AWT/SWT :: Custom Jtree Renderer

Nov 2, 2014

I would like to ask about JTree custom renderer. What could be wrong with this. Here's the deal:

I have a Jtree which suppose to view the structure of given folder, so far so good its working. But my problem is that i dont want it to show the full path as name, only folder name and file name. I wrote a custom JTree renderer in hope that this will solve my problem but it didn't.

Here is my custom Jtree renderer:

private static class MyTreeCellRenderer extends DefaultTreeCellRenderer {
@Override
public Component getTreeCellRendererComponent(JTree tree, Object value, boolean sel, boolean expanded, boolean leaf, int row, boolean hasFocus) {
super.getTreeCellRendererComponent(tree, value, sel, expanded, leaf, row, hasFocus);
if( value instanceof DefaultMutableTreeNode){

[Code] .....

and here is where I am trying to implement it:

tree.setCellRenderer( new MyTreeCellRenderer());

View Replies View Related

Swing/AWT/SWT :: Manually Select A Node In JTree?

Oct 24, 2014

I have problem with manually (through my java code) selecting items in a JTree. I did Google the problem and found solutions here :

[URL]

This code worked for me only partially. Once I tried selecting deeper nested nodes, I ran into problems. Since my production code is very cluttered I built an example and reproduced my exact problem in it.

DummyView.java
package de.fortis.tcws.client.controller;
import java.awt.BorderLayout;
import java.awt.Dimension;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;

[code].....

The important method is 'manualSelect(String[])'.

It streps through the tree by comparing user objects and finds the target node. Then it calls 'navigateToNode()' which uses the solution discussed in the links above.

This method behaves incosistently:

If you call it with an empty array it will correctly select the root node. The righthand pane shows the text of the selected node. = correct

If you call it with target node 1 it will correctly select node 1. The righthand pane shows the text of the selected node. = correct

If you call it with target node 1.1 it will select node 1.1 but for some reason it is not displayed as marked (no background). The righthand pane shows the text of the selected node. = only partly correct

If you call it with target node A it will run into an exception. Debugging reveals that the selection occurs correclty at first. You can also observe the righthand pane showing that 'A' was selected. But afterwards another TreeselectionEvent is occuring that has a NewLeadSelectionPath of null. I do not know where this second SelectionEvent is triggered from.

This code is run with Java 1.6.0_39 which is also what I will have to use in production.

View Replies View Related

Swing/AWT/SWT :: Build Code To Call Class As JTree?

Sep 28, 2014

I am trying to make a JTree. I have used this guide :[URL]

Now when I call my Class with

TreeMainMenu tree = new TreeMainMenu();
JScrollPane MainMenu = new JScrollPane(tree);

I get only the default JTree..

I need to understand how I should build my code to call the class as JTree.

This is my code:

public class TreeMainMenu extends JTree {
private DefaultMutableTreeNode top = new DefaultMutableTreeNode("TOP");
JTree tree;
public JTree TreeMainMenu() {
APNode();
tree = new JTree(top);
tree.getSelectionModel().setSelectionMode(TreeSelectionModel.SINGLE_TREE_SELECTION);
return tree;

[code]....

View Replies View Related

Display Data Structure With JTree In A Swing Application

Aug 28, 2014

I have a tree-based data structure that looks somewhat like this:image1.png..Every tree always has a height of no more then 3, and each of these classes has a very specific use, generalization is not possible between them.Now, I want to display my data structure with a JTree in a Swing application. A JTree needs a TreeModel and so I created a custom TreeModel for my classes, it looks like this:

public class CustomTreeModel implements TreeModel {
private Root root;
public Object getRoot() {
return root;

[code]....

But then I would introduce this interface to my Model classes just for the purpose of writing the View. So my data model has to be altered to make the View work, this sounds completely against MVC to me and also like something I dont really like.On the other hand, the CustomTreeModel would be much simpler, easier to understand, easier to maintain and just in general more pleasing to the eye.Should I change my Model to improve the View? Is instanceof okay to be used in View classes?

View Replies View Related

Swing/AWT/SWT :: Populate JPanel Based On More Information About Selected JTree Node From A File?

Aug 27, 2014

When you select a node in a JTree can you then populate a JPanel based on more information about that node from a file?

View Replies View Related

Java Tree Structure - Build Tree Based On Traversal Results

Jun 17, 2014

How to do draw the original binary tree based on traversal results?

A binary tree has this pre-order traversal result: A,B,D,H,I,E,F,C,G,K,J (TreeNodes) And the same tree gives the following in-order traversal: B,H,I,D,A,C,F,E,K,G,J. Can you draw the tree structure?

View Replies View Related

Swing/AWT/SWT :: How To Add Setbounds Inside Static Void Main In Java

Dec 31, 2014

I am making an application in java, inside static void main, i want to customize all buttons, text areas and want to put them on desired location inside application. I have tried to use setbounds but can not use it, how can i use it, or is there any other way or layout to make my application components customized layout.

View Replies View Related

Swing/AWT/SWT :: StartDrag Method Call - Drag Image Is Not Ready

Oct 15, 2013

Ok so to learn Dnd image ability a little further I created a simple drag and drop application trying to use an external image when trying to drag and drop. Unfortunately I am still getting errors during the startDrag method call. This is the error message it gives "java.awt.dnd.InvalidDnDOperationException: drag image creation problem: drag image is not ready"

The code is as follows:

package com.Test;
import java.awt.Color;
import java.awt.Dimension;
import java.awt.Image;
import java.awt.Point;
import java.awt.Toolkit;
import java.awt.datatransfer.DataFlavor;
import java.awt.datatransfer.Transferable;

[Code] ....

The code the error happens on is:

public void dragGestureRecognized(DragGestureEvent e) {
System.out.println("Drag Started!" + e.getComponent().toString());
//BufferedImage img = (BufferedImage) this.createImage(this.getWidth(), this.getHeight());
//BufferedImage img = (BufferedImage) Toolkit.getDefaultToolkit().getImage("Happy.jpg");
//if (!(img == null)){
//System.out.println("Image is not null!");
//}
Image img2 = Toolkit.getDefaultToolkit().getImage("C:1Happy.PNG");
e.startDrag(getCursor(), img2, new Point(0,0), this, this); //This is where the error is
}

I see the text Drag Started in my console with the sysout line but it will not show the image I am trying to use during the drag operation.

View Replies View Related

Swing/AWT/SWT :: Icons Should Drag Starting At Point Where Mouse Originally Clicked Down

Apr 23, 2014

I am working on a simple app that should emulate a desktop with some icons that you can drag around. I was instructed to use the MouseListener and MouseMotionListener. The icons should drag starting at the point where the mouse originally clicked down on it (ie not dragging from the top right corner).

I am drawing my icons to a jpanel, and I seem to be having two problems:The hitboxes are offThe icon is being dragged from the top right corner, despite having setup up a mouse offset at the beginning of the drag..Here are the relevant classes, the Desktop.draw() method is being called from my DrawPanel

import java.awt.*;
import javax.swing.*;
import java.awt.event.*;
public class Desktop implements MouseListener, MouseMotionListener{
static DesktopIcon[] icons;

[code]...

View Replies View Related

Swing/AWT/SWT :: Creating New Leaves In Tree

Aug 26, 2014

Having trouble adding leaves to my tree. Developing a stand alone Java app using mainly SWT and Eclipse JavaEE on Windows.The tree is like this:

root
------parentA
--------------childA1
--------------childA2
--------------childA3
------parentB
------parentC
--------------childC1
--------------childC2

My requirement: when a child is selected/clicked I want to create a grandchild (there could be from zero to say 12 grandchildren). Thus if user clicks/selects childA2:

root
------parentA
--------------childA1
--------------childA2
----------------------grandchildA21
--------------childA3
------parentB
------parentC
--------------childC1
--------------childC2

Codewise I have:

import org.eclipse.swt.widgets.Tree;
import org.eclipse.swt.widgets.TreeItem;

Question one: do I need any further tree related imports to get this to work?

final Tree tree = new Tree(shell, SWT.VIRTUAL | SWT.BORDER | SWT.CHECK | SWT.V_SCROLL | SWT.H_SCROLL | SWT.SINGLE );
tree.setHeaderVisible(true);
tree.setBounds(975, 00, 375, 600);

[code]...

And it is here I've tried lots of options but it's like bleak mid winter - no new leaves What seems odd is that I can see the selected/clicked child text item.getText() but if I look at the index it is always -1. And I thought the index would let me create the leaf.

View Replies View Related

Swing/AWT/SWT :: Sorting In File Tree Node

May 12, 2014

I have requirement of sorting the files in tree structure with name and timestamp of creation, i am new to swings...

Here we are using FileTreeModel.

Root Folder:
folder1;
file1
file2
.
.

View Replies View Related

Swing/AWT/SWT :: Adding Button To Refresh Tree

Apr 6, 2015

I want to add a button who refresh the tree the problem that i have not "DefaultTreeModel" in my class to do this ((DefaultTreeModel) jTree1.getModel()).reload(); and i try this jtree.updateUI(); but not work ....

View Replies View Related

Swing/AWT/SWT :: Draw 3 Triangles On Top Of Each Other To Give Appearance Of A Tree

Nov 22, 2014

I'm having trouble in 2 areas.

I'm trying to draw 3 triangles 'on top' of each other to give appearance of a tree. My code is below and struggling with how to set my x/y cords correctly.

Also I've drawn a rectangle under a new class and that should then be appearing in the south location of my border layout (south) - but it's not.

import javax.swing.*;
import java.awt.*;
public class Christmas1 extends JFrame {
JPanel titlePanel;
JLabel title;

[Code] .....

View Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved