Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie

A simple java Class and Swing question

Options
  • 14-10-2004 12:42pm
    #1
    Registered Users Posts: 2,102 ✭✭✭


    Hi all!

    I'm doing up a simple web browser, just for the learning experience. Now I have 3 classes: Buttons (self explanatory) a JPanel, then I have URLWindow a JPanel and finally Browser.

    Browser displays the buttons fine, but won't display the JEditorPane class.

    I don't know what I'm doing wrong, but if I change the EditorPane class to be extend JFrame and give it a main method it works fine and surfs the net....

    I have:

    public class ImagePanel extends JScrollPane implements HyperlinkListener

    Which I think might be the problem. So my question is simply this, how do I change the code (given below) to work with the Browser class.


    ublic class URLDisplayPanel extends JScrollPane implements HyperlinkListener
    {
    private URL url;
    private JEditorPane htmlPane;
    private JScrollPane scrollPane;


    public URLDisplayPanel()
    {
    super();

    try
    {
    url = new URL("http://www.apl.jhu.edu/~hall/");

    htmlPane = new JEditorPane(url);
    htmlPane.setEditable(false);
    htmlPane.addHyperlinkListener(this);
    scrollPane = new JScrollPane(htmlPane);



    }
    catch(MalformedURLException mue)
    {
    System.err.println("url: " + mue.getMessage());
    }
    catch(IOException ioe)
    {
    System.err.println("read: " + ioe.getMessage());
    }


    }

    .... etc.


    In Browser what I'm doing is:


    super("Ross Browser v0.0.0.0.1b");

    PoB = new PanelOfButtons();
    PoB.setBackground(Color.white);

    urlB = new URLDisplayPanel();

    Container container = getContentPane();
    container.add(PoB, BorderLayout.SOUTH);
    container.add(urlB, BorderLayout.CENTER);


    As I said the buttons are fine, the url display is just a blank grey box. I

    Thanks!
    Ross


Comments

  • Registered Users Posts: 2,102 ✭✭✭RossFixxxed


    Err retard alert, once I move (or redraw in any way) the window it shows it fine....

    Nm thanks!
    Ross


Advertisement