import java.awt.*; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import javax.swing.*; import java.io.*; import java.net.*; public class JClient extends JFrame implements ActionListener { public static final String NL = System.getProperty( "line.separator" ); public static final int DEFAULT_PORT = 80; private JTextField host = new JTextField(); private JTextArea input = new JTextArea( 20, 100 ); private JTextArea console = new JTextArea( 20, 100 ); private JButton submit = new JButton( "Submit" ); private JClient() { // Controllers setDefaultCloseOperation( JFrame.EXIT_ON_CLOSE ); submit.addActionListener( this ); // Presentation setTitle( "JClient" ); host.setText( "www.site.uottawa.ca" ); input.setBorder( BorderFactory.createLineBorder( Color.black ) ); input.setFont( new Font( "Monospaced", Font.BOLD, 12 ) ); input.setBackground( Color.white ); console.setEditable( false ); console.setFont( new Font( "Monospaced", Font.BOLD, 12 ) ); console.setBackground( Color.white ); console.setForeground( Color.red ); log( "Info: Enter the HOST name at the top, an HTTP request in the second box, then click submit." ); JPanel center = new JPanel(); center.setLayout( new GridLayout( 2, 1 ) ); center.add( new JScrollPane( input ) ); center.add( new JScrollPane( console ) ); Container content = getContentPane(); content.add( submit, BorderLayout.SOUTH ); content.add( host, BorderLayout.NORTH ); content.add( center, BorderLayout.CENTER ); pack(); } private void log( String msg ) { console.append( msg + NL ); } public void actionPerformed( ActionEvent e ) { if ( e.getSource() == submit ) { submit(); } } public void submit() { } public static void main( String[] args ) { JFrame app = new JClient(); app.setVisible( true ); } }