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


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 :: 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 View Related

Swing/AWT/SWT :: Change Location Of Component Using Grid Bag Layout

Jun 13, 2014

How to change the location of a grid bag positioned component after it's already been added to the layout earlier?

Example is if I want component 1 to change from row 1 to row 2.

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

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

Swing/AWT/SWT :: Panel Doesn't Refresh When New Component Added If Smaller Than Largest Visible Component

Jan 26, 2014

I have a JPanel that's using a simple GridBagLayout.

JPanel panel = new JPanel();
GridBagLayout qPanelLayout = new GridBagLayout();
qPanelLayout.columnWidths = new int[] { 0 };
qPanelLayout.rowHeights = new int[] { 0 };
qPanelLayout.columnWeights = new double[] { Double.MIN_VALUE };
qPanelLayout.rowWeights = new double[] { 0.0 };
panel.setLayout(qPanelLayout);
componentCount = 0;

Based on user input I am adding sub-panels to the panel. These sub-panels may vary in height. They take up the full width of the Panel.

public void add(Component comp) {
GridBagConstraints gbc = new GridBagConstraints();
gbc.fill = GridBagConstraints.HORIZONTAL;
gbc.insets = new Insets(2,2,2,2);
gbc.gridx = 0;
gbc.gridy = componentCount++;
panel.add(comp, gbc_questionPane1);
}

The odd behaviour I'm seeing is that if the height of the new sub-panel I'm adding is less than the height of the largest sub-panel currently displayed then the main panel does not repaint. If its height is equal or greater then the Panel does repaint, and any sub-panels that were added but not visible before are now painted. What have I missed?

View Replies View Related

Swing/AWT/SWT :: Can Mig Layout Work As Border Layout

Jun 1, 2014

I want to add only one button in a JFrame by using Mig Layout, dock south as BorderLayout.South does . Is it possible?

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 :: Adding ActionListener To Button Component?

Mar 7, 2014

Can I add actionListener to a button component without creating a reference to it? Look at my code below:

public void init() {
setBackground(Color.red);
//Create the layout
setLayout(new BorderLayout(20, 5));
//Add buttons
add("North", new Button("Red"));
add("South", new Button("Yellow"));
add("East", new Button("Cyan"));
add("West", new Button("Magenta"));
add("Center", new Button("White"));
}

Or should I just do the usual instance.addActionListener(this) like myButton.addActionListener(this)?

View Replies View Related

Swing/AWT/SWT :: How To Come Up With GUI Application Involving List Component

Feb 1, 2014

I am learning Java on my own and I am taking on very small project by myself for fun, and I'm just stuck on this small part of the project.
So I have created a text file that contains a small list of toy names and prices, like:

Barbie, 12.95
Lego, 15.99
Hot Wheels, 5.00
Power Rangers, 6.49

And what I would like is my application to read the contents of the file and store the toy names in a list component. And then I want to be able to select a toy name from the list and add it to a shopping cart that is a list component as well. I want to the application to have menu items and buttons to allow me to remove items from the shopping cart, clear the shopping cart of all selections, and check out. When I check out, the application should calculate and display the subtotal of all the toy names in the shopping cart, the sales tax (which can just be 8 percent of the subtotal), and the total.

View Replies View Related

How To Pass Main Arguments On Execution To Swing Component

Aug 4, 2014

I wish to use args passed to main(String[]) during application execution to a Swing component.

In a simple example, assume args passed are: a b c d

And here is the result I look for:

package argsinswing;
import javax.swing.JOptionPane;
public class ArgsInSwing {
public static void main(String[] args) {
String str1 = args[0];

[Code] ....

View Replies View Related

Swing/AWT/SWT :: Replace Dropdown Of JComboBox By Another Component Like JTable?

Jan 29, 2015

My question is related to combo boxes. A combo box in general is a text field with a dropdown list. I would want to know if we can replace hthe dropdown List by an other component, for example a JTable component.

View Replies View Related

Swing/AWT/SWT :: Spring Layout Odd Sizing

Mar 12, 2015

I create a spring layout like so

Container contentPane = this.getContentPane();
JLabel characterLabel = new JLabel("Character: ");
JComboBox<String> characterComboBox = new JComboBox<String>();
characterLabel.setMinimumSize(characterComboBox.getMinimumSize());

[Code] ....

and I have attached an image of the results.

Why are the drop down boxes not stretched to the right all the way and why are they so tall?

View Replies View Related

Swing/AWT/SWT :: MVC Layout - Adding Listeners?

May 4, 2014

So I'm doing a basic MVC layout for a pretty basic game that I am making in order to understand the whole MVC layout. The game requires the user to move up/down/left/right via JButtons on the GUI. Since I'm using an MVC layout and my buttons are in a different class than the ActionListeners, I was wondering what the best way to add the action listeners are?

Method 1:

View Replies View Related

Swing/AWT/SWT :: Alternative To Null Layout

Aug 10, 2014

My IDE has a visual editor for creating Swing applications. The created application windows have no layout manager and use method "setBounds()" for placing Swing components on the application window. I have built an application that uses JInternalFrame. Each JInternalFrame is a separate and different "screen" for the user to interact with.

There are around 2,000 screens in the application and new screens are constantly being added as well as existing screens being modified. As a result, the top-level container - a JFrame - is a fixed size and is not resizable. I have now been asked to increase the size of the JFrame while maintaining the proportions of the screens.

Rather than manually editing the invocations of "setBounds()" on all the screens, any alternative way to achieve this? Also, is there a way to achieve this such that if, in future, the JFrame will again be resized, the screesn will automatically adjust?

View Replies View Related

Swing/AWT/SWT :: Layout With Fixed Heights And Gaps?

Jan 29, 2015

I'm trying to build a GUI that must look lik on the image above. There must be three JPanles, the one above, with buttons and combo boxes, must have fixed height and all three must have fixed vertical gaps between them. I'm trying laout after layout but somehow it's not working. I'm allowed to use only standard Swing layouts.

View Replies View Related







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