how to remove the content of grid cell in swt? - java

In my wizard page I am using gridlayout with 3 colums. The 3 column will have remove button. I am using add button for the composite. when i push add button it will add new row to the grid layout.
Now I am trying to add listener to remove button. When I push the remove button it should remove the row in which the remove button is pushed from the gridlayout and should resize the composite.
How to achieve this. And how to get the row index of the gridlayout?

To remove the controls completely you need to call dispose() on each control and then call layout() on the parent composite.
GridLayout does not make any information about the positions of the controls available so you can't really get a row index. It does sound like you might be better using a TableViewer to show a proper table.

Related

How to Make a JList with "x" Buttons in Each Cell

I would like to make a custom component that is much like a JList, except there is a little "x" button on the right side of each cell that removes that cell from the list (and triggers an event). I know that you would have to extend JList, but looking at the code for JList I have no idea where to go from there. For reference, I would like the list to be like on the macOS Messages app (except the "x" button can always be visible, not just when the mouse is over the cell).
I would like to make a custom component
I suggest you do that by extending JPanel and adding real components to your panel. Then you can actually add JButton with the "x" that can respond to the mouse event.
A JList does not display real components, only rendered images of the component and therefore is does not respond to events if you try to click on the "x".
The other option is to use a JTable. A JTable does allow you to display values in a column format. In this case it does support the concept of editors, which would allow you to add a button to a column. For example check out Table Button Column.

JavaFX ListView - Scroll with button press

I have a listView that contains my data, but instead of scrolling using the scroll bar, i need to be able to press a button to scroll up (if the listview can scroll up) and a button to scroll down (if the listview can scroll down)
Anyone know how i would go about this? I have checked the listView, and there seems to be no function to scroll up or down.
Ideally i would like to know if there are properties against a listView that tell me the
Maximum Y position that the listView can go to
Current Y postition that the listView is scrolled to
Using these values i can code the rest.
In the end, i removed the listView, and used a ScrollPane with a VBox. Then i added my items to the VBox instead. I had to make changes to the items i was adding to the listView originally, but this seems to work nicely.
I can now use the get/set property VMin, VMax and Vvalue on the scrollPane.
There is Flowless which acts as a simplified(*) (and more efficient) ListView. It has scrollX(dx) and scrollY(dy) methods that you can use to scroll the content.
(*) It does not support selection and inline editing out of the box, but can be implemented on top of it.

How to create a tabbed panel in LibGDX?

In LibGDX, how can I create tabbed panel (screen areas) whose tabs switch visibility between multiple child panels?
Are there any ready-to-go frameworks?
or
How can I code a "TabbedPanel" class?
You could easily do this with a Table and Buttons inside a ButtonGroup
The first Row would be Buttons inside a ButtonGroup, so that minimum one Button and maximum one Button need to be checked.
The second Row would be the content. Here you can use a Pane or Table. Inside the ClickListener of the Buttons you add and remove the content (as Actor) dynamicly.
Use the UI Skin to create tab Buttons, that look like tabs.
I don't think libgdx has it and have never seen it, but i think a good way to go would be using a table inside a table.
the first cell of the first table would have a table made of buttons and the next row of the first table would have the the pane, making every button switch the pane that is in the second cell.
Just an idea though.
Take a look at the table and the scene2D stuff from libgdx
Table layout
scene2D
also take a look at the scene2d UI stuff
Scene2D.ui

How to set the button unmovable?

In android app, I have display the number of buttons in number of rows in GridView using adapter, If i click the button in first row right corner automatically the second row buttons are moved to first row and hide the first row buttons by second row buttons. i need to fix the solution for, the button is not move.
Anyone can give idea to fix the solution for this?
1. Use fixed size Buttons.
2. The professional way to handle it, is usingIcons Images.
In GridView display the buttons inside the EditText and and set the background color as white for EditText, Now the buttons are not moving when click the button in first row on the GridView.

How to move up/down an item in a table

Following is an UI:
There is an Up button and a down button in the UI, when clicking the Up/down button, the selected item(e.g. lib/logger.jar) in the left table(I assume it is a table, because I will create a table to show the items in my Application) will be moved up/down.
Question: How to add function to the Up/Down button, so the item in the table will be moved after clicking the Up/Down button?
BTW, I am using Java SWT/JFace.
If it is a table, you will work with TableItems. To move a TableItem, you have to dispose the one you want to move and create a new one using the constructor that receives an index as one of its arguments. This index is where the new TableItem will be placed.

Categories

Resources