ABOUT US

|

SUPPORT

|

BLOG

DOWNLOADS    

 

 

 

 


 

 

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 the layout 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.setText("http://www.google.com");
                
textfield.addActionListener(new ActionListener() {
                public void actionPerformed(ActionEvent e) {
                                browser.loadURL(textfield.getText());
                }
});

//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
browser.loadURL("http://www.google.com");
panel.add(BorderLayout.NORTH, textfield);
// Add WebRenderer to the JPanel, in the Center position of the BorderLayout
panel.add(BorderLayout.CENTER, browser.getComponent());

 

 

 Copyright JadeLiquid Software - www.jadeliquid.com