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
Related
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.
I am building an application with several tabs containing JPanels with JTextPanes. While testing, I wrote text longer than the screen, and the JTextPane grows horizontally. Does somebody know a way to stop it from growing like that? Also, how can I force that the text, once the line has been completed, jumps to the next line on the JTextPane?
Thanks!
UPDATE: I opted for the first option that Julien Gauthier mentioned, which is using JTextArea and enabling the Wrapping. It worked neatly. Given that the size of my text boxes (or areas) is more than enough for the limit I established as text capture (800 characters), I did not need to add Scrolls to the text areas. And also, I did not had any trouble with my save-text-to-file functions with JTextAreas instead of JTextPanes. Thanks a lot for the help!
I wrote text longer than the screen, and the JTextPane grows horizontally. Does somebody know a way to stop it from growing like that?
Add the text pane to a JScrollPane and then add the scroll pane to the frame. Then the text will wrap and scrollbars will appear when required.
Read the section from the Swing tutorial on Text Component Features for a working example of a text pane.
You have several possibilities :
You can first replace the JTextpane by a JTextArea, and use jTextArea.setLineWrap(boolea wrap).
You can use an editorKit with your JTextPane, wich will wrap the text. Please look this example : http://java-sl.com/tip_html_letter_wrap.html
You can use a JScrollPane, but the result will be ugly with long sentences.
Good luck.
What is the exact use of ColumnViewerTooltipSupport? I know that it provides tooltip support for ColumnViewers but does it mean that it provides tooltip for treeViewers? How can I use this feature to provide tooltip support individually different tooltips for my each tree item when the mouse hovers over each item? Do I require a MouseListener for this or does the ColumnViewerTooltipSupport class provide it by default? Can someone please help me out here as I'm relatively new to SWT concepts.
My tooltip has multiple lines, How can I wrap the text and display it neatly? It seems like ColumnViewerToolTipSupport class does not wrap the tooltip text if the text is too long. I would like to use a tooltip window with a vertical scroll bar just like the InformationControl Windows in eclipse? If something like eclipse is not possible then just a tooltip window with wrapped up text.
Please show me an example snippet?
ColumnViewerToolTipSupport adds support for individual tooltips to TableViewer and TreeViewer (and other ColumnViewers), you enable this using:
ColumnViewerToolTipSupport.enableFor(viewer);
The support expects that the label provider(s) for the viewer are based on CellLabelProvider (or one of its subclasses).
CellLabelProvider has getToolTipImage, getToolTipText, getToolTipBackgroundColor, getToolTipForegroundColor, getToolTipFont and getToolTipShift methods that you can override to control the tooltips.
Note: All this is JFace code not pure SWT
Both Eclipse an Netbeans provide a vertical points of interest highlighter next to document scroll bars, which appears to be a part of an extended JScrollPane or is simply a standalone custom component.
I've marked it on the picture below (Netbeans and Eclipse version, in that order).
It highlights lots of different things and represents a flat view of the entire document.
What is this area/component called in general?
I've been looking around on pointers on how to implement such a thing in swing or abuse an existing implementation to my liking but I don't even know what to search for. Both implementations of this thing appear to be quite similar, so I'm hoping they are based on the same piece of code.
It's an extend JScrollPane which has implemted some kind of column footer.
The default JScrollPane provides row and column headers by default, check out How to use scroll panes for more details
Try taking a look at JideScrollPane from jidesoft
Eclipse just calls these vertical rulers (they are implemented with SWT in Eclipse).
I've made a simple GUI with 2 lines of checkboxes. The checkboxes are all the same size. When I maximize the application, they are anchored on the left so it looks a bit out of place.
I would like to have the checkboxes slowly move to the first line if there is space. Similar to the way 'float' works in CSS (on websites).
Does Swing have this type of functionality?
Check out Wrap Layout which works in many cases.
Similar to the way 'float' works in CSS (on websites).
Look to FlowLayout for that effect.