Can we make a group or anything for that matter blur(inactive but seen with a lighter shade), and on a click of button it should be seen proper in SWT.
Calling setEnabled(false) on SWT controls makes them display in a lighter color (and be not responsive).
Note: Unfortunately this does not work for Tables and Trees. You have to set colors for those manually.
Related
I am developing a Java Swing-based application with different perspectives. For the "main menu" perspective I do not want the window (JFrame) to be decorated, while in other perspective I do want the window to be decorated. In other words, I need want to change the decoration attribute dynamically.
I have tried to use setUndecorated(false) and setUndecorated(true), but I seems I can only set this once, before actually showing the window.
Is there a way to achieve this?
From the javadoc:
Disables or enables decorations for this frame. This method can only be called while the frame is not displayable.
Therefore, once the JFrame is packed and/or displayed, you can no longer change that value. If you want to change the undecorated state of a JFrame you will need to dispose() it first, then change the state and eventually make it visible again.
After all, I had to take a different approach.
The former solution did work, as I stated in my last comment.
However, it was showing the default LAF window decoration, while I was using a different LAF.
So the result was graphically inconsistent with the rest of the LAF. Finally, I came with the right solution, I used setUndecorate(true) for my frame. Then, when I had to change my perspective to one using decorations I simply had to use the following code
contentPane.getRootPane().setWindowDecorationStyle(JRootPane.FRAME);
And when I had to revert to the non decorate perspective, I use
contentPane.getRootPane().setWindowDecorationStyle(JRootPane.NONE);
This approach didn't need to dispose the window and show it again (which actually produced a brief but still visible hide/show of the window)
i have difficulties in resizing elements in CN1, f.e. i want to resize a Button and put an image on it to use in a MenuBar, the Buttons are too big so that it exceeds the space of a Samsung S5 Display. Im working with the Designer and tried a lot with the Themes/Styles but dont seem to find a solution for this.
The MenuBar as in the screen has too large buttons, the left one is the Logo of the Company, the Buttons are three in total but only two can be seen..
For the yellow status icon, same problem same hassle :\
Do i really have to manage this in source code or is there a more convenient way with the UIDesigner.
Regards
EDIT : i now found out that using "icon" in the Designer is rubbish. Instead use this following Trick.
Put in a Text, define a Style in the ThemeEditor, set Font-Size in millimeters. Also set the Background Image and its behaviour to ScaleToFit, it should Resize now. Only Downside i have using this technique is that i have to use Whitespaces instead of a Text, is this really the best practice or does someone have a better approach?
Also another downside is that for every Image you have to Design a single Style
In order to support multi DPI's the icon needs to adjust it's size to the many screen sizes available.
Use multi-image https://www.codenameone.com/how-do-i---fetch-an-image-from-the-resource-file---add-a-multiimage.html
I need to place few buttons one under another and few textboxes in the same way using SWT.
When I'm doing that, they are next to each other and I cannot change it even using
button1.setLocation(new Point(100,20));
button2.setLocation(new Point(400,10));
Can I add those things to something similiar to SWING's JPanel and move/position it freely as I need? Or maybe another solution? As to let You know - I cannot use SWING here. It has to be SWT. The reason is that I have already a chart made with SWT. The buttons and textboxes should be placed so they won't be covering my chart.
You can dynamically add a new control to the existing layout, but make sure you call the layout() on the parent Composite, where you have set the layout.
If you want to place a SWT control relative to another control, you can use org.eclipse.swt.layout.FormLayout.
I am developing a Java Swing-based application with different perspectives. For the "main menu" perspective I do not want the window (JFrame) to be decorated, while in other perspective I do want the window to be decorated. In other words, I need want to change the decoration attribute dynamically.
I have tried to use setUndecorated(false) and setUndecorated(true), but I seems I can only set this once, before actually showing the window.
Is there a way to achieve this?
From the javadoc:
Disables or enables decorations for this frame. This method can only be called while the frame is not displayable.
Therefore, once the JFrame is packed and/or displayed, you can no longer change that value. If you want to change the undecorated state of a JFrame you will need to dispose() it first, then change the state and eventually make it visible again.
After all, I had to take a different approach.
The former solution did work, as I stated in my last comment.
However, it was showing the default LAF window decoration, while I was using a different LAF.
So the result was graphically inconsistent with the rest of the LAF. Finally, I came with the right solution, I used setUndecorate(true) for my frame. Then, when I had to change my perspective to one using decorations I simply had to use the following code
contentPane.getRootPane().setWindowDecorationStyle(JRootPane.FRAME);
And when I had to revert to the non decorate perspective, I use
contentPane.getRootPane().setWindowDecorationStyle(JRootPane.NONE);
This approach didn't need to dispose the window and show it again (which actually produced a brief but still visible hide/show of the window)
I've used
chkBox.setIcon();
chkBox.setSelectedIcon();
chkBox.setDisabledIcon();
chkBox.setDisabledSelectedIcon();
to set custom icons for my JCheckbox. But now, if the focus moves to one of the checkboxes, there is no border shown around them or anything else, which tells that the checkbox has focus.
Does anyone know, how to give some feedback when a customized checkbox has focus?
Thanks
Your problem definitely depends on Look and Feel (L&F) that you are using in your application (if you don't setup one - i guess you are using MetalLookAndFeel?).
Anyway, there might be a lot of solutions:
Check that your JCheckBox is actually focusable and focus painted. Be aware that some L&F might switch off focus painting - check checkBox.setFocusPainted() method.
If you are not satisfied with default focus painting - you might want to create your own CheckBoxUI that paints a better focus indicator. That requires some basic knowledge in UIs creation though.
If you want to paint focus indication straight on the check icon itself you can create your own Icon-based implementation that paints it together with current check state. I have posted a custom Icon example in other topic about state-dependant icon if you want to see a real example.
There might be other solutions but they depends on the L&F you are using...
You can use this ready-to use checkbox alternative:
http://codetoearn.blogspot.com/2013/01/swing-fantasy-checkbox-with-customized.html