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

Java gui question

Options
  • 12-01-2006 3:22pm
    #1
    Registered Users Posts: 3,809 ✭✭✭


    I need to be able to open and display in my gui either text files or html files(ie display it like you see this html page here but in a java gui) but the documentation for it online on how to do it seems piss poor. Any ideas?
    thanx

    This is my only hope all I get online is how to open and display images and how to stream the contents of a file to a jtext area.which is no good to me.


Comments

  • Closed Accounts Posts: 324 ✭✭madramor


    is how to open and display images and how to stream the contents of a file to a jtext area
    thats seems like half your problem solved to me
    I need to be able to open and display in my gui either text files

    heres how to do html stuff, this displays boards.ie
    you can use HyperlinkListener to handle the links but you can find that out for your self.
    its takes a few seconds to load, if boards is down change url in code and recomplie
    import java.awt.BorderLayout;
    import java.awt.event.WindowAdapter;
    import java.awt.event.WindowEvent;
    import java.io.IOException;
    import javax.swing.JEditorPane;
    import javax.swing.JFrame;
    import javax.swing.JScrollPane;
    
    public class Browser extends JFrame{
        
        public static void main(String[] args) {
            JFrame frame = new Browser();
            frame.addWindowListener(new WindowAdapter(){
                public void windowClosing(WindowEvent e){
                    System.exit(0);
                }
            });
        }
        
        public Browser() {
            super("Web Browser - takes a few seconds to load");
            try {
                JEditorPane htmlPane = new JEditorPane("http://www.boards.ie");
                htmlPane.setEditable(false);
                JScrollPane scrollPane = new JScrollPane(htmlPane);
                getContentPane().add(scrollPane, BorderLayout.CENTER);
            }
            catch(IOException ioe) {
                System.out.println(ioe.toString());
            }
            setExtendedState(JFrame.MAXIMIZED_BOTH);
            setVisible(true);
        }
    }
    
    This is my only hope
    you have a great future in software development


  • Closed Accounts Posts: 33 sean_or99




  • Closed Accounts Posts: 17,208 ✭✭✭✭aidan_walsh


    We have a [url=-http://www.boards.ie/vbulletin/showpost.php?p=2763962&postcount=1]policy on homework[/url] questions here. You have to prove you made an effort before asking, meaning post what you have done already when asking the question.


  • Registered Users Posts: 3,809 ✭✭✭CerebralCortex


    I got the text part working and now I am on my way to learning how to do the html part.


Advertisement