53084

Why is the dialog size so small with this GWT DockLayoutPanel?

Question:

I've generated a new Web Application project using GWT 2.0.4. I replace the onModuleLoad() code with:

public void onModuleLoad() { DockLayoutPanel dp = new DockLayoutPanel(Unit.EM); dp.addNorth(new Button("north search"), 4); dp.addSouth(new Button("Search"), 4); dp.addWest(new Button("west"), 4); dp.addEast(new Button("east"), 4); RootLayoutPanel.get().add(dp); }

That produces what I think is the right thing; four buttons, one on each edge. But if I try to put that exact same thing into a DialogBox like this:

public void onModuleLoad() { DockLayoutPanel dp = new DockLayoutPanel(Unit.EM); dp.addNorth(new Button("north search"), 4); dp.addSouth(new Button("Search"), 4); dp.addWest(new Button("west"), 4); dp.addEast(new Button("east"), 4); DialogBox dlog = new DialogBox(); dlog.add(dp); dlog.show(); }

What I get is a tiny little dialog box squished up in the right hand corner. The buttons are there but they're only a few pixels wide.

Why? What am I doing wrong? Shouldn't the dialog box have something very similar to the normal window?

Answer1:

RootLayoutPanel is specifically designed to wrap LayoutPanels and takes care of sizing etc. at least to a certain extent. If you want to wrap a LayoutPanel in a normal Widget, you need to set the size of the panel explicitly:

DockLayoutPanel dp = new DockLayoutPanel(Unit.EM); dp.addNorth(new Button("north search"), 4); dp.addSouth(new Button("Search"), 4); dp.addWest(new Button("west"), 4); dp.addEast(new Button("east"), 4); dp.setSize("20em", "20em"); DialogBox dlog = new DialogBox(); dlog.add(dp); dlog.show();

See whether that helps! Good luck!

Recommend

  • Trying to get multiple fields validated in Wordpress HTML form using Javascript
  • Does the Linux implementation of quicksort “back off” to insertion sort?
  • Python Sqlalchemy - tablename as a variable
  • Combine pros from url and props object in Vue router config
  • How to differentiate between UDP Broadcasts and Unicasts?
  • CefSharp - Could not load file or assembly 'CefSharp.Core.dll' or one of its dependencies
  • Do python objects move in memory during execution?
  • Can't call function from body onload (uncaught reference error: start is not defined) javascrip
  • How to fit two divs side by side horizontally?
  • How to load icon from resource in Java?
  • Set default value for entity type in Symfony2
  • Passing a large HTML string from View to Controller
  • Adding multiple rows to DataTable
  • Spark throws java.util.NoSuchElementException: key not found: 67
  • How to make QComboBox popup upwards?
  • Problem with Ruby + rtaglib gem
  • Branch mispredictions
  • Sending/receiving text data from remote server in android [closed]
  • How to render a full webpage in smaller iframe?
  • Uploading files with asp.net core into database as byte array
  • Change taskbar icon at runtime on deployed app
  • HTML5 Video Play/Pause issue
  • IdHttp Post Method Delphi 2010
  • Height for UIViewControllers don't go beyond 10,000
  • htaccess merge 2 segments with underscore
  • Error: packet sequence number wrong after upgrading RDS instance
  • How to send binary with spring boot websocket?
  • Application backgrounding in Xamarin.Mac
  • Finding all XML nodes between each two processing instructions
  • Execute powershell script on a remote computer using C#
  • Threads and Concurrent Modification Exception working with a list
  • can you use embedded ruby in custom javascript files in rails?
  • In metro, get all inherited classes of an (abstract) class?
  • Django REST framework - HyperlinkedRelatedField with additional parameter
  • How to use Typescript with libraries like Ampersand.js that parse configs to build prototypes
  • Swift: UIView.animate works unexpectedly
  • how to specify different css for ie
  • How can i move Clearcase dyamic/snapshot views to another host (Linux)
  • How to use Streams api peek() function and make it work?
  • Will this work on all screen sizes?