Link to home
Start Free TrialLog in
Avatar of jayrod
jayrodFlag for United States of America

asked on

gui clean up

Can anyone tell me how to place my gui components on this win form in some sort of order?


package com.softwareConstruction;

import java.awt.*;
import java.awt.event.*;
import java.applet.Applet;
import java.util.*;

public class AssociateApplet extends Applet
   implements ActionListener {
   
    //Variable declarations
    private Frame win;
    private TextField mapInputText, domainInputText;
    private Label domainContent, mapContent;
    private static final String submitInput = "Submit input";
    private static final String bye  = " Exit ";
    private static final String addDomainValue  = " Add Value to Domain ";    
    private HashSet hashSet = new HashSet();
    private HashMap hashMap = new HashMap();
   
   public void actionPerformed ( ActionEvent e) {
      String cmd = e.getActionCommand();
      if ( cmd.equals( submitInput ) ) {
         
          //Use the associate class to add the object and key to the map
      }
      else if ( cmd.equals( addDomainValue ) ) {
          //Add the value to the domain
         
       }
      else if ( cmd.equals( bye ) ) {
         win.setVisible(false);
      }
   }

   public void init() {

      win = new Frame ( "Associative Application" );
     
      //Define a new TextField to handle the map value input
      this.mapInputText = new TextField("", 20);
      this.domainInputText = new TextField("", 20);
     
      //Add the text Field
      win.add(mapInputText);
      win.add(domainInputText);
     
      //Create a new window
      win.setLayout ( new FlowLayout() );
     
      //Add the submitInput and exit buttons to the window
      addButton ( submitInput ); addButton ( bye ); addButton(addDomainValue);
     
      //Add the label for the domain content
      domainContent = new Label( "Domain Content" );
      domainContent.setFont (new Font ( "Dialog", Font.BOLD, 14 ) );
      domainContent.setBackground ( Color.green );
      domainContent.setAlignment ( Label.CENTER );
     
      //Add the window that will show us what is in the domain
      win.add ( domainContent );
     
     
      //Add the label for the domain content
      mapContent = new Label( "Map Content" );
      mapContent.setFont (new Font ( "Dialog", Font.BOLD, 14 ) );
      mapContent.setBackground ( Color.green );
      mapContent.setAlignment ( Label.CENTER );
     
      //Add the window that will show us what is in the domain
      win.add ( mapContent );
     
     
      win.setSize ( 600, 500 );
   }

   public void start() {
         win.setVisible(true);
   }

   public void stop() {
         win.setVisible(false);
   }

   private void addButton ( String name ) {
      Button b = new Button ( name );
      b.setFont (new Font ( "Helvetica", Font.BOLD, 14 ) );
      b.addActionListener ( this );
      win.add ( b );
   }

   private void display(){
       
       
   }

}

SOLUTION
Avatar of aviadbd
aviadbd

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of pjcrooks2000
pjcrooks2000

Yep Layout managers check them out from the Sun site as aviadbd says :)

pjcrooks2000
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of jayrod

ASKER

I've downloaded the vep and i'm using eclipse 3.0 and I can't get the stinking thing to work for me... Once I have it installed.. how do I know it's working? VEP that is?

You should have a new perspective called VE, and you should have new objects under the "New" window (Where you have "Class", "Interface", "Project" etc, you should have GUI items now).

If you don't have those, you probably didn't install it right.

AviadBD.