Wrox Programmer Forums
|
Java GUI Discussions specific to programming Java GUI.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Java GUI section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old September 11th, 2005, 03:25 PM
Registered User
 
Join Date: Jun 2005
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Default Frames

Can anyone help me please. I'm trying to set up a frame which will have two
buttons and a welcom message. Its the beginnings of a basic client server
login / registration system. For some reason though, one of the buttons I've
added onto the frame seems to expand to the size of the frame itself. The
code is below, any help would be great.

package TMA03Client;

import java.awt.*;
import com.borland.jbcl.layout.*;
import java.io.*;
import java.net.*;
import java.awt.event.*;
import java.util.*;
import java.security.*;
import blowfish.*;

public class Client extends Frame {

   private Frame mainPage = new Frame();
   private Frame registerPage = new Frame();
   private Frame loginPage = new Frame();

   private Label introText = new Label();

   private TextField fullName = new TextField();
   private TextField userAddress = new TextField();
   private TextField userTelephone = new TextField();
   private TextField userLogin = new TextField();
   private TextField userPassword = new TextField();
   private TextField userConfirm = new TextField();
   private TextField userName = new TextField();
   private TextField logPassword = new TextField();

   private Button registerButton = new Button();
   private Button loginButton = new Button();
   private Button sumbitRegister = new Button();
   private Button sumbitLogin = new Button();

   private int totalBuys = 0;

   private Socket s = null;
   private InputStream is = null;
   private OutputStream os = null;
   private PrintWriter pw = null;
   private BufferedReader bf = null;
   private ClientCommandSet cSet = null;
   private ClientResponseSet rSet = null;

   public Client() {
       try {
           jbInit();
           setup();
       } catch (Exception e) {
           e.printStackTrace();
       }
   }

   private void jbInit() throws Exception {
       registerButton.setLabel("Register Details");
       registerButton.addActionListener(new java.awt.event.ActionListener()
{
           public void actionPerformed(ActionEvent e) {
               registerButton_actionPerformed(e);
           }
       });

       loginButton.setLabel("Login");
       loginButton.addActionListener(new java.awt.event.ActionListener() {
           public void actionPerformed(ActionEvent e) {
               loginButton_actionPerformed(e);
           }
       });

       mainPage.g
       introText.setText("Welcome to the OU TMA03 System");
       introText.setSize(100,100);
       introText.setLocation(0,0);
       mainPage.add(registerButton);
       registerButton.setSize(100,100);
       registerButton.setLocation(100,100);
       mainPage.add(loginButton);
       loginButton.setSize(100,100);
       loginButton.setLocation(100,100);
       mainPage.setSize(500,500);
       mainPage.setLocation(100,100);
       mainPage.setVisible(true);
       mainPage.setResizable(true);
       registerPage.setVisible(false);
       loginPage.setVisible(false);
       mainPage.pack();


   }

   public void setup() {
       try {
           s = new Socket("127.0.0.1", 3000);
           is = s.getInputStream();
           os = s.getOutputStream();
           pw = new PrintWriter(os, true);

           bf = new BufferedReader
           (new InputStreamReader(is));
           cSet = new ClientCommandSet(pw);
       } catch (Exception e) {
           System.out.println("Trouble contacting the server " + e);
       }
   }

   void loginButton_actionPerformed(ActionEvent e) {

       if (cSet != null) {
           cSet.loginCommand();
       }
       try {

           pw.close();
           bf.close();
           is.close();
           os.close();
           s.close();
       } catch (Exception ex) {};
       System.exit(0);
   }

   void registerButton_actionPerformed(ActionEvent e) {

       if (cSet != null) {
           cSet.registerCommand();
       }
       try {

           pw.close();
           bf.close();
           is.close();
           os.close();
           s.close();
       } catch (Exception ex) {};
       System.exit(0);
   }

   public static void main(String[] args){

       Client cl = new Client();
   }
}








Similar Threads
Thread Thread Starter Forum Replies Last Post
Frames Simmy73 ASP.NET 2.0 Basics 1 May 26th, 2006 07:26 AM
Frames ricardo_s HTML Code Clinic 1 April 27th, 2006 02:37 PM
FRAMES twinkle Javascript 2 March 30th, 2004 02:04 AM
i frames and all that Adam H-W HTML Code Clinic 2 November 5th, 2003 12:24 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.