I am extending GWT DialogBox and my constructor looks like:
public MyBox() {
setGlassEnabled(true);
setAnimationEnabled(true);
setWidth("400px");
VerticalPanel contents = new VerticalPanel();
contents.setWidth("400px");
// init widgets
}
When I comment out second line everything works well. With animation enabled is the size of my dialog "broken". When I inspect HTML site the element has correctly 400px, but it just doesn't fully animate :/
I have few such widgets (animated boxes) and some (smaller ones) works well. What might be the problem? Thanks
EDIT:
Here is weird thing. The table element has 432px, but my DialogBox has 400px set everywhere and no padding set. I tried to force padding 0 with css and still no result.
Did you try setting the width before setting animationEnabled? Are you using an XML layout? MAybe try setting the width in there instead of in the class? I suspect the animation actually tweaks the width property and those two are conflicting.
I just looked at an example of something I did that does the same, and I changed the size of the HTMLPanel that is contained inside the dialog box, not the size of the dialog box itself. And this works with animationEnabled.
Related
I am using the Swing GUI editor on the IntelliJ IDEA IDE. In the properties navigator of the JScrollPane there is a property called "border" and, inside of it, a sub-property called "title". There I can set a title to the pane, but I cannot find how to change this title dynamically.
I have tried all the reasonable possibilities that would work with most common swing components, like getting the border (as this title is apparently a property of the pane border) and finding some setText() or setTitle() method somewhere, but I could find nothing...
As I suspected, and as read in the question comments, the whole thing was going around the border property:
String borderTitle = "My fancy title";
Border etchedBorder = BorderFactory.createEtchedBorder();
Border etchedTitledBorder = BorderFactory.createTitledBorder(etchedBorder, borderTitle);
myScrollPane.setBorder(etchedTitledBorder);
Note I used the createEtchedBorder(), but any other available border method creator can be used.
There are probably better ways to achieve this, because in that way you need to set a new border every time you need to change the title instead of just changing the value of its title parameter, but this is doing the trick pretty well.
I hope this can be useful.
I'm doing a program in JavaFX with ComboBoxes, and loading a FXML for the layout.
When I click for the first time in a ComboBox with few items (only two, for example), the scrollbar is shown at the right side. After I open it again, the scrollbar doesn't appear anymore.
I tried some solutions. One that worked is to apply a CSS directly in the FXML, which sets the cell size to a fixed value. But a solution inside the code (for example, in the initialize function in the controller) would be better for my case.
Thanks for any help.
This problem seems to be fixed in recent JDK versions, see https://bugs.openjdk.java.net/browse/JDK-8095019
If the options would stay fixed I would suggest using ChoiceBox instead of ComboBox. It is basically the same, but without the scrollable option. If you insist using ComboBox you can try combobox.setVisibleRowCount()
I am trying to add a tooltip to my ToggleButton to explain to the user what's going to happen if they press it. The problem is, my explanation is too long and the tooltip cuts it off with "..." (the ellipsis string, was it?) Anyway, when I set the max/pref width via a TooltipBuilder like in this example:
this.watched = new ToggleButton("Watched?");
Tooltip tooltip = TooltipBuilder.create().wrapText(true).text(
"Rather than specifying individual images, you can make this source \'watched\',which means that every" +
" time this gallery is viewed, all the images in this directory will be listed.").build();
tooltip.prefWidth(50);
watched.setTooltip(tooltip);
I get this result:
My attempts to set the width via maxWidth(double), maxWidthProperty().set(double), prefWidth(double), and prefWidthProperty().set(double) have been ignored.
Is there any way to overcome this?
In my code, I was setting wrapText(boolean) before setting the width. It seems like JavaFX doesn't like this so much. I changed it to look something like this:
TooltipBuilder.create().prefWidth(300).wrapText(true).<other properties>.build();
This gives me a successful wrap!
In javaFx 2.2 use this:
Tooltip toolTip = TooltipBuilder.create().text(string).prefWidth(500).wrapText(true).build();
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
I'm trying to get a simple layout working under GWT 2.0 using UiBinder. The layout I'm trying to get is one that mimic Java's BorderLayout in where you can specify different panels in the north, south, east, west and center directions; for that I'm using DockLayoutPanel. I would like to get a header and footer, both with fixed width. The remaining viewport space would be occupied by the widget assigned to the DockLayoutPanel center slot.
The current .ui.xml file I've got is:
<g:DockLayoutPanel unit='EM'>
<g:north size='2'>
<g:HTML>HEADER</g:HTML>
</g:north>
<g:south size='2'>
<g:HTML>FOOTER</g:HTML>
</g:south>
<g:center>
<g:HTML>
<div id='loginform'>Hello!</div>
</g:HTML>
</g:center>
</g:DockLayoutPanel>
The browser only renders HEADER at the top left corner. How can I achieve the layout I'm looking for? It seems that there's more CSS you've got to know before you can use GWT layout panels, but that kind of defeats the purpose of creating the UI with it.
This works for me with none of the hacks suggested by RaphaelO.
The Javadoc example on the DockLayoutPanel uses 192 as the width for West. This is wrong - the author probably thought he was using PX, but he was using EM. So if you zoom out, you'll see that Center is far to the right.
Have you checked your using Standards Mode? This is required for the DockLayoutPanel.
Also, forgot to mention that you should use RootLayoutPanel when you add the DockLayout in your entrypoint class - don't use RootPanel.
The use of the newly introduced Layout Panels is indeed quite confusing. There is a way to make the layout occupies the whole client area. It requires a little bit of Java code in addition to the ui.xml file.
In your EntryPoint class, add a UiBinder definition with a annotation to the ui.xml file which declares the layout:
#UiTemplate("LayoutDeclarationFile.ui.xml")
interface DockLayoutUiBinder extends
UiBinder<DockLayoutPanel, TheEntryPointChildClass> {
}
private static DockLayoutUiBinder uiBinder = GWT
.create(DockLayoutUiBinder.class);
in the onModuleLoad function, instantiate the UiBinder, retrieves its root and directly add it to the DOM:
public void onModuleLoad() {
DockLayoutPanel layout = uiBinder.createAndBindUi(this);
// Make sure we use the whole client area
Window.setMargin("0px");
// Add the panel to the DOM
RootLayoutPanel.get().add(layout);
}
I tried your code block as well as the the sample block on the javadoc page for DockLayoutPanel and I am getting similar results. Only the data in the North section of the DockLayoutPanel seems to be displayed. However when i search the page (using firefox and safari on Mac) the other elements are found but they are not showing anywhere. Seems like there might be a bug with this panel and the UiBinder.