Ok, forget the setSize instructions.
Now you can see that the code below calculate a reasonable rectangle. Debug values are x = 1024 y = 767 size = width = 1534 height = 27
Forget also the BrowserComponent. This applies also to when it is not in the layout, and also with BoxLayout instead of BorderLayout.
No matter if an InteractionDialog is used instead of a Dialog.
I ensure you that the result is that tiny dialog you can see in the original attached image.
So why the dialog has not the right bounds?
public static void testWebViewAlertDialog(String s1, String s2,int width)
{
Dialog alertDialog=new Dialog(s1);
alertDialog.setDisposeWhenPointerOutOfBounds(true);
Button okButton=new Button(okCommand);
alertDialog.setLayout(BoxLayout.y());
Container c1=new Container();
Command backCommand=new Command("Back") {
@Override
public void actionPerformed(ActionEvent evt) {
alertDialog.dispose();
}
};
alertDialog.setBackCommand(backCommand);
c1.setLayout(new BorderLayout());
//c1.setLayout(BoxLayout.y());
BrowserComponent testWebView=new BrowserComponent();
testWebView.addWebEventListener("onLoad", new ActionListener() {
@Override
public void actionPerformed(ActionEvent evt) {
c1.add(BorderLayout.SOUTH,okButton);
//c1.add(okButton);
c1.add(BorderLayout.CENTER,testWebView);
//c1.add(testWebView);
Rectangle rect = new Rectangle(getRect(c1));
if (width>rect.getWidth()) rect.setWidth(width);
rect.setHeight(rect.getHeight()+testWebView.getPreferredSize().getHeight());
alertDialog.add(c1);
alertDialog.showPopupDialog(rect); //x = 1024 y = 767 size = width = 1534 height = 27
}});
testWebView.setPage(s2,"");
}