TXT

java

By Lloyd Bryant,2014-09-05 21:26
13 views 0
import java.awt.*; import java.awt.event.*; import javax.swing.*; import java.net.*; import javax.swing.event.*; import java.io.*; public class Project extends JFrame implements ActionListener,HyperlinkListener { private JEditorPane jep=new JEditorPane(); private JTextField text=new JTextField(); private JButton button[]=new JButton[5]; ..

import java.awt.*;

    import java.awt.event.*;

import javax.swing.*;

import java.net.*;

    import javax.swing.event.*;

    import java.io.*;

    public class Project extends JFrame implements ActionListener,HyperlinkListener {

     private JEditorPane jep=new JEditorPane();

     private JTextField text=new JTextField();

     private JButton button[]=new JButton[5];

     Project()

     {

     JLabel label=new JLabel("URL");

     JMenu mnuSystem=new JMenu("ÎÄ?þ(F)");

     JMenu mnuHelp=new JMenu("?ïÖú(H)");

     JMenu mnuEdit=new JMenu("?à?-");

     JToolBar tc=new JToolBar();

     JMenuBar tb=new JMenuBar();

     BoxLayout boxLayout=new BoxLayout(tc,BoxLayout.X_AXIS);

     tc.setLayout(boxLayout);

     for(int i=0;i<5;i++)

     {

     button[i]=new JButton();

     button[i].addActionListener(this);

     tc.add(button[i]);

     }

     tc.add(text);

     text.setSize(300,25);

     label.setBackground(Color.red);

     JScrollPane jspViewer=new JScrollPane();

     jspViewer.getViewport().add(jep,null);

     setLayout(null);

     add(tb);

     add(tc);

     tb.add(mnuSystem);

     tb.add(mnuHelp);

     tb.add(mnuEdit);

     tb.setBounds(0,0,800,25);

     tc.setBounds(0,40,800,30);

     add(label);

     add(jspViewer);

     jspViewer.setBounds(0,80,800,640);

     jep.setEditable(false);

     jep.addHyperlinkListener(this);

     text.addActionListener(this);

     setSize(800,700);

     setVisible(true);

     }

     public void actionPerformed(ActionEvent e)

     {

     String string=text.getText();

     if(string.startsWith("http://")){}

     else

     string="http://"+string;

     try

     {

     URL url=new URL(string);

     jep.setPage(url);

     }

     catch(IOException re){System.out.print(re);}

     }

     public void hyperlinkUpdate(HyperlinkEvent e)

     {

     try{jep.setPage(e.getURL());}

     catch(Exception ee){}

     }

     public static void main(String args[]) { new Project();}

    }

Report this document

For any questions or suggestions please email
cust-service@docsford.com