Add a new Image to an action button - java

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?

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 do I edit properties of components?

Let's say I have a button. How would I programmatically edit its properties? I don't want to change the properties using XML code in the layout.
Declare your Button variable:
Button button;
...
Then write the following in your onCreate() method:
button = (Button) findViewById(R.id.<Your buttons ID>);
button.setHeight(50);
Please rather do research before asking questions.

SmartGWT- how to change filter button icon in listGrid?

I want to change this filter icon to another one, I have tried this method setFilterButtonProperties(newButton);
but it doesn't work.
here the image which I want to change.
Try this one
Button newButton=new Button("");
newButton.setSize("18px", "18px");
newButton.setIcon("[SKIN]/RecordEditor/add.png");
listGrid.setFilterButtonProperties(newButton);
Note: Change the icon path and size as per your requirement.

GXT3 Remove tab from a tabpanel/tab container

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.

JFace Action and ImageDescriptor - I wnt to show image and text

Action myAction= new Action("LABEL", ImageCache.getImageDescriptor("IMAGE"));
This code shows me a button without any text. Instead it only shows the image.
What should I do to display them both side by side?
I tried using setText() and setDescription() and setImageDescriptor() but none helped.
Text is not normally shown for an action in a ToolBar if there is also an image.
If you are adding the Action to the tool bar manager using an ActionContributionItem you can call ActionContributionItem.setMode(ActionContributionItem.MODE_FORCE_TEXT);

Categories