Adding icon to costum JDialog - java

I want to change the icon next to the title of my costum JDialog, but i cant get it to work. It worked this way for a JOptionPane before.
private ResourceLoader rl = ResourceLoader.getInstance();
...
setBounds(100, 100, 603, 419);
setTitle("über CogFit");
new ImageIcon(this.rl.loadImage("gfx/srh_logo_32x32.png"));
I already tried this:
JDialog - how to change icon
but it also didnt work.
Thanks for the help

If you want to set the icon displayed in the tile bar you must use the JDialog#setIconImage(Image) method.
https://docs.oracle.com/javase/7/docs/api/java/awt/Window.html#setIconImage(java.awt.Image)

Related

How to add context menu to a canvas element?

Problem : It is not possible to simply 'add' ContextMenu to a Canvas or Pane element via addContextMenu(menu), which works only with javafx.scene.control elements (and neither Canvas or Panel extends this class).
Question : Is there any 'clean' way to 'register' ContextMenu item to a Canvas element? I expect standard behavior of this menu (to show after RMB clicked on Canvas element, autohide when clicked with LMB etc.).
Canvas canvas = ... ;
ContextMenu menu = ... ;
canvas.setOnContextMenuRequested(e -> menu.show(canvas, e.getScreenX(), e.getScreenY()));
James_D's solution may not dismiss the menu when clicking the canvas while the context menu is visible. See this bug :
https://bugs.openjdk.java.net/browse/JDK-8095591
So instead, I suggest using :
Canvas canvas = ... ;
ContextMenu menu = ... ;
canvas.setOnContextMenuRequested(e -> menu.show(canvas.getScene().getWindow(), e.getScreenX(), e.getScreenY()));
Maybe you can use Chrome extension's contextMenu. here is the official document.
The only issue so far I find is that the Context type for a canvas is not clear. ["all"] works but is not a good way.

Vaadin: center componet in Layout dont work with setSizeFull just with static values?

I have a panel inside a layout and tried to center it in the middle:
Doesn't work if layout is 100% X 100% (setSizeFull). Panel is place in the top left of the Window.
But,
If I asign a static value setWidht("500px") the panel is place in the center of the 500px.
Why or how can I center a panel in a Layout with a setSizeFull property?
Some pseudo-code:
class MyVaadinUI
init method
setContent(new Login());
and
class Login extends CustomComponent // Vaadin Composite
Login() // constructor
vLayout.setComponentAlignment(panel, Alignment.MIDDLE_CENTER);
// Code for VerticalLayout and panel is autogenerate by wysiwyg editor
//the problem if that if vlayout is set with 100% x 100% (setSizefull)
//the panel is place in the top-left corner BUT if a set a static value
// 1280x800 it is correct place in the middle center
You have added Panel in the layout and you have called layout.setSizeFull().
You can use #setComponentAlignment this,
VerticalLayout layout = new VerticalLayout();//For example
layout.setSizeFull()
layout.addComponent(panel);//Your panel
layout.setComponentAlignment(panel, Alignment.MIDDLE_CENTER);
EDIT
I think you have not called setSizeFull() on your MainUI class.You have added setSizeFull on LogIn.You should fix the height and width of LogIn and add this.setSizeFull() to the MainUI.
I find a solution. According to this "A layout with undefined size can't contain a component with relative size." So adding a setSizeFull to the UI works:
class MyVaadinUI
init method
this.setSizeFull();
setContent(new Login());

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.

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);

opption menu Jelly bean

How will it be possible to have a menu button which call option-menus with the following condistions ( must be ):
App hides the titlebar :
requestWindowFeature(Window.FEATURE_NO_TITLE);
the targetversion in Manifest is set to 16 :
android:targetSdkVersion="16"
Some Infos and researches from my side:
Setting targetSdkVersion="10" shows the menu still in the bottom, which I would like to achieve.
Showing the titlebar shows the menubutton in top ( 3 points icon ) and the menu is also callable. But I need to hide the titlebar.
any hints , suggestions ?
thanks & regards
Andreas
Another option is to use slider menu and have it on left or right. You shouldn't include button on action bar (like facebook), you can open menu after item click or onFling event.
There is nice and easy tutorial that I tried:
http://oodlestechnologies.com/blogs/Facebook-Style-Slide-Menu-In-Android

Categories