Skip to main content

JDIC Browser Issue

1 reply [Last post]
Joined: 2009-06-22


Im pretty new to Java programming and Im working on a project for a professor.

basically the professor has a perl script which creates a summary of his experiment. this script contains css and java script.

now he wants me to build a right click feature in his java app whch will have one option as summary. clicking it, shud reveal this summary pop up.

since i cudnt find any pure java browser which can handle the css and java script, i used the JDIC browser. It works great.

But i have one issue. the frame enclosing the browser shud have the exact size of the summary. but i cant seem to get the size of the summary page to set it as the frame size. there are many templates for d summary and so hardcoding the size is nt possible.

Is there a way by which the frame can automatically take the size of the page being opened. and it resizes as and when the data changes in it

I would really appreciate if someone could guide me . This is really imp for me

Thanx in advance

Message was edited by: rm2000

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
Joined: 2009-06-22

is there anyway that the frame can dynamically resize itself depending on the data being displayed by the browser?

Also is it possible to initialize the browser before its realized/displayed?

the frame resizes on its own in the following example.
just want the same with the browser as well

import javax.swing.JFrame;
import javax.swing.JButton;
import javax.swing.JPanel;
import javax.swing.JTextField;
import java.awt.event.ActionListener;
import java.awt.event.ActionEvent;
import java.awt.BorderLayout;

public class MyFrame extends JFrame {

private String str;
private JPanel panel;
private JButton button;
private JTextField textField;
private String theText = "a bit of work";

public static void main(String[] args) {
String text = "Pack test";
MyFrame frame = new MyFrame(text);

public MyFrame(String s) {
str = s;
textField = new JTextField();

panel = (JPanel)getContentPane();
button = makeAButton();
panel.add(button, BorderLayout.WEST);
panel.add(textField, BorderLayout.EAST);

public JButton makeAButton() {
JButton b = new JButton("Push Me!");
final JPanel thePanel = panel;
final JFrame thisFrame = this;

class ButtonListener implements ActionListener {
private int count;
public ButtonListener() {
count = 0;
public void actionPerformed(ActionEvent e) {

theText += " " + count;
ButtonListener blist = new ButtonListener();
return b;

public String getText() {
return str;