Java List stops updating after Drag and Drop - java

I am creating an application that converts files from xml to pptx. The user will drag items from a JTree to a JList to create the slide. I have managed to get everything working but the JList seems to disappear after the drop. I know the drop is received because of print statements, and that it's not null. The JList is still there I believe, because I can print the items in the array. Through testing, I think that something is wrong in the custom DefaultListModel I have created. It is not calling an update/redraw/revalidate after the drop for some reason, or has released its action listeners because I notice that the getSize and getElementAt methods stop getting called after the drop. It does however draw correctly if I add items to the ListModel on app init.
I've been looking through all the documentation on ListModels and TransferHandlers but have not been able to get the List to display after the drop. Is my model missing an Override or not handling listeners in some way?
Full source:
http://code.google.com/p/app4args/
Possible problematic file:
http://code.google.com/p/app4args/source/browse/trunk/src/edu/gatech/app4args/utils/CustomListModel.java
To recreate:
Download latest release/source & example xml file from downloads section of project site
Run app, choose File > Import, browse to example xml file
Create new slide: Slide > New Slide, choose Standard (any works)
Drag JTree item from Library to a List in Slide Content View
List does not update, clicking on it or elsewhere in the app and back on the list will make it disappear
Thanks

Turns out I was overriding methods in CustomListModel that were relevant to the updating of how to draw the content of a list. I removed these and reworked a few things and it is correctly drawing now.

Related

How to get and set scrollbar position of Java table at run time?

Currently with help of JAVA SWT (org.eclipse.swt.widgets.Table & org.eclipse.jface.viewers.TableViewer library), I have a table which is getting populated from DB. Idea is to refresh the table data while user is scroll down to check the tables row using scroll-bar and let the scroll bar position restore to same point where it was before refresh event. So that user never feel that some refresh event is working in background while he scroll down the data.
Is there any inbuilt method or library exist in jdk or in above eclipse package to get & set the position of scroll-bar dynamically?
I found a logic to get scroll bar position
ScrollBar vScroll = Table.getVerticalBar();
int valuetemp = vScroll.getSelection();
But after refreshing the table content, when scroll-bar moved to very fist entry after that if I use below code to restore the scroll-bar. Ideally it should work as per API but it didn't move my scroll-bar position to the previous value.
vScroll.setSelection(valuetemp);
I had a similar problem. I tried to keep the scrollbar at the newest table input.
I did not found a solution for the
ScrollBar.class
but the following code worked for me:
table.setTopIndex(table.getItemCount()-1);
I hope this helps :)

How to add in pop-up to jtextFiled view in java

I have developed a java gui that contains two jTextField views for displaying the source and destination file paths. And , the user selects more than one file path , i would like to display previous paths in a pop-up attached to the jTextField. This is a common feature in almost all app.
Does anyone knows how this is called, in order to google how to do it?
It is called editable JComboBox.

How to make an image Viewer in swing?

I am trying to make an image Viewer like the one shown in the figure below:-
Before i can start i have following questions in mind :-
How would i check for the number of images in the target folder so that i can iterate and include all the images in my app.
Secondly,i am thiking to scale the images down to 75x75 .But what i can't think is that how will i slide the images as scrollbar is moved
To be specific,what is the appropriate container for those 75x75 images queue and how that queue is shifted to left or right?(I already know how to get current scrollbar value and add event listeners on it to respond)
To check the number of images in the target folder you can use the File class.
As for the container you might need to create the animation your self. There is no a container ready for doing so.
This site ( and book ) has some ideas about it. I don't know how out-dated it might be though
http://filthyrichclients.org/
Unless I am misunderstanding, making a scrolling list of images is quite simple.
First, create a JList with a datamodel that allows images.
A great example is shown here:
Java drag and drop images in a list
Second, add the JList to a JScrollPane.
The scaling aspect can be easily performed using Scalr:
http://www.thebuzzmedia.com/software/imgscalr-java-image-scaling-library/

Drag & Drop pre-established elements in a Java Form Applications

I want to be able to drag & drop elements in running time with netbeans(Java).
Fo example: I'll have elements as Texboxt,Button,Labels,ComboBox,Panel, Listbox...etc
and I want to drag as many elements as I want, and this elements could be like my toolbox en my application.
My profesor was telling me that I could use Jgraph to do this functionality another thing that he mentioned me was that I could search for a Drag and drop library or framework. for example like in this website, 1: http://cacoo.com
image http://img43.imageshack.us/img43/431/idek.png
Edit: I added this image of an idea. Imagine this is your own editor, and it has its own elements, like shown in the toolbox. What I want is to drag those elements and drop them to the design area, like an IDE; that is my basic challenge rigth now. Also, I wonder if I could do this functionality with JGraph library or another framework that someone knows about it.
Obviously when I click the run button another window will pop up with the elements.

Cloning a frame/tab with swing components/buttons inside

OK a complete revision:
I have a JFrame with a tab that has buttons/textfields etc. inside.Buttons have events that does simple things like reading from an SQL server and filling the textfields from the received query.Pretty simple eh? And now ,I need to add more tabs to this Frame and have to have multiple tabs.In each tab I "must" have the same components/events. So what I am asking is this,how can I clone all the components/events/keylisteners etc. (whatever i have inside that tab) to another tab? I could always add the same components with different names from the code,but I need to find a way to clone the whole tab..
Why not keep the components you already have without duplicating them, and figure out a way to store all the data to be displayed in some kind of model. You could create only some buttons to simulate the tabs, and when clicking on one you display the data associated with it.

Categories