Display text over the icon in JXLabel - java

I'm using SwingX label for a image select/preview.
I need to show both text and icon together but when I set icon the text disappear!
How can I show text over the icon on a JXLabel?
Thanks

there no issue with that, there are two ways
1.correct way (implemented in the API, good habits, blablabla)
JLabel.setHorizontalTextPosition(JLabel.CENTER);
// search for equivalent in SwingX
2.crazy way to set proper LayoutManager for JXLabel and put there another JXLabel to the desired coordinates Location

Related

Vaadin Component Alignent

I have 3 text fields in vertical layout and
I want to place a button at the right of the 3rd text field in HorizontalLayout,
but what happens is the button is placed in alignment with a caption of the text field.
How I solved this issue in Vaadin 8?
Assuming you want the button to align with the box of the TextField (rather than the caption of the field), and the two components are in the same Horizontal Layout, you can use the following:
buttonName.getElement().getStyle().set("margin-top", "auto");
You can use com.vaadin.ui.Alignment for basic alignment needs within ordered layouts. For example:
horizontalLayout.setComponentAlignment(button, Alignment.BOTTOM_LEFT);
The default alignment is TOP_LEFT.

GWT vertical align labels and textboxes in java code

I am trying to vertically align a label and 2 text boxes. I tried to use a horizontal panel, a grid and a flex table, but none of them seems to perfectly align the text. Do you have any suggestions?
You can use .setVerticalAlignment(HasVerticalAlignment.TOP); in HorizontalPanel, but according to the documentation this property affects only widgets that have been added after this property has been set.
If you only support modern browsers, a better solution is to use Flexbox layout model.
You can simply try it with Vertical panel to add widgets like label and textBox.
this can be useful to you, http://www.tutorialspoint.com/gwt/gwt_verticalpanel_widget.htm

use of icons on ToolTipText

Basically, I need an image/icon to show up whenI hover over a swing component
//this is what i normally use to apply image to components
Icon icon = new ImageIcon(getClass().getResource("icon.png"));
label = new JLabel(icon);
what I'd like to do:
//use an imported icon on a tool tip text and also add some texts
label.setToolTipText(icon + "some random text");
Tool tips support HTML, so display that image as you might display it in HTML. E.G. as seen in this answer.

Insert ICON/PNG inside TextArea

Without resorting to wrapping a GWT TextArea in a separate DIV, how to add a search icon/magnifier icon inside the text area?
No, Not possible.Text area is not a normal Widget.
GWT's TextArea maps directly to a HTML TextArea thats why you can only set text to it. The only thing you can do ist create a Grid/VerticalPanel/HorizontalPanel and put in each cell a separate TextArea.
Google Groups
Similar Question
Use a Composite wrapping a FlowPanel, put a text area and an image inside, then in CSS position the icon absolutely so it's over the text field.

java swing- Possible to add JLabel next to application icon/title?

Is the above question possible? The effect I'm trying to achieve is similar to how MS Word displays "Document- Microsoft Word (Technical Preview)" in this picture link: http://img.blogsolute.com/ms-word-2010.png, but with a colored background.
You can set the title of any frame you create by passing the title string to the constructor of the JFrame. You can't, however, add any controls to the 'decoration' portion of the frame - i.e., the title bar.
What you probably can do, however, is create an undecorated frame, and manually add the decoration using customised Border objects. This effectively allows you to put any controls you like around the outside, and the root pane will happily work inside it.
Why do you need JLabel for that? You can use setTitle("") for this purpose

Categories

Resources