BrowserGUI(){ url = new JTextField(); cnt = new JEditorPane(); cnt.setContentType( "text/html" ); frame = new JFrame("Browser GUI"); Container c = frame.getContentPane(); c.add( url, BorderLayout.NORTH ); c.add( new JScrollPane( cnt, ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED ), BorderLayout.CENTER ); frame.pack(); frame.setVisible(true); frame.setBounds( 0,0,600,400); frame.addWindowListener( this ); url.addActionListener( this ); }
02602592009/11/10(火) 09:26:52 public void actionPerformed( ActionEvent ea ){ String adrs = url.getText(); try { cnt.setPage( adrs ); } catch ( IOException ei ) { System.out.println(" Document not found" ); } frame.setTitle( adrs ); frame.repaint(); }
//ウィンドウリスナーイベント関数 public void windowActivated( WindowEvent e ){ } public void windowClosed( WindowEvent e ){ } public void windowClosing( WindowEvent e ){ System.exit(0); } public void windowDeactivated( WindowEvent e ){ } public void windowDeiconified( WindowEvent e ){ } public void windowIconified( WindowEvent e ){ } public void windowOpened( WindowEvent e ){ }
public static void main( String args[] ){ new BrowserGUI(); }