Help actionlistener in a seperate class

Hello,
Thank you thus far for yout help. I'm currently having a probelm with calling action listener form a seperate class file:
The codes are as belows:
the main class i call my action listener assaveButton = new Button("SAVE");
     saveButton.setBounds(80,350, BUTTON_WIDTH, BUTTON_HEIGHT);
     detailPanel.add(saveButton);
     saveButton.addActionListener();
and in the other class file in which i put it as a panel i put it as:
import java.awt.*;
import javax.swing.*;
import java.awt.event.*;
import java.sql.*;
public class ActionTPanel extends Panel{
public ActionTPanel(){
cancelButton.addActionListener (
     new ActionListener() {
          public void actionPerformed(ActionEvent e)
               RecordTFrame lala = new RecordTFrame();
               lala.show();
     saveButton.addActionListener(
new ActionListener() {
public void actionPerformed(ActionEvent e) {
                         try{
                         Statement stmt = con.createStatement();
                         if(!tf1.getText().equals ("")){
                         String query =     "INSERT INTO HarvestFile (" +
                                             "TreeID, SegmentCode, DateOfHarvest, NumberOfTrees, NumberRemaining," +
                                                  "Revenue, ForestOfficer, Comments" +
                                                  ") VALUES ('" +
                                                  tf1.getText() + "','" +
                                                  tf.getText() + "','" +
                                                  tf2.getText() + "','" +
                                                  tf3.getText() + "','" +
                                                  tf5.getText() + "','" +
                                                  tf4.getText() + "','" +
                                                  tf6.getText() + "','" +
                                                  tf7.getText() + "')";
                         System.out.print("\nSending query: " +
                                                  con.nativeSQL (query) + "\n");
                         int result = stmt.executeUpdate(query);
                              if(result==1)
                              System.out.print("\nInsertion successful\n");
                              else{
                              System.out.print("\nInsertion failed\n");
                              tf1.setText("");
                              tf.setText("");
                              tf2.setText("");
                              tf3.setText("");
                              tf5.setText("");
                              tf4.setText("");
                              tf6.setText("");
                              tf7.setText("");
                         else
                         System.out.print("\nEnter Tree ID!");
                         stmt.close();
                         catch (SQLException sqlex){
                         sqlex.printStackTrace();
                         System.out.print(sqlex.toString() );
     resetButton.addActionListener (
     new ActionListener() {
          public void actionPerformed(ActionEvent e)
               tf.setText("");      
               tf1.setText("");
               tf2.setText("");
          tf3.setText("");
          tf4.setText("");
          tf5.setText("");
          tf6.setText("");
          tf7.setText("");
     show();
public static void main( String args[] )
          final HAddFrame app = new HAddFrame();
          app.addWindowListener(
               new WindowAdapter() {
                    public void windowClosing( WindowEvent e )
                         System.exit( 0 );
I'm not sure how to call it inthe class
i hope u guys can help me!
Thanks!
-pal-
your help is greatly appreciated!

hello again!
I have another question do i have to reclare the textfields in the separate class file...
Thanks
pal

Similar Messages

  • Programs will not compile that have seperate classes

    I am trying to compile a program which has a seperate class, but it wont compile, it cant find the other class. I am compiling in the correct order, and I have tried re-compiling programs with seperate classes that I have done before, and they now wont compile. I tried compiling my program on my friends computer and it compiled fine.
    I am using jdk5.0 update 6 on Windows XP Pro
    Any help will be much appreciated

    That still doesnt work, it comes up with an extra
    error message now:
    "error reading PhoneEntry.java; error in opening zip
    file"Zip file?
    It sounds like you have some bogus zip file in your classpath.
    Did you try the exact command I posted?
    my two classes are PhoneEntry.java and
    PhoneBook.java
    PhoneEntry needs to be compiled before PhoneBookThat doesn't matter. Javac will take care of that automatically.
    PhoneEntry compiles fine, just when it tries to find
    PhoneBook it appears it cannot find the created
    PhoneEntry.class fileAll I can guess at is that you're doing this: javac -classpath .;something.zip *.java and something.zip either doesn't exist or is corrupt.

  • Help with dynamic creation of class object names

    Hi all
    Wonder if you can help. I have a class player.java. I want to be able to create objects from this class depending on a int counter variable.
    So, for example,
    int counter = 1;
    Player p+counter = new Player ("Sam","Smith");the counter increments by 1 each time the method this sits within is called. The syntax for Player name creation is incorrect. What I am looking to create is Player p1, Player p2, Player p3.... depending on value of i.
    Basically I think this is just a question of syntax, but I can't quite get there.
    Please help if you can.
    Thanks.
    Sam

    here is the method:
    //add member
      public void addMember() {
        String output,firstName,secondName,address1,address2,phoneNumberAsString;
        long phoneNumber;
        boolean isMember=true;
        this.memberCounter++;
        Player temp;
        //create HashMap
        HashMap memberList = new HashMap();
        output="Squash Court Booking System \n";
        output=output+"Enter Details \n\n";
        firstName=askUser("Enter First Name: ");
        secondName=askUser("Enter Second Name: ");
        address1=askUser("Enter Street Name and Number: ");
        address2=askUser("Enter Town: ");
        phoneNumberAsString=askUser("Enter Phone Number: ");
        phoneNumber=Long.parseLong(phoneNumberAsString);
        Player p = new Player(firstName,secondName,address1,address2,phoneNumber,isMember);
        //place member into HashMap
        memberList.put(new Integer(memberCounter),p);
        //JOptionPane.showMessageDialog(null,"Membercounter="+memberCounter,"Test",JOptionPane.INFORMATION_MESSAGE);
        //create iterator
        Iterator members = memberList.values().iterator();
        //create output
        output="";
        while(members.hasNext()) {
          temp = (Player)members.next();
          output=output + temp.getFirstName() + " ";
          output=output + temp.getSecondName() + "\n";
          output=output + temp.getAddress1() + "\n";
          output=output + temp.getAddress2() + "\n";
          output= output + temp.getPhoneNumber() + "\n";
          output= output + temp.getIsMember();
        //display message
        JOptionPane.showMessageDialog(null,output,"Member Listings",JOptionPane.INFORMATION_MESSAGE);
      }//end addMemberOn running this, no matter how many details are input, the HashMap only gives me the first one back....
    Any ideas?
    Sam

  • Event handlers execute code from a seperate class

    i am having difficulties linking my event handlers to another piece of code in a seperate class. basically i want my event handler to execute a code which is in another class. how do i do this?

    while adding listener to the component for which u want to handle event add listener with the name of class where u r going to write the event handling code and declare that class as implementing the type of listener and handle the event in that class by implementing the definitions for the methods in the interface

  • Re: Beginner needs help using a array of class objects, and quick

    Dear Cynthiaw,
    I just read your Beginner needs help using a array of class objects, and quick of Dec 7, 2006 9:25 PM . I really like your nice example.
    I also want to put a question on the forum and display the source code of my classe in a pretty way as you did : with colors, indentation, ... But how ? In html, I assume. How did you generate the html code of your three classes ? By help of your IDE ? NetBeans ? References ?
    I already posted my question with six source code classes ... in text mode --> Awful : See "Polymorphism did you say ?"
    Is there a way to discard and replace a post (with html source code) in the Sun forum ?
    Thanks for your help.
    Chavada

    chavada wrote:
    Dear Cynthiaw,
    I just read your Beginner needs help using a array of class objects, and quick of Dec 7, 2006 9:25 PM . I really like your nice example.You think she's still around almost a year later?
    I also want to put a question on the forum and display the source code of my classe in a pretty way as you did : with colors, indentation, ... But how ?Just use [code] and [/code] around it, or use the CODE button
    [code]
    public class Foo() {
      * This is the bar method
      public void bar() {
        // do stuff
    }[/code]

  • Help on java.sql.Types class

    Hai Friends ,
    I want some help on java.sql.Types class .
    What is the use of the above class ?
    Some details about this class.

    Good Morning Yekesa
    First of all i would like to thank U for looking into my problem.
    I am using java.sql.Types.OTHER for
    {"?=CALL(storedprocedurename.functionname(?))"}
    registerOutParameter(1,javal.sql.Types.OTHER)
    setString(2,"user")
    here the
    second parameter passes an argument to function name ( viz. username say "user")
    and the function will return the ref cursor as follows:
    // declaration in pl/sql procedure
    begin
    rc ref cursor
    open rc for select * from ss_user where login_name="user";
    return rc;
    end
    now the stored procedure has a return value (i.e. stored function) which it needs to register as
    registerOutParameter(1,javal.sql.Types.OTHER)
    and it finally results in the following errors :
    Loading driver
    Before conn stmt
    After conn stmt
    Calling Stored procedure
    Stored procedure called
    java.sql.SQLException: Invalid column type
    at oracle.jdbc.dbaccess.DBError.check_error(DBError.java:243)
    at oracle.jdbc.driver.OracleStatement.get_internal_type(OracleStatement.java:2487)
    at oracle.jdbc.driver.OracleCallableStatement.registerOutParameter(OracleCallableStatement.java:64)
    at oracle.jdbc.driver.OracleCallableStatement.registerOutParameter(OracleCallableStatement.java:54)
    at sptest.<init>(sptest.java:28)
    at sptest.main(sptest.java:49)
    T couldn't understand why it is saying Invalid Column Type because its working fine with both
    java.sql.Types.INTEGER
    and
    java.sql.Types.VARCHAR
    Pl help me at the earliest as i have wasted a lot of time on it.
    pl mail me in detail at [email protected]
    bye then
    bansi
    null

  • 2 seperate class files, need some help

    Hi,
    Um, incase you didn't notice, I'm new to java. The closest to Java that I've ever been was C#. But anyways:
    I have 2 class files. One of them is a main form, and the other one is a simple dialog form. Is there a way that I can make the main form show the dialog form say, by clicking a button? I know how to create a button and do something when the button is clicked, I just don't know how to make one form show another one without having the code for both forms in one file. By the way, I'm making it in Swing if that makes a difference. Also, code examples would help, thanks.

    Hi,
    Um, incase you didn't notice, I'm new to java.The way about every second posts starts in here. Thanks for pointing it out, I wouldn't have guessed. :p
    The
    closest to Java that I've ever been was C#. But
    anyways:
    I have 2 class files. One of them is a main form, and
    the other one is a simple dialog form.
    Is there a way
    that I can make the main form show the dialog form
    say, by clicking a button?Yes, of course.
    I know how to create a
    button and do something when the button is clicked, I
    just don't know how to make one form show another one
    without having the code for both forms in one file.Uhm. Just something similar to
    MyDialog d = new myDialog(theFrameToBeModalTo);
    d.show();?
    What does it have to do with files? Java doesn't care about files.
    By the way, I'm making it in Swing if that makes a
    difference. Also, code examples would help, thanks.All code examples you need are here:
    http://java.sun.com/docs/books/tutorial/

  • Two seperate class files can not resolve (pls help me) THANKS!

    When i compile UseMusic.java i get the following:
    i can't figure it out..
    Thank You for Time!
    D:\java\cENG310\Ass2>javac UseMusic.java
    UseMusic.java:29: cannot resolve symbol
    symbol  : variable middlec
    location: class UseMusic
                       mm.caldis(middlec);  // compute freqs
                                 ^
    UseMusic.java:42: cannot resolve symbol
    symbol  : variable middlec
    location: class UseMusic
             mm.setzero(middlec); // reset middlec to zero
                        ^
    UseMusic.java:56: caldis(java.lang.String[],double[],double) in Music cannot be appli
                      mm.caldis(middlec);  // compute freqs
                        ^
    UseMusic.java:81: checkvaild(java.lang.String[],java.lang.String) in Music cannot be
    a.lang.String)
                boolean cv = mm.checkvaild(strkey);
                               ^
    UseMusic.java:86: getfreq(java.lang.String[],java.lang.String) in Music cannot be app
    ang.String)
                   int index = mm.getfreq(strkey);
                                 ^
    5 errors
    *  Filename    : UseMusic.java
    import iopack.Io;
    import java.text.DecimalFormat;
    * UseMusic this class is
    public class UseMusic {
          public static void main(String[] args) {
             Music mm = new Music();
                   DecimalFormat fmt = new DecimalFormat("0.###"); // round output to 3 decimals places
             boolean newmidc = false;
             boolean notelookup = false;  
             System.out.println("\n\tMusical Scales");
             System.out.println("\t---------------");     // display the title and instructions
             System.out.println("\n\tDefault note values are:");  
                 mm.caldis(middlec);  // compute freqs
             System.out.println("\n\t************************");
             System.out.println("\t* Notes  *  Frequency  *");
             System.out.println("\t************************"); 
             // print old results
             for (int i = 0; i < mm.noteName.length; i ++) {
                        // display values onto screen
                System.out.println("\t* " + mm.noteName[i] + "\n");
                System.out.println("      " + mm.noteFreq[i] + " Hz *\n");     
             mm.setzero(middlec); // reset middlec to zero
             // prompt user for value of midddle c
             while (!newmidc) {
                   //read value new value for middle c
                   double middlec = Io.readDouble("\n\tEnter value for Middle C [Between 250 - 265] (Hz)");
                   // vaildate value for middlec
                   // vaild if valeu for middle is between 250-265
                   if ((middlec > 250) && (middlec < 265)) {
                      System.out.println("\n\tNew note values");
                      System.out.println("\n\t----------------\n");
                      mm.caldis(middlec);  // compute freqs
                      System.out.println("\n\t************************");
                      System.out.println("\t* Notes  *  Frequency  *");
                      System.out.println("\t************************"); 
                      // print old results
                      for (int i = 0; i < mm.noteName.length; i ++) {
                            // display values onto screen
                            System.out.println("\t* " + mm.noteName[i] + "\n");
                            System.out.println("      " + mm.noteFreq[i] + " Hz *\n");     
                      break;   // get out of while
                   else {
                         System.out.println("\nError Invaild Input!\nValue must be between 250 Hz to 265 Hz.");         
                   } //end of else
             } // end of while for newmidc
             // prompt user for note
             while (!notelookup) {
                //read value new value for
                String strkey = Io.readString("\n\tEnter note value");
                boolean cv = mm.checkvaild(strkey);
                // vaildate value for middlec
                // vaild if valeu for middle is between 250-265
                if (cv == true) {
                   int index = mm.getfreq(strkey);
                   System.out.println("\nNote " + mm.getnoteName(index) + "has frequency of" + mm.getnoteFreq(index) + " Hz");
                   break;   // get out of while
                else {
                   System.out.println("Invaild note!, please try again.");          
                } //end of else
             } //end of while    
          }// end of static main
    } // end of Class UseMusic
    *  Filename    : Music.java
    import java.*;
    public class Music
       static int MAXSIZE = 12;                  // max # of elements (13 elements)
       static double INITALMIDDLEC = 256;     // set default value of middle c to 256
       double middlec;          // user value for middlec
       String[] noteName;   // array stores name of notes
       double[] noteFreq;     // array stores freq of notes
      boolean vaildstr;     // track whether entered string is vaild
       char replay;               // user's reponse to continue prompt
       boolean uContinue;     // whether or not to continue
       int sub;                         // index of searched string
       // Default Constructor
       Music () {
          String[] noteName = {"C","C#","D","D#","E","F","F#","G","G#","A","A#","B","C'"};
          double[] noteFreq = new double[noteName.length];
          middlec = INITALMIDDLEC; // default value of middlec to 256
              vaildstr = false;        // signify whether user entered value
          sub = 0;
       void caldis(String[] noteName, double[] noteFreq, double middlec) {
          // calculate the values based upon middlec
          double temp = 0; // dummy used to store value
          double semitone = (double)Math.pow(2,(1/12));
          temp = middlec;   //set the value of the first element to middlec   
          // fill noteFreq with values wrt middlec
          // no magic #s - noteName since noteFreq has # of elements
          for (int i = 0; i < noteName.length; i++) {
             temp = noteFreq[i-1]; // save value of previous elements 
             noteFreq[i] = temp + (temp * semitone);
          } //end of for
       double getmiddlec(double middlec) {
          return middlec;   // Returns the value of middlec
       int getfreq(String[] noteName, String strkey) {     
          for (int i = 0 ; i < noteName.length ; i++) {        
             if (strkey.compareTo(noteName) == 0) {           
    sub = i;
    return sub;
         double setzero(double middlec) {
              middlec = 0;
              return middlec;
    String getnoteName(int index) {
    return noteName[index];
    double getnoteFreq(int index) {
    return noteFreq[index];
    boolean checkvaild(String[] noteName, String strkey) {
    vaildstr = noteName.equals(strkey);
    return vaildstr;
    } //end of Class Music

    >
    What part can't you figure out? The compiler is
    telling you that it can't resolve "middlec", which it
    can't, because you apparently didn't define it
    anywhere. Actually he did define it, but he defined it after he passed it to those methods. If that's not simply an oversight on his part, I can't begin to understand what he was thinking.

  • HELP- Can't Import My Classes

    I've just recently gotten into Java development and have been able to make very basic programs?if you could call them that. To basically introduce myself to Java programming, I thought I'd create a simple tab-based text editor (think Microsoft Notepad with the ability to edit multiple files at once). I've created a basic menu bar class file, a tab-based editor pane/window class file, but am having trouble with the class file I'm using to incorporate the two together. I've had Steven Haines' Java 2 from Scratch at-hand for a week or two now (up to date, no; useful to a degree, yes) and have designed the application with a structure similar to the app in the book.
    The structure of the main class file:
    import java.lang.*;
    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.*;
    import javax.swing.event.*;
    import menuBar;
    import jPad;
    public class jNotepad extends JFrame implements ActionListener
    menuBar menu=new menuBar();
    jPad jNote=new jPad();
    public jNotepad()
    super("JNotepad v1.0");
    setJMenuBar(menu);
    menu.addActionListener(this);
    jNote=new jPad();
    getContentPane().add(jNote,BorderLayout.CENTER);
    setSize(600,300);
    setVisible(true);
    addWindowListener
    new WindowAdapter()
    public void windowClosing(WindowEvent closer)
    System.exit(0);
    public void actionPerformed(ActionEvent performed)
    JMenuItem item=(JMenuItem)performed.getSource();
    if(item==menu.fNew)
    System.out.println("File->New");
    else if(item==menu.fOpen)
    System.out.println("File->Open...");
    else if(item==menu.fClose)
    System.out.println("File->Close");
    else if(item==menu.fCloseAll)
    System.out.println("File->Close All");
    else if(item==menu.fSave)
    System.out.println("File->Save");
    else if(item==menu.fSaveAs)
    System.out.println("File->Save As...");
    else if(item==menu.fSaveAll)
    System.out.println("File->Save All");
    else if(item==menu.fPrint)
    System.out.println("File->Print");
    else if(item==menu.fExit)
    System.out.println("File->Exit");
    else if(item==menu.eCut)
    System.out.println("Edit->Cut");
    else if(item==menu.eCopy)
    System.out.println("Edit->Copy");
    else if(item==menu.ePaste)
    System.out.println("Edit->Paste");
    else if(item==menu.eDelete)
    System.out.println("Edit->Delete");
    else if(item==menu.hContents)
    System.out.println("Help->Contents");
    else if(item==menu.hAbout)
    System.out.println("Help->About");
    public static void main(String[] args)
    jNotepad jNotepadv10=new jNotepad();
    For some reason or another, whenever I try to compile the java file into a class file, it gives me an error stating that I need periods after the "import menuBar" and "import jPad." Then if I add the periods and recompile, it says I need identifiers after the periods, so I add asterisk identifier masks and recompile again just to be told the packages menuBar and jPad do not exist. I can't go any further with my program until I resolve this issue. Any assistance would be appreciated.

    use package For example pjb is my initals. I like to have top package of all my programs.
    At the top of the java file of NotePad.java, should be
    package pjb.apps.NotePad;Make sure that java file and compiled class file is in that directory
    \pjb\apps\NotePad.java
    \pjb\apps\NotePad.class
    \pjb\apps\Calculator.class
    Ok Now with your imports do the following. A made up JOS program requires apps to use.
    \pjb\os\jos.java
    \pjb\os\jos.class
    In the jos.java i have
    import pjb.apps.*;
    ...jos coding
    public void showAppCalculator() {
      Calculator josCalculator = new Calculator();
      josCalculator.show();
    ...jos codingAnother example is I just want NotePad imported
    import pjb.apps.NotePad;
    ...jos coding
    public void showAppNotePad() {
      NotePadjosNotePad = new NotePad();
      josCalculator.show();
    ...jos codingor make sure the the classes are all in the same directory as your application program.
    See http://java.sun.com/docs/books/tutorial/java/interpack/index.html
    for more details about packages.
    Hope it helps :)

  • Help with GUI (calling one class from other class)

    Hi everybody,
    I am new at GUI and I need your help..
    I have a JPanel, named "holdAll", layout of which is set to BorderLayout. I have implemented all other JPanels in different class files. For example, I have TopPanel, LeftPanel, etc. as shown below
    LeftPanel myLeft = new LeftPanel();
    holdAll.add(myLeft, BorderLayout.WEST);
    RightPanel myRight = new RightPanel();
    holdAll.add(myRight, BorderLayout.EAST);
    TopPanel myTop = new TopPanel();
    holdAll.add(myTop, BorderLayout.NORTH);
    MiddlePanel myMiddle = new MiddlePanel();
    holdAll.add(myMiddle, BorderLayout.CENTER);
    BottomPanel myBottom = new BottomPanel();
    holdAll.add(myBottom, BorderLayout.SOUTH);
    That works well but I have difficulties in ActionListeners.. For example, in my TopPanel class I have the code below:
    public void actionPerformed(ActionEvent e) {
    if (e.getSource() == btnInsert) {
    int returnVal = fc.showOpenDialog(fc);
    if (returnVal == JFileChooser.APPROVE_OPTION) {
    File file = fc.getSelectedFile();
    myImage newImage = new myImage(file);
    System.out.println(newImage.myHashCode());
    Here, if I have upload new image, then I have to update the listImage in the LeftPanel class.. But, I could not access the lstImage object in the LeftPanel class from the actionListener event in the TopPanel class.
    What should I do? Is my design poor?

    public class TopPanel extends JPanel implements ActionListener { //it doesn't allow "extends JPanel, Observable"
    JFileChooser fc;
    JButton btnInsert;
    JButton btnDelete;
    public TopPanel() {
    setLayout(new FlowLayout());
    setBorder(BorderFactory.createBevelBorder(1, Color.WHITE, Color.GRAY));
    btnInsert = new JButton("Insert");
    btnDelete = new JButton("Delete");
    JLabel myLabel = new JLabel(" Search : ");
    JTextField txtSearch = new JTextField();
    txtSearch.setColumns(20);
    JToolBar searchToolBar = new JToolBar();
    fc = new JFileChooser();
    btnInsert.addActionListener(this);
    searchToolBar.add(btnInsert);
    searchToolBar.add(btnDelete);
    searchToolBar.add(myLabel);
    searchToolBar.add(txtSearch);
    add(searchToolBar);
    public void actionPerformed(ActionEvent e) {
    if (e.getSource() == btnInsert) {
    int returnVal = fc.showOpenDialog(fc);
    if (returnVal == JFileChooser.APPROVE_OPTION) {
    File file = fc.getSelectedFile();
    *//Here I want to send fc.GetName() to the JList in the LeftPanel*
    my LeftPanel class is below:
    public class LeftPanel extends JPanel{
    public LeftPanel(){
    this.setLayout(new BorderLayout());
    setBorder(BorderFactory.createBevelBorder(1, Color.WHITE, Color.GRAY));
    JPanel pnlButtons = new JPanel();
    JButton btnName = new JButton("Name");
    JButton btnSize = new JButton("Size");
    JButton btnDate = new JButton("Date");
    pnlButtons.add(btnName);
    pnlButtons.add(btnSize);
    pnlButtons.add(btnDate);
    pnlButtons.setBorder(BorderFactory.createLineBorder(Color.BLACK));
    JPanel pnlImage = new JPanel();
    JList lstImage = new JList();
    lstImage.setVisible(true);
    pnlImage.add(new JScrollPane(lstImage));
    add(pnlButtons, BorderLayout.NORTH);
    add(pnlImage, BorderLayout.CENTER);
    Is there any simple way?

  • Include jsp versus seperate class/bean versus taglib

    Hi friends,
    I am working on Servlet/JSP project. There are large no. of jsp pages. A common set of methods get repeated in all the jsp pages. Now my concen is to separate out the methods in a file and then use it in jsp page.
    Kindly suggest me the right path to follow, taking into consideration that we take up the optimized solution and performance-wise also feasible.
    Whether I should go for
    1. Using 'include jsp'
    2. using 'taglib'
    3. creating a seperate utility class with the required methods and 'import' it in the JSP pages.
    Kindly reply ASAP.
    Thanks in advance.
    Regards.

    I would suggest you should go for user defined tags.
    This would ensure that the business functionality is isolated from your web objects and it would be modular to maintain.
    Using simple classes will add java code to your JSP pages, which makes them less readable.
    Apart from that implicit object creation by the Servlet/JSP engine(which are instantiating and garbage collecting the taglib objects) will be more efficient.
    Hope this helps
    regards
    Ravi

  • Help me with my different classes for Dialog/Listener problem

    Class TodSource
    //bunch of code
    bEdit.addActionListener(new EditUrl(this));
    //more code
    OTHER classes
    import java.awt.*;
    import java.awt.event.*;
    import java.net.*;
    import java.io.*;
    import java.applet.Applet;
    public class EditUrl implements ActionListener{
         Frame OriginalOwner;
         EditUrl(Frame TodSourceFrame){
         OriginalOwner = TodSourceFrame;     
         actionPerformed(ActionEvent e) {
         new EditDialog(OriginalOwner, "Enter URL");
    public class EditDialog extends Dialog{
         EditDialog(Frame OriginalOwner, String title) {
         super(OriginalOwner, title, true);
         addWindowListener(new CloseCross());
         setLayout(new FlowLayout());
    setSize(250, 150);
         setResizable(false);
         show();
    class CloseCross extends WindowAdapter {
         public void windowClosing(WindowEvent event){
              dispose();
    when i compile i get this error
    C:\Documents and Settings\Administrator\Desktop\Java Ref>javac TodSource.java
    .\EditUrl.java:18: invalid method declaration; return type required
    actionPerformed(ActionEvent e) {
    ^
    .\EditUrl.java:28: class EditDialog is public, should be declared in a file name
    d EditDialog.java
    public class EditDialog extends Dialog{
    ^
    .\EditUrl.java:8: EditUrl should be declared abstract; it does not define action
    Performed(java.awt.event.ActionEvent) in EditUrl
    public class EditUrl implements ActionListener{
    ^
    .\EditUrl.java:54: cannot resolve symbol
    symbol : method dispose ()
    location: class CloseCross
    dispose();
    ^
    4 errors
    hm, anyone can understand the problem

    hi again,
    sorry it takes such a long time
    1. dispose() is a method normally used by frames, windows and so on
    this method just only kills the frame, give the memory this frame used back to the system and makes the frame undisplayable.
    So since i do not know what you want to dispose i cannot help you
    2. actionperformed()
    It works the following way:
    every class implementing the interface ActionListener has to implement the method actionPerformed(ActionEvent e)
    if you start the program you have to add this actionlistener to a graphiccomponent which can trigger an action(like buttons)
    here a short example
    import java.awt.*;
    import java.awt.event.*;
    public class Example extends Frame implements ActionListener {
    public Example(){
       Button b = new Button("I am a button");
       b.addActionListener(this); // this will add our actionListener to this button
       b.setActionCommand("DoAnything"); // we need it, if we define more buttons, which uses the same listener
       add(b); // adding the button to our frame
    public void actionPerformed(ActionEvent e){
    if(e.getActionCommand().equals("DoAnything"))
        // insert here what you want to do
    test it out                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      

  • I need some help to develop the action class.

    my total concept is , browse a file and upload then after i want save that file in some folder in my system with same formatte (if u browse a 1.txt file then i want to save that file same c: temp/1.txt same formate )how can i do that? i know i have to develop the code in action class but what kind of code i have to develop.
    i suceed to upload the file but i dont have the idea to save that file in my system. but i dont know how can i save my file in the c:temp folder.?
    please help me.

    The authentication is something you can do with either https (secure the transport) or with WS-Security (Secure the message). You can add that with JDeveloper by using the context menu on a webservice.
    To create a webservice:
    - specify the xsd
    - create the wsdl
    - Generate a Java webservice using JDeveloper
    - implement the class to return the content of the request.
    Regards,
    Lonneke

  • Need help calling and looping custom classes

    Hi, I am writing a code with custom classes in it and another program that calls upon all of the classes in the first program. I can get the second one (L6) to call upon and execute all of the classes of the first (Foreign). However, I need the second one to loop until quit is selected from the menu on Foreign and I can't seem to figure out how to do it. Here are the codes:
    L6:
    public class lab6
    public static void main(String[] args)
    Foreign camount = new Foreign();
    camount = new Foreign();
    camount.get();
    camount.print();
    camount.intake();
    camount.convert();
    camount.vertprint();
    System.out.println(camount);
    Foreign:
    import java.util.Scanner;
    public class Foreign
    private String country;
    private int choice;
    private float dollars;
    private float conversionValue;
    private float conversionAmount;
    public Foreign()
    country = "null";
    choice = 0;
    dollars = 0;
    conversionValue = 0;
    conversionAmount = 0;
    public void get()
         Scanner Keyboard = new Scanner(System.in);
              System.out.println("Foreign Exchange\n\n");
    System.out.println("1 = U.S. to Canada");
    System.out.println("2 = U.S. to Mexico");
    System.out.println("3 = U.S. to Japan");
    System.out.println("4 = U.S. to Euro");
    System.out.println("0 = Quit");
    System.out.print("\nEnter your choice: ");
    choice = Keyboard.nextInt();
    public void print()
    System.out.print("\nYou chose " + choice);
    public void intake()
         Scanner Keyboard = new Scanner(System.in);
              if (choice >= 1 && choice <= 4)
    switch (choice)
              case 1: System.out.println("\nU.S. to Canada");
                        conversionValue = 1.1225f;
                        country = ("Canadian Dollars");
                        break;
              case 2: System.out.println("\nU.S. to Mexico");
                        conversionValue = 10.9685f;
                        country = ("Mexican Pesos");
    break;
              case 3: System.out.println("\nU.S. to Japan");
                        conversionValue = 118.47f;
                        country = ("Japanese Yen");
    break;
              case 4: System.out.println("\nU.S. to Euro");
                        conversionValue = 0.736377f;
                        country = ("European Union Euros");
    break;
                   System.out.print("\nEnter U.S. dollar amount: ");
              dollars = Keyboard.nextFloat();
    public void convert()
    conversionAmount = conversionValue * dollars;
    public void vertprint()
    System.out.println("\nCountry = " + country);
    System.out.println("Rate = " + conversionValue);
    System.out.println("Dollars = " + dollars);
    System.out.println("Value = " + conversionAmount);
    public String toString()
    String line;
    line = "\n" + country + " " + conversionValue + " " + dollars + " " + conversionAmount;
    return line;
    I appreciate any help anyone can give me. This is driving me crazy. Thanks.

    1. first you need to write method to get choice value from Foreign class.
    simply add this method.
       public class Foreign {
          // ... Add this
          public int getChoice() {
             return choice;
       }2. Then in your main, you can obtain with previos method.
    public static void main(String[] args) {
       Foreign camount = new Foreign();
       // remove this. you alredy create an instance in last statement.
       //camount = new Foreign();
       int choice = 0;
       do {
          camount.get();
          choice = camount.getChoice();
          // your process...
       } while (choice != 0);
    }

  • Calling a method from an abstract class in a seperate class

    I am trying to call the getID() method from the Chat class in the getIDs() method in the Outputter class. I would usually instantiate with a normal class but I know you cant instantiate the method when using abstract classes. I've been going over and over my theory and have just become more confused??
    Package Chatroom
    public abstract class Chat
       private String id;
       public String getID()
          return id;
       protected void setId(String s)
          id = s;
       public abstract void sendMessageToUser(String msg);
    Package Chatroom
    public class Outputter
    public String[] getIDs()
         // This is where I get confused. I know you can't instantiate the object like:
            Chat users=new Chat();
            users.getID();
    I have the two classes in the package and you need to that to be able to use a class' methods in another class.
    Please help me :(                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               

    I have just looked over my program and realised my class names are not the most discriptive, so I have renamed them to give you a clearer picture.
    package Chatroom
    public abstract class Chatter
    private String id;
    public String getID()
    return id;
    protected void setId(String s)
    id = s;
    I am trying to slowly build a chatroom on my own. The Chatter class is a class that will be used to represent a single logged in user and the user is given an ID when he logs in through the setId and getID() methods.
    package Chatroom;
    import java.util.Vector;
    public class Broadcaster
    private Vector<Chatter> chatters = new Vector<Chatter>();
    public String[] getIDs()
    // code here
    The Broadcaster class will keep a list of all logged-in users keeps a list of all the chats representing logged-in users, which it stores in a Vector.I am trying to use the getIDs() method to return an array of Strings comprising the IDs of all logged-in users, which is why im trying to use the getID() method from the Chat class.
    I apologise if I come across as clueless, it's just I have been going through books for about 4 hours now and I have just totally lossed all my bearings

Maybe you are looking for

  • RV082 Unable to see or change settings in web interface

    I have just purchased an RV082. I am using a Mac with Safari and Firefox to access the web interface through http://192.168.1.1 I was able to log in to the web interface using admin/admin, but the system summary page is blank. The category choices we

  • Error related to namespace mismatch in BPEL

    Hi All We are facing an error related to NameSpace of a variable in BPEL process. We are sending a SOAP XML request to a third-party web service and fetching the XML response in a variable. There is a mismatch in the namespace of the variables. The x

  • Known problem with Disk Utility formatting Windows NT drive ?

    I have had a strange problem while formatting a newly purchased Iomega USB (Seagate) with version 11.1 (252.4) of Disk Utility (OS 10.5.8). The drive was NTSF and I wanted Mac OS extended. The first attempt failed, unfortunately I didn't note the exa

  • Apache start fails on Content server

    Hi , I have installed Content server 6.40 on AIX 5.3 with Apache server 2.2.4 However after successful installation of MaxDB instance and Content Server the apache fails to restart or stop and gives the below message: ./apachectl -k start httpd: Synt

  • ViewLink Accessor returning null when VO has a BindParameter

    I have DeptView and EmpView that is link with a DempEmpViewLink. the link is two way so DeptView has a RowIterator Viewlink accessor and EmpView has a Row ViewLInk accessor. However inside the employeViewRow code, I always get a Null value when I acc