Hi I'm new in LWUIT please help me figure this out, I want to make my tabs to stay in tact when I scroll the list within the container that the Tab houses. For example I have a tab on which I add 3 tabcomponent and these components are containers, the first container has different containers in it, the second container has an HTMLComponent and the third one has a list which contains a lot of element more than 100. When I scroll this list the Tabs disappear as the list moves down, so how do i stop this and make only the list scrollable and the Tabs to be always visible like a title?
form.setScrollable(false);
form.setLayout(new BorderLayout());
form.addComponent(BorderLayout.CENTER, tabs);
Now when adding a component as a tab make sure it is scrollable.
Related
I have a Jsplitpane where on the left side I show a list and on the right side there is JTabbedPane. If I click on a list item, then the JTabbedPane will update the info. Everything works good.
Now my question is, when no list item is clicked on ( so basically when you run it first time), then I want to to replace the JTabbedPane with empty panel (blank right side). I tried to do setVisibility to be off on the JtabbedPane but then the divider is pushed all the way to the right. Is there a quick way to just make this JtabbedPane blank and then somehow make it appear later on. Here are screenshots to better explain the situation:
Fully functional window
What I want when no item is clicked
What happens if no item is clicked
I'm trying to add an applet to one of my tabs, but each time I try to add it to a certain tab, it's creating a new tab.
I have already made the tabbed pane using netbeans, added panels to both of the tabs and tried to replace the panel with my applet panel and it's not working correctly. My questions is how can I refer to the "Game" tab and add the applet to that panel?
https://dl.dropbox.com/s/q0lfuz9cxp757n8/Screenshot%202014-07-13%2001.06.42.png
Here's what I'm trying
TabbedPane tabbedPane = new TabbedPane();
tabbedPane.gameTab.add(gamePanel);
And it keeps creating a new tab as seen in the image, but I'm trying to add the gamePanel to the existing "Game" tab.
First of all you don't want to keep creating a new JTabbedPane. You want to update the existing tabbed pane.
Read the JTabbedPane API. There are several approaches you could use:
1) Use the remove(...) method to remove the current tab, then use the add(...) method to add a new tab. The API allows you to add a tab to the end or at a specific index. This is probably the easiest.
2) Use the getComponentAt(...) method to get the panel that was added to a specific table. Then you can add any component to this panel, assuming you have a proper layout.
In both cases the question is why isn't the applet added when you initially create the tab?
When I start my program I have 6 panels. Then I have some radio buttons and depending on the choice some panels hide. In this example I want to hide all panels except 1 and 2. When I click the radio button instead of hiding the rest of the panels and leave the first 2 panels in the current position, it moves them.
private void MonocButtonItemStateChanged(java.awt.event.ItemEvent evt) {
Panel3.setVisible(false);
Panel4.setVisible(false);
Panel5.setVisible(false);
Panel6.setVisible(false);
}
Propably the panel that contains the show/hide panels has FlowLayout manager. When components get invisible the container lays out from scratch the components again.
To get around with this you can use an AbsoluteLayout or make the panels invisible in a diferent way so you cannot see them but they are occuping space.
Looks like switching to Absolute Layout fixed the problem! Solved!
I'm looking for a way to clone (duplicate) a whole tab (the selected one) in a JTabbedPane. Every time I take the tabwith getSelectedComponent() and add it to the pane, the title of the tab disapnö rs and I get no second tab. But there is no exception.
I tried to copy the currently selected tab. Each tab is a JPanel with a simple JTable on it and I want to get the selected tab two times.
As far as I know, the same swing component can't appear in multiple places in your GUI, so you would actually have to create new instances of all your UI elements for the "copied" tab and set their values to the same values of the first tab / connect them to the same domain objects.
In Swings, a component can be added to only one container. Adding it again to another container will have no effect.
is it possible to loading of tabs in jtabedpane dyanamically in java..
that means i have frame that consinting of one tabbedpane..
in that i have 10 tabs and in each tab consting of another tabbedpane and in that each tabbedpane has 4 tabs and each tab consisting buttons and textfields......
when i login into my project the next frame takes more time to visible....
this is happens why because i have more tabbedpanes in my frame so that it takes the lot's of time to visible..
my question is..
is it possible to load tabs content dynamically when i click the tab in tabbedpane.....
or is it possible to load tabbedpanes fastly......????????
It should be quick to load tab panes. What must be taking a moment is the content in the tabs. You can create tabs dynamically with the same way you create them when you build the GUI initially. My guess is that the content is your real problem. Depending on what that is you can load some items on threads other than the EDT and then come back. (Look into SwingWorker).
You can make use of SwingUtilities.invokeLater to push the creation of your inner tab panes to occur after initially displaying your tab pane..
Create the outer tab pane
Create stub panels for all tabs in the outer pane - this will put placeholders in for your tabs, making it look to the user that they have already been created.
Create content for the first tab.
Iterate over tabs 2 to n, creating Runnable instances that setup the content of the tabs, including their inner tab panes. Use these Runnable instances as the param to SwingUtilities.invokeLater. This will put these actions at the end of the EDT, so they will be performed after the current action has completed.
Complete the setup of your outer tab pane, adding it to your JFrame or other container and setting it visible.