GXT3 Remove tab from a tabpanel/tab container - java

I am using GXT3 version. I have a screen with tabs where on the first tab I have add button which opens new tab where I do certain functions. After done I need to close the newly opened tab on click of close button which I am not able to do.
To add the new tab I am doing this
tabPanel.add(childPanel, new TabItemConfig("some title"));
where childPanel is a verticalLayoutContainer widget of another class. The close button is in this another class.
How can I remove this new tab?

if I understood your problem, in gxt3 you need pass in the config if your new tab can be closed.
TabItemConfig tabItemConfig = new TabItemConfig("Some Title");
tabItemConfig.setClosable(true);
tabPanel.add(childPanel, tabItemConfig);
So the new tab has a close button.

Related

HI In Codename one I created a button on my form but when I click on the Button it does not perform the Action Event

I Created a button on my codename one frm but when I click on the button it does not perform the Action Event. I tried removing the Button and to recreate but it does not work.
Using something like:
Button b = new Button("My Button");
myForm.add(b);
b.addActionListner(e -> {
ToastBar.showInfoMessage("Hi There");
});
Works for me.

How to remove close button from tabs in JavaFX

I have created some tabs in a TabPane. Each time I make a tab it has got a close(x) button on its right side. I don't want the tabs to be removed from the TtabPane so I have used:
TabPane tabPane = new TabPane();
Tab tab = new Tab("new tab");
tab.setContents(new Label("Please help"));
tabPane.getTabs().add(tab);
tab.setOnCloseRequest(e -> e.consume());
so that it won't be removed. Is there some way not to display this close button on tab.
Any help is appreciated.
You can set the TabClosingPolicy on a TabPane
myTabPane.setTabClosingPolicy(TabClosingPolicy.UNAVAILABLE);
There are the following possibilities:
TabClosingPolicy.ALL_TABS // all tabs can be closed
TabClosingPolicy.SELECTED_TAB // only the selected tab can be closed
TabClosingPolicy.UNAVAILABLE // you cant close
If you are adding classes to myTabPane.getTabs() there is also the possibility to set the class to not be closeable (because it needs to extend from Tab):
setClosable(false);
If you define it in the class which extends from Tab I guess the policy you set will be useless and is overridden.
Link to the oracle doc:
JavaFX 8 TabPane.TabClosingPolicy
You can also define this using FXML by this code:
<TabPane tabClosingPolicy="UNAVAILABLE">

JavaFX How to get a children (WebView) from a Tab?

I have just started to do things with JavaFX and I'm trying to 'build' an browser. Right now I have a TabPane with two tabs. One tab has a WebView and the other tab is able to add new tabs. Over the TabPane is a Textfield. When I enter an internet adress I want to load a website in the selected Tab.
My Problem is, that I dont know how to get the Webview inside the selected Tab. I was able to get the selected Tab, but I have no Idea how to get the WebView inside it.
int index = TabPane.getSelectionModel().getSelectedIndex();
Tab selectedTab = TabPane.getTabs().get(index);
You could always call selectedTab.getContent(), and then navigate down through the scene graph hierarchy until you get to the right element. E.g. if your tab content is a BorderPane and the WebView is in the center you could do
BorderPane selectedBorderPane = (BorderPane) selectedTab.getContent();
WebView selectedWebView = (WebView) selectedBorderPane.getCenter();
This is pretty ugly code, though, and you'd have to rewrite it any time you changed the layout, which means your application becomes hard to maintain.
A (much) better way would be to create a variable at the appropriate scope (controller for the view that displays the tab pane, or the class that contains it if you're doing the layout in Java) for the current web view:
private WebView currentWebView ;
Then whenever you create a new tab containing a web view, add a listener to the tab's selectedProperty:
Tab tab = new Tab(...);
// ...
WebView webView = new WebView(...);
// ... layout, etc tab content, etc...
tab.selectedProperty().addListener((obs, wasSelected, isNowSelected) -> {
if (isNowSelected) {
currentWebView = webView ;
}
});
Now currentWebView always references the currently displayed web view. (You will also need to initialize it to the first web view displayed at startup.)

Popup disappears while selecting options from ListBox<String>

I have a popup in GWT UI screen, in that popup I have Listbox. My problem is when I try to select any option in the ListBox popup closes itself and all I can see is ListBox dropdown options.
PopupPanel have autoHide function in default.
Use below code to disable autoHide when creating PopupPanel.
PopupPanel myPopUp = new PopupPanel(false);
Use these methods to handle open and close PopupPanel.
myPopUp.show();
myPopUp.hide();

Add a new Image to an action button

I want to add a new Icon that is currently in the workspace of the project, concretly in "icons/launch.png", to a button in a eclipse project. The standard code is this:
action1.setImageDescriptor(PlatformUI.getWorkbench().getSharedImages().
getImageDescriptor(ISharedImages.IMG_OBJS_INFO_TSK));
This add the IMG_OBJS_INFO_TSK to the button.
Does anyone know how to add a new Image to it?

Categories