i want to assign a multidimensional array to jtree. how can i do this?
here is sample of an array:
ROOT:{ FolderA : {FileA,FileB} , FolderB: {FileA,FileB} } ....
Also i want to determine files and assign icon to them.
You must get model from your jtree and then operate on it. Here you have working example
Here's a nice article showing how to use org.netbeans.swing.outline.Outline for this. There's more in this answer. Ordinary extensions of TableCellRenderer or the RenderDataProvider interface make it especially easy to customize the appearance of rows in the tree.
Related
Is there any grid equivalent object in java ?
I tried using j tables but they don't have all the functionalities needed.
in C# there is a grid object which saves a lot of work. i was wondering if there is any similar object in java.
As far as I know, there is no grid like data structure or collection available in Java. Though you can implement a grid like structure in Java with help of a two-dimensional array.
In case of AWT you might want to use the GridLayout class. Hope this helps.
Definitively the equivalent is JTable, however, if you're trying to create functionalities seems to Grid in C#, you will need to do a little bit extra effort, with swing you should focus on events and add the corresponding listeners in order to add the desired features on it.
I'm working on my first java program. I'm making a Project Manager program.
The base idea is that i have a JList which contains the names of the Co-workers. If you double click one of the names a JTabbedPane will pop up a new tab and will be populated a JTable what is containing the specific persons tasks.
And here comes the tricky part. I want to use this JTable to modify the datas so i need to give a specific name to the JTable so i can use that later on in my methods to call it.
The question is how can i create dynamic names to these tables so i can call it later (something like this: table+tabID).
OR
Is there a better solution to my problem?
Any help or advice is greatly appreciated.
I solved it. The solution was:
I made an ArrayList<JTables> to store the tables and I'm using the tab indexes to get the proper table.
I need to make an expandable list using java swing. I will attempt to demonstrate:
Unexpanded:
>[Expand me!]
>[And me!]
Expanded:
|[Expand me!]
>[Expand us too!]
>[Expand us too!]
>[Expand us too!]
>[And me!]
So, when you click on the "Expand me" portion of the list, another lists will drop down, possibly containing more expandable lists. If you were to click on it again, it's "sub-lists" would then retract. Pretty basic. And, as you can see, I am not looking for JComboBox, and I do not think JList can do this. If someone were to point me in the right direction, or give some programming examples, I would be grateful.
Thanks,
MirroredFate
How about using a JTree.
A control that displays a set of hierarchical data as an outline.
You can try using a JTable and put a button in the first column. When the button is clicked you add more data in the rows in between.
update
Something like this:
Or this
I think the first uses a JTree but that the idea.
BTW these two belong to JIDE Soft, check if it is feasible for you to buy a license:
http://www.jidesoft.com/products/grids.htm
Is not trivial to roll you own but is not impossible either.
check for TreeTable or one example or Outline, but with notice, that on official Java (SnOracle) pages any progress died ...,
First of all, I'm using Swing in Java. In my application, I need to have a multi column list (if that's what I should call it). What I mean by a multi column list is something like windows explorer's list view mode of showing files and folders.
So, all of the columns of my list are going to have the same object (files for instance), but I want to be able to put them on different columns, in order to have a wider view.
Does anyone have any suggestion how I can do that?
Thanks,
Reza
One may use:
list.setLayoutOrientation(JList.HORIZONTAL_WRAP);
Alternatively you can use a JScrollPane. This will handle creating scroll bars and such for you, which would solve the issue of running out of vertical space, and thus eliminating the need for extra columns.
I understand how to make a multiple-select list box using JLists but I want to add JCheckBoxes to the list and make it dropdown like. The best visual representation I have found online is dropdown-check-list.
What would be the best way to accomplish the above?
I was thinking of a TableList. Any suggestions?
If you are using JList, then its as simple as changing the ListCellRenderer to return a JCheckbox component.
EDIT:
For JCombobox, you can use combobox.setRenderer(myListRenderer);
This code snippet may help you.
The basic idea is to handle actionPerformed or mouseClick events by yourself and keep states of the corresponding items (checked/unchecked) in your own data structure. You'll be able to use that data structure for rendering checkboxes in a dropdown