I have a task to create java tree, with three columns: Sport name, Count of sports which are in sport category, and last update. Something similar is dispayed on image bellow:
As you can see, there are 4 kinds of sports: Water, Ball, Skying, Dancing. When I expand skying, there are 3 sports of its kind.
But how to make columns. I can make JTree with nodes and stuff, but how to add columns?
Here is a good example for using a Tree with multiple columns. It looks like this:
I would however suggest using a JFace TreeViewer. There are good tutorials here and here.
It sounds like you want a view that expands like a tree but has rows & columns like a table. Consider Outline, cited here.
Related
So i am thinking about Nattable for a project, it looks excellent, but one of my requirement is to have a good configurable sort on multiple columns with a clear display of what is happening, having see the group example, this is a great bit of functionality:
Where you can drag columns in to a bar that then groups the data by those values, this is what I would like for sorting, ie I don't want the tree expansion, or new rows added, I just want the table sorted in the order that I have dragged the columns. I am trying to work out if this is going to be possible in nattable because the sorting examples for multiple columns are lacklustre compared to this grouping bar, so can it be done?
Sorting multiple columns in NatTable works if the ISortModel supports it.
The _509_SortHeaderLayerExample has a custom ISortModel that does not evaluate the accumulate parameter. The _602_GlazedListsSortingExample uses the GlazedListsSortModel that supports sorting by multiple columns.
Using the DefaultSortConfiguration sorting by multiple columns works if SHIFT + ALT are pressed while clicking on the column header. Using the SingleClickSortConfiguration only the ALT key is pressed while clicking on the column header.
With a good understanding of the NatTable mechanisms it is possible to implement a sorting similar to the grouping UI. You need the grouping header and implement that it should sort instead of group. It is not supported out of the box.
Bus Seat Structure
I need to implement a bus structure which will be generated using number of row and column given, I used a scrollpan as the structure may grow. Each seat is needed to be selected by user. I know I have to generate a matrix, But how can I design the UI that will represent the matrix, each cell will be a button.
You could use a TableView for this. You can create the columns as you like, add a style to it to fit your needs and perhaps add an empty column in the middle to achieve the same as in your picture. Here is also a good tutorial on the TableView.
You can also add columns to other columns. So in your example picture, you could add a "door" column which has a "left" and "right" column.
I need to write an editor with two Trees, where user can map nodes from one tree to another. The biggest challenge is to draw connection line between TreeItems.
Are there any samples that I can use?
There is the link for JDeveloper XSD Mapper tree view
https://technology.amis.nl/wp-content/uploads/images/xsdMapper.jpg
There is a related question here.
There is also the Nebula TreeMapper. Looks like this:
I try to develop a java project for kids to develop myself. I'm not expecting a code, just examples or documentations about it.
The project, takes two numbers and two different kind of fruits from combobox and it displays thoso fruits with matching via line.
For example, the kid select 2 and 3 as a number and apple and orange as a fruit. The program shows 2 apples,there will be line among 2 apples and 3 oranges and there will be line among 3 oranges. And the kid(user) can move the fruits via drag and drop.
How can i do that? I dont know even keywords to search on anywhere.Which libraries or methods i have to learn ?
Sorry for bad language
Thanks
the kid select 2 and 3 as a number
two JSpinners for numbers with one SpinnerNumberModel (you can to reduce range)
or two JComboBoxes with integers in the model as the Items (you can to reduce range)
apple and orange as a fruit.
two JComboBoxes with Icon/ImageIcon in the model (see Oracle tutorial for working code example)
or two JLists with Icon/ImageIcon in the model (use the same methods as for JComboBox, Items in JComboBox are in JList)
can move the fruits via drag and drop.
use JList for this idea
put generated fruits as Item to the model for the another JList (horizontal wrap), for DnD to read Oracle tutorial for working code example about DnD between two JList
How can i do that? I dont know even keywords to search on
anywhere.Which libraries or methods i have to learn ?
post an SSCCE, short runnable, compilable in the case that you will have any issue(s) with a.m. points, demostrated your progress
You can use javaFX. It is much more easier to use than swing and have a modern appearance. There is also a scene builder for javaFX. You can directly place combo boxes or lines via this scene builder.
I have to design an application which handles customer orders. The GUI has tabs, one for the customer and one for the admin. In the customer tab, he has the possibility of submitting an order, by chosing the products from the product list, each having a checkbox in front of them and a text field in which the quantity will be specified.
I am using the netbeans gui editor for the design and I am a bit stuck as the code cannot be modified. I cannot create the product list dynamically (so to create a line for each product in the product array list, and on each line to put the checkbox and the textfield) or at least I don't know how to.
My question is - is there any way of dynamically creating such a list (checkbox + label with the product name + textfield which waits for the quantity) or is there an alternative to my idea ?
Sounds like you need to use a JTable for your list of Products and Quantities. In the NetBeans GUI editor you will only be able to place the JTable on the panel you are designing. After that you need to define a 'Model' for your table which will hold the data you are entering. See the official Oracle Java tutorial on How to Use Tables.
Of course there are lots of other use cases that would fit your requirements, but your design sounds fine. The checkbox is probably superfluous though, as entering a quantity against a product should be enough to indicate that the customer has chosen that Product. If your list of Products gets too long, though, you might want to re-visit this design. Perhaps the table could have 2 coulmns, the first one being a combo-box list of Products, and the second column has the quantity.