Codename One How can i resize the BrowserComponent?

Viewed 58

I tried using browser component.set width/height and its not working, the component is extremely small to the point where its not visible, I only tested it by clicking on it and hearing audio.

BrowserComponent browser = new BrowserComponent();
         browser.setHeight(1000);
         browser.setWidth(1000);

browser.setURL("https://www.youtube.com/embed/dV9fKsjkJDQ/");

1 Answers

You can't set the size of a component in Codename One. You need to use layout managers to position it. Otherwise when you rotate the device or run on a smaller/larger device things won't appear correctly.

Since a browser is scrollable and contains variable data its size is non-deterministic so you should place it in the center of a border layout e.g.:

Form myForm = new Form("Browser", new BorderLayout());
BrowserComponent browser = new BrowserComponent();
myForm.add(BorderLayout.CENTER, browser);
myForm.show();

This will place the browser over the full form regardless of screen size or orientation which is a special behavior of the CENTER position.

Related