Using WebRenderer with Java Layout Managers







WebRenderer has a default sizing of 200x200 pixels. A common Java layout manager is the FlowLayout the default layout manager used by a JPanel. When WebRenderer is added to a FlowLayout WebRenderer has a default size of 200x200 pixels. The minium size can be changed by calling the following:

browser. setPreferredSize(100, 100); // Set the browser to 100x100 pixels

In the WebRenderer examples included with the SDK download we use a BorderLayout. The BorderLayout sets the size of the component to whatever space it has left over (if added in the CENTER position) after adding other components as done with WebRenderer in the examples.







Example using a BorderLayout:







JPanel panel = new JPanel(new BorderLayout());
JTextField textfield = new JTextField();
textfield.addActionListener(new ActionListener() {
                public void actionPerformed(ActionEvent e) {

//Must be called to stop License dialog
BrowserFactory.setLicenseData("30dtrial", "TODO:Add your 30 day License Key");
//Core function to create browser
IBrowserCanvas browser = BrowserFactory.spawnMozilla();
// Load the file into WebRenderer
panel.add(BorderLayout.NORTH, textfield);
// Add WebRenderer to the JPanel, in the Center position of the BorderLayout
panel.add(BorderLayout.CENTER, (Canvas)browser);



 Copyright � JadeLiquid Software - www.jadeliquid.com