New Posts  All Forums:Forum Nav:

Creating Auxiliary Classes/

post #1 of 2
Thread Starter 
Hey I've been asked to create auxiliary classes in one of my java programs but I didn't understand the lecture much on it. Could someone please help clear this up for me?

This is the base code:

Code:

import java.awt.*;
 import javax.swing.*;
 import java.awt.event.*;
 
 public class LogicA extends JFrame
                   implements ActionListener
 {

JLabel numOneLabel = new JLabel("Enter your first number:  ");
JTextField numOneTxt = new JTextField(3);
JLabel numTwoLabel = new JLabel("Enter your second number:  ");
JTextField numTwoTxt = new JTextField(3);
JTextArea commentTxt = new JTextArea (2,20);
JButton sumBtn = new JButton("ADD");

     public static void main(String[] args)
     {
         LogicA jf = new LogicA();
     }
     
     public LogicA()
     {
         setLayout(new FlowLayout());
         setSize(600, 200);
         setTitle("Adding");
         setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
add(numOneLabel);
add(numOneTxt);
add(numTwoLabel);
add(numTwoTxt);
add(sumBtn);
add(commentTxt);
sumBtn.addActionListener(this);
        setVisible(true);
     }
 
     public void actionPerformed(ActionEvent e)
     {
        int numOne = Integer.parseInt(numOneTxt.getText());
int numTwo = Integer.parseInt(numTwoTxt.getText());
int sum = numOne+numTwo;
String numTxt = Integer.toString(sum);
String message = "The sum of your two numbers is \
 " + numTxt;
commentTxt.setText(message);
     }
 }
What I've basically been asked to do is remove all the calculations and create a separate class just for that. I understand the idea but not how to actually execute it... I get that I probably want to remove the stuff inside of the action performed class. And I've created another java file. I'm just really confused here. I've done it before but on a much simpler file... Could someone just point me towards what I actually have to do? Thanks
Edited by kidshenlong - 3/5/11 at 12:11pm
Dark Star
(13 items)
 
  
CPUMotherboardGraphicsRAM
Q6600 - Currently Overclocking ;) Gigabyte GA-EP45-UD3P HD 6950 OCZ Blade LC DDR2 PC29200 4GB (GOT) 
Hard DriveOSMonitorKeyboard
640GB for Storage and OCZ Vertex 2e 60GB Windows 7 Ultimate-Signature Edition 3 x 22" -BenQ G2222HDL Logitech G15 
PowerCaseMouse
Corsair TX850 HAF 932 Logitech G500 
  hide details  
Reply
Dark Star
(13 items)
 
  
CPUMotherboardGraphicsRAM
Q6600 - Currently Overclocking ;) Gigabyte GA-EP45-UD3P HD 6950 OCZ Blade LC DDR2 PC29200 4GB (GOT) 
Hard DriveOSMonitorKeyboard
640GB for Storage and OCZ Vertex 2e 60GB Windows 7 Ultimate-Signature Edition 3 x 22" -BenQ G2222HDL Logitech G15 
PowerCaseMouse
Corsair TX850 HAF 932 Logitech G500 
  hide details  
Reply
post #2 of 2
CODE tags, pretty please.
New Posts  All Forums:Forum Nav:
  Return Home
  Back to Forum: Application Programming