Advertisement
Help Keep Boards Alive. Support us by going ad free today. See here: https://subscriptions.boards.ie/.
If we do not hit our goal we will be forced to close the site.

Current status: https://keepboardsalive.com/

Annual subs are best for most impact. If you are still undecided on going Ad Free - you can also donate using the Paypal Donate option. All contribution helps. Thank you.
https://www.boards.ie/group/1878-subscribers-forum

Private Group for paid up members of Boards.ie. Join the club.

A simple java Class and Swing question

  • 14-10-2004 12:42PM
    #1
    Registered Users, Registered Users 2 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, Registered Users 2 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