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
Related
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.
I'm trying to build a custom UI to practice my interface development.
What I would like to do is create a 'sidebar' on a JFrame, which acts as a tabbed pane for a number of JPanels that I would like to be able to switch between.
Currently, I have a 'sidebar' consisting of a number of buttons, and through clicking a button - I would 'hide' one panel, and 'swap in' another (although I am yet unsure of how best to do this). The panels I am creating are the same size, but I do not know how to swap a panel in one position on my UI with another panel, in that same position.
As a result of this I have researched tabbed panes, and these seem like they could be perfect for what I'm trying to implement. I know I can set each pane to display my own JPanel, but I would like the actual tabs to be represented by the custom buttons I have made.
Is this possible with the JTabbedPane class? Or should I continue figuring out how to swap in and out my panels using the button action listener?
I would like to create something like this in JavaFX:
The Panel with the song titles is expanded and collapsed by clicking on the album cover. The other albums are moved down when it's expanded and up again when collapsed.
What would be the most simple way to do this? I thought of using an Accordion, using the images as titles, but I'm not sure if it can be stylized in a way that it looks like this.
Since the icons should be realigned when the window size is increased, I'd like to use a Flow- or Tile Pane for the main layout. Animation would be nice-to-have, but is not absolutely necessary.
I'm grateful for any hint!
I cannot think of a simple way to have the albums in the second row to move down. However, if you want a grid of albums and a pop-over that appears when the user clicks on the album, the ControlsFX library’s GridView and PopOver control may help you. Although the GridView example in the link above shows only images, you can embed a whole scene graph (the image icon of the album, the title label, and the artist name label) in each cell.
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.
I am developing a desktop Java application with GUI implemented through Swing. I have made a JFrame and have added three buttons on it - Add, Edit, Delete.
Now I want that whenever a user clicks on any of the button, the content specific to that button appears besides those three buttons.
So how to implement this? Should I need to add a JPanel besides those three buttons and then add the content specific to the button to that JPanel?
So far, I have taken a JFrame and have added 3 buttons on it. That's it.
For the Add button, I want to add some buttons and textfields to add information to the database.
For the Delete button, I want to add some buttons to find records in the database based on the information entered through the user in the textfield that appears when the user clicks on the Delete button.
Similar type of content for Edit button.
So how to implement this. Should I need to add a JPanel besides those three buttons and then add the content specific to the button to that JPane
That would be fine. When you push the button, you can call JPanel.removeAll() to remove all the controls currently in the control, and then just do the layout again, specific to whatever button you pushed.
If you have custom swing controls, just add your custom control the JPanel using a BorderLayout and putting in the center.
Another option would be to use a CardLayout, and flipping between the cards when a user presses one of the buttons. If the layouts for the buttons never change, that would probably be a better way to do it. Obviously if the content changes between button presses, you'll need to redo the layout each time.
Either of Chad's or Alex's answers would be fine. You will probably need to call a combination of revalidate() and repaint() on the panel that you've changed, as in the past I've noticed Swing doesn't always like panels being swapped out.
Also, have you considered using a JTabbedPane instead of manually coding the interaction with the add/edit/delete buttons?
I haven't done a lot of Java programming, but I think using 2-3 different JPanel, and make visible the one you need depending on the button that was clicked would do the trick.
I'm not sure if this is the right approach though.
I was using a JFrame to add all buttons and make a new JFrame for a new window and hide a previous one.
gven way are better. I will do that now.