How to set arbitrary TreeViewTable expander column in javafx - java

I have TreeViewTable like image below:
TreeViewTable
I want to set the second column to be hierarchical (with expander as well) instead of the first column. The first column is vertically aligned and the second column is tree-like displayed.
I have tried for hours but couldn't figure out how. What should be the best approach achieve that?

This is very easy in javafx. You just need to call method treeColumn(col) of TreeTableView

Related

draw layout widget on libgdx

I am almost new on LibGDX
I need to draw an overlay on my game like this one:
There is a background, 2 text and a botton
I would like to draw it using a class and reuse it in many part of my game.
I try to extend a "stack" class but is not good.
Also I would like to add the class into a table so probably I need to extend an actor
Can somebody tell me witch layout/class/widget is the best to achive this?
Thanks
If your layout will be similar to the image you posted, you could use a Table for that.
https://javadoc.io/static/com.badlogicgames.gdx/gdx/1.11.0/com/badlogic/gdx/scenes/scene2d/ui/Table.html
I often use nested Tables if I need to span multiple columns/rows instead of trying to do everything in one Table. This makes things easier to work with IMO.
For the example image you posted, you could use two tables. Table1 is the entire widget and Table2 has the two Label (text) items. Then you can set the background on Table1, which will place the background behind everything in the table.
To layout each item in the Table, the Cell (part of LibGDX's Table) is typically used for this. You can set size, alignment, padding, spacing, etc. on each cell of the table to get the layout you want.
For example, to add a padding of 20 to the left side of the button:
table1.getCell(button).padLeft(20);
Here is the API for Cell.
https://javadoc.io/static/com.badlogicgames.gdx/gdx/1.11.0/com/badlogic/gdx/scenes/scene2d/ui/Cell.html

Possible efficient ways of creating a timetable in Android (Java)

I've been trying to create a timetable and I have tried different layouts, the best i could get is to use a grid layout.
a preview of how it looks:
The header is a fixed view, I added that manually in the xml file.
but each of the "Off white" cells and cells that contains time are textviews added dynamically using a loop.
However I think it's not the most efficient way of creating this, also I wouldn't be able to locate those cells unless I add an id to each of them dynamically and store those Ids.
This example shows an empty time table. but those cells should be able to expand and merge with others when an event is added.
Is Grid Layout the only way to build this and is there more a more efficient way to locate each cell position?
this is similar to what I'm trying to achieve

Looking for approach to display multiple records on single row using celltable

Generally, for GWT list views of POJOs/DTOs I typically use a ListDataProider and a CellTable and place the CellTable into a Vertical Panel with a SimplePager. All is well.
I have a scenario where the Pojo's DTO is only 3 fields; and as such it would be nice to create a list view where I can put two columns of my DTO's next to each other and page accordingly. For example, instead of just three columns per row, there would be six where the first three columns represent one DTO instance and the next three (repeated) columns represent a second DTO instance.
Has anybody successfully done this before using celltables or other GWT component? Looking for a simple approach.
My fallback position (which is good enough) was to use a FlexTable with a search form and caping the results to 40 records. Two columns of 20 DTO's.
I have done something similar. I was using a Grid. The key to align the components was this line of code:
myGrid.setWidget(position/COLUMNS_NUMBER+1, position%COLUMNS_NUMBER, lName);
Where lName was a GWT Label with the element (property) to be displayed (the 'name' property of my POJO / DTO). COLUMNS_NUMBER is my constant for how many columns I want to display.
I was displaying just this property, but you could easily adapt this idea to show more than one property of more than one DTO in different columns. My algorithm was just iterating through the DTO collection, getting each DTO's name prpoerty, which would be inserted as a Label in the Grid via setWidget, and updating the index variable position, which starts in 0.
I also needed this condition:
if(position%COLUMNS_NUMBER==0){
list.insertRow(position/COLUMNS_NUMBER +1);
}
I'm displaying only onew property of each DTO, but the idea is also not having each one in a different row, and customizing the number of columns displayed. Again, you can adapt that to meet your needs, by adapting the way you increment the index variable position and the column where you display the DTO property or (even simpler) by following the same approach and just choosing a different property to display each time depending on
postiont%3
since you want to show 3 properties of each DTO.

how can i programatically select a particular text from JTable when i do search in it?

here are the screenshots of the application
Rows will be displayed in the Table according to the text which is written in the search textfield.
Now i want to mark that particular text as per the shown in the second image with the yellow color
I know how to select a row or a particular cell.
but I don't know how to select a particular text inside the cell of any row in the table.
I am guessing you know how to search in JTable, so I am not pasting code of it here.
You can look over the SwingX library. It has this kind of function as you said predefined it it. You just need to add it to your table. This is where you can find it. Give it a try you will surely like it.
The basic premise would be to use a custom TableCellRenderer that provided the functionality that you require.
The problem is how to implement it.
I would create a TableCellRenderer based on a JTextField, remove it's border and make it transparent. This will allow you to use the text highlighting functionality provided by JTextCompoent to highlight portions of the text, as demonstrated here.
The next problem is then knowing what to highlight. There are a number of possibilities.
You could provide a method in your table model that could return the current text that should be highlighted.
I'd, personally, probably use the JTable#putClientProperty and JTable#getClientProperty methods to seed the search text.
Or, you could actually provide a simple model that directly to the renderer which had a method that returned the current search text. This might actually be more useful as you could link it to field, the method building the filter and the renderers and allow them to simply seed each other

How to check for empty cells in Gridbaglayout?

How to check for empty cells in gridbaglayout?
e.g. there are 100 cells, only 10 filled with label or pictures?
Well the GridBagLayout has a getConstraints(Component) method. So you could get all the components in the Container and then get the constraint for each component. The constraint will contain the gridX/gridY value which you could use to populate a 2D array. You may also not to consider the gridWidth/gridHeight values.
So the answer is yes you could derive all the information.
You can use table2gridbag to avoid producing empty cells in the first place. It's a console tool that takes an HTML table, describing the layout, and transforms it into suitable Java source code for configuring the GridbBaglayoutManager to produce an equivalent layout.

Categories

Resources