Need help for java program

Hi,
I need help with my web application. When i tried to run it using
localhost:8080
it's giving me error that
signup.do file is not available.
can someone tell me what could be wrong with my code?
I want to know what is .do file and what needs to do to have remove the error
I have also used struts config file.
Please help me.
Message was edited by:
star4588

See struts documentation here http://struts.apache.org/1.2.9/userGuide/building_controller.html#action_mapping_example
you should have something like that :
<action-mappings>
        <action
            path="/signup"
            type="org.apache.struts.webapp.example.SignupAction"
            name="signupForm"
            scope="request"
            input="/signup.jsp"
            unknown="false"
            validate="true" />
    </action-mappings>in your struts-config.xml.
Hope That Helps

Similar Messages

  • Need help for Java Programming asap plzzzzzzzzzzzzz

    Here is the work: (Im writing it coz I wasn't able to attach it)
    Introduction
    In geometry, a straight line is the shortest distance between two points.
    A line may be characterised by its end points and its length.
    A line connects the points P1 and P2.
    The point P1 has coordinates {X1,Y1}.
    The point P2 has coordinates {X2,Y2}.
    The length of the line joining P1 and P2 is given by the equation:
    { (X2 - X1)2 + (Y2 - Y1)2 }1/2
    Those of you who are familiar with geometry will recognise the equation as being the well known Pythagoras equation for the hypotenuse of right angled triangles.
    Requirements
    Develop a class specification for the class Point.
    Write a short test program and test plan for this class.
    For example:
    //pointTest.java
    main(...)
    Point P1;
    P1.create(24,16); // create a point with coordinates {24,16}
    P1.display(); // display the {X,Y} coordinates of P1
    Develop a class specification for the class Line.
    Write a short test program and test plan for this class.
    For example:
    //lineTest.java
    main(...)
    Point P1 = new Point();
    P1.create(24,16); // create a point with coordinates {24,16}
    Point P2 = new Point();
    P2.create(33,42); // create a point with coordinates {33,42}
    Line L1 = new Line();
    L1.create(P1,P2); // create a line using points P1 and P2
    System.out.println( L1.length() ); // display the length of line L1
    Line L2 = new Line();
    L2.create(12,30,28,16); // create a line using coordinates {12,30}, {28,16}
    L2.display(); // display the coordinates of both points and the length of the line
    Application
    We wish to determine the length of the boundary of any regular or irregular polygon .
    The polygon may have up to 6 sides.
    The user should be prompted to enter the number of sides and the coordinates of each vertex point.
    The program should then calculate and display the total length of the boundary.
    You should write an application to implement this using your Point and Line classes.
    What I should have at the end
    The following:
    ? A listing of the files Point.java, the class test program and results.
    ? A listing of the files Line.java, the class test program and results.
    ? The application program and results.
    Note 1: All code must be written in java.

    Point P1 = new Point();
    P1.create(24,16); // create a point with coordinates {24,16}That's a terrible idea. If that was actually in your requirements, then whoever wrote it should stop teaching Java right now.
    We have constructors to initialize objects with sensible, meaningful values. Creating a new Point object without any values and then calling a "create()" method to set the values is a pretty stupid approach. Not only does it ignore the usefulness of a constructor, it also ignores the convention that methods called "create" should actually create something (and not just set values).

  • Need help with Java programming installation question

    Sorry for my lack of knowledge about Java programming, but:....
    A while back I thought I had updated my Java Runtime Environment programming. But I now apparently have two programs installed, perhaps through my not handling the installation properly. Those are:
    J2SE Runtime Environment 5.0 update 5.0 (a 118MB file)
    and:
    Java 2 Runtime Environment, SE v 1.4.2_05 (a 108MB file)
    Do I need both of these installed? If not, which should I uninstall?
    Or, should I just leave it alone, and not worry about it?
    Yeah, I don't have much in the way of technical knowledge...
    Any help or advice would be appreciated. Thank you.
    Bob VanHorst

    Thanks for the feedback. I think I'll do just that. Once in a while I have a problem with Java not bringing up a webcam shot, but when that happens, it seems to be more website based than a general condition.

  • Need help in java program execution...

    Hi all
    I have made a java program( JAR file) and I need to execute it from a double click...can you please tell how to do it..For normal execution i have to go to CMD prompt and write a couple of commands but i want to execute it through 1 click..
    The method which i thought was to make a batch(.bat) file and write the commands in it but its not working properly...do you have any other method or software which i can use...
    I am new to java and any help would be appreciated.

    You should avoid using a batch file since there's no explicit reason to do that.
    sachinmittal wrote:
    I have made a java program( JAR file) and I need to execute it from a double click...can you please tell how to do it.There a lot of tutorials out there. I prefer this one:
    [http://java.sun.com/docs/books/tutorial/deployment/jar/index.html]
    You should take look at the manifest section if you want to build an executable jar.

  • I need Help for that program

    i do aprogram for sample calculator by Java there it , i Hope if u have any sugesst say to me Or if u have a program for that.
    import java.applet.*;
    import java.awt.*;
    import java.awt.event.*;
    public class Z extends Applet implements ActionListener {
         int n4=0;
         StringBuffer E;
         Character x;
         String s;
         TextField T1;
         public void init(){
              T1=new TextField(20);
              this.add(T1);
         Button a=new Button("2");
         this.add(a);
         a.setActionCommand("2");
         a.addActionListener(this);
         Button b=new Button("3");
         b.setActionCommand("3");
         this.add(b);
         b.addActionListener(this);
         Button d=new Button("-");
         this.add(d);
         d.setActionCommand("-");
         d.addActionListener(this);
              Button f=new Button("+");
         this.add(f);
         f.setActionCommand("+");
         f.addActionListener(this);
    Button c=new Button("=");
         this.add(c);
    c.setActionCommand("+");
    c.addActionListener(this);}
    public void actionPerformed(ActionEvent y){
         s=(y.getActionCommand());
         E=new StringBuffer();
                   x= new Character (s.charAt(0));
         E.append(x.charValue());
              if(E.length() ==3){
                   Character n=new Character(E.charAt(0));
                        Character m=new Character(E.charAt(2));
                   int n1=Integer.parseInt(n.toString());
                   int n2=Integer.parseInt(m.toString());
              if(E.charAt(1)=='+'){
                   n4=n1+n2;}
                   if(E.charAt(1)=='-'){
                   n4=n1-n2;}
                   if(E.charAt(1)=='*'){
                   n4=n1*n2;}
                   if(E.charAt(1)=='/'){
                   n4=n1/n2;}
                   if(s=="="){
                   T1.setText(String.valueOf(n4));
         

    the program is used for do acalculature, i want to know ,why he donot work? .The idea of that program it
    When u click in any number(button) the action performed get that number , and store it in StringBuffer which that stringbuffer enabel me to store three things(the first number, the sign which be *or+, and the secand number)
    and then put the result in variable and then put the result as aString in Text Field.
    I hope u can understand me now and help me for that program, If u donot understand me ,Please Sugesst to me how to do the calculature program.thanks
    import java.applet.*;
    import java.awt.*;
    import java.awt.event.*;
    public class Z extends Applet implements ActionListener {
         int n4=0;
         StringBuffer E;
         Character x;
         String s;
         TextField T1;
         public void init(){
              T1=new TextField(20);
              this.add(T1);
         Button a=new Button("2");
         this.add(a);
         a.setActionCommand("2");
         a.addActionListener(this);
         Button b=new Button("3");
         b.setActionCommand("3");
         this.add(b);
         b.addActionListener(this);
         Button d=new Button("-");
         this.add(d);
         d.setActionCommand("-");
         d.addActionListener(this);
              Button f=new Button("+");
         this.add(f);
         f.addActionListener(this);
    Button c=new Button("=");
         this.add(c);
         c.setActionCommand("=");
    c.addActionListener(this);
    public void actionPerformed(ActionEvent y){
         s=(y.getActionCommand());
         E=new StringBuffer();
                   x= new Character (s.charAt(0));
         E.append(x.charValue());
              if(E.length() ==3){
                   Character n=new Character(E.charAt(0));
                        Character m=new Character(E.charAt(2));
                   int n1=Integer.parseInt(n.toString());
                   int n2=Integer.parseInt(m.toString());
              if(E.charAt(1)=='+'){
                   n4=n1+n2;}
                   if(E.charAt(1)=='-'){
                   n4=n1-n2;}
                   if(E.charAt(1)=='*'){
                   n4=n1*n2;}
                   if(E.charAt(1)=='/'){
                   n4=n1/n2;}
                   if(s=="="){
                   T1.setText(String.valueOf(n4));
         

  • Need help with Java program from Yahoo

    Please excuse this novice question but I'm trying to launch "Market Tracker on Yahoo and am having problems. Yahoo says it's because I have multiple versions of Sun JVM running on my system and instructed me to do an uninstall of Jave which I did then restarted my computer. I was instructed to sign into Yahoo Finance and launch Market Tracker which detected that I needed the latest version of Sun JVM and automaticall installed it on my machine. Same problems exists. I uninstalled Java again an then did a search and found an SDK Java 40 application still on my computer. Could this be the problem? Can I remove this and what is it? Can anyone email me an answer at Bulrush2001 @ yahoo.com. Thanks in advance.

    Alas,most likely nobody here in this forum will have an answre for you.
    We're all about Sun Java Enterprise Messaging Server.
    not about JAVA, java programming, or JVM

  • Need help for Java Certification

    Hello friends,
    I am preparing for SCJP 1.4. Those who have passed this exam pl help in prepration. Which books I should follow and some usefull sites which can help in preparing for the exam.
    I will appreciate any kind of help.
    Thanks,
    Regards,
    Nitin Goyal

    Hello friends,
    I am preparing for SCJP 1.4. Java certification, what do you need it for?I hear it's a new requirement to become a cab driver in Jakarta.

  • Need help connecting java-program to Clarion-software/database

    I have made a simple java-program which monitors control-lines in a computers com-port. Now I need to pass this information to Clarion-based software.
    I am currently writing the changes in to a file from which the clarion software will read the changes, but is there any better way to do this?

    Check out these websites:
    - http://www.softvelocity.com
    - http://en.wikipedia.org/wiki/Clarion_programming_language
    The problems is actually the fact that i don't have access to this clarion-based software or it's APIs etc.
    Message was edited by:
    RDuck

  • Need help w java program

    i have to writea java program.
    write a java program to make change when an item that costs less than a dollar is purchased and the buyer gives the seller a one dollar bill. the goal is to provide the buyer as few coins as possible in the change. the program must determine how many quarters, how many dimes, how many nickles, and how many pennies to return. the ideal program would read in the cost of the item purchased, but for now your program should just set the cost of the item to be 32 cents.
    what am i supposed to do. thank you!!

    i only have to make the first step, which is showing that the item costs 32 cents.
    so far i got this:
    public class change {
    public static void main(String[] args) {
    System.out.println("Cost = $0.32);
    however, i get this error message:
    Could not find the main class: change. Program will exit.
    Exception in thread "main"
    ----jGRASP wedge2: exit code for process is 1.
    ----jGRASP: operation complete.
    i downloaded jgrasp on my computer and i got this message, this never happened with the school pc. so maybe i did sth wrong with the program or i don't have the right software on my computer.

  • Hi there, need help for this program...thx!

    Hi there guys,
    I have created this applet program that requires a user to login with a user no, and a password. I am using arrays as to store the defined variables,(as required by my project supervisor). My problem here is that when the arrays are declared in class validateUser(), the program would run fine, but i cant login and i get a NullPointerException error. if the arrays are located in actionPerformed, i get a 'cannot resolve symbol' error for the method 'get' and 'if (Admin.equals(admins.get(i).toString())) ' as well as 'if (Password.equals(passwordsget(i).toString())) '. I am not very effecient in java, hence the untidy program (and i have to admit, it isnt any good), so sorry for any inconvenience caused. Once agani thx in advance ;)
    here are my codings :
    import java.applet.Applet;
    import java.awt.*;
    import java.awt.image.*;
    import java.awt.event.*;
    import java.io.*;
    import java.net.URL;
    import java.net.*;
    import javax.swing.*;
    import java.lang.*;
    import java.util.Vector;
    public class eg31662 extends Applet implements ActionListener
         Panel panel1, panel2, panel3, panel4, panel5;
         Button login, enter;
         Label inst, top, admin, pass, fieldlabel;
    TextField adminF, passF, field;
    String Admin, Password;
    Vector admins, passwords;
         Thread thread = null;
         boolean status = false;
              public class validateUser extends Applet
                   String[] admins = {"User1", "User2", "User3"};
                   String[] passwords = {"P1", "P2", "P2"};
         public void init()
              setLayout (new BorderLayout());
              panel1 = new Panel(new FlowLayout());
              panel2 = new Panel(new FlowLayout());
              //login button
              login = new Button("Login");
              //instruction
              inst = new Label("Please type in your User no. and the given password in order to proceed");
              //label
              top = new Label("Login login");
              admin = new Label("Admin No :");
              pass = new Label("Password :");
              //input textfields
              adminF = new TextField(8);
              passF = new TextField(10);
              passF.setEchoChar('*');
              panel1.setBackground(Color.gray);
              panel2.setBackground(Color.orange);
              panel2.add(admin);
              panel2.add(adminF);
              panel2.add(pass);
              panel2.add(passF);
              panel2.add(login);
              panel2.add(inst);
              panel1.add(top);
              add(panel1, BorderLayout.NORTH);
              add(panel2, BorderLayout.CENTER);
              login.addActionListener(this);
              setSize(500,400);
         void mainpage()
              boolean flag = true;
              setLayout (new BorderLayout());
              panel1 = new Panel(new FlowLayout());
              panel2 = new Panel(new FlowLayout());
              top = new Label("Welcome");
              enter = new Button("Enter");
              panel2.setBackground(Color.orange);
              panel1.setBackground(Color.gray);
              fieldlabel = new Label("Type something here :");
              field = new TextField(20);
              add(panel1, BorderLayout.NORTH);
              add(panel2, BorderLayout.CENTER);
              panel2.add(fieldlabel);
              panel2.add(field);
              enter.addActionListener(this);
         public void start() {
              if(thread == null) {
                   status = true;
         public void stop() {
              status = false;
         public void run() {
              while(status == true) {
                   try {
                        thread.sleep(50);
                   catch(InterruptedException ie) {
                   repaint();
              thread = null;
         public void actionPerformed(ActionEvent ev)
                   //String[] admins = {"User1", "User2", "User3"};
                   //String[] passwords = {"P1", "P2", "P3"};
              if(ev.getSource() == login)
                   Admin = adminF.getText();
                   Password = passF.getText();
              boolean ok = true;
              for (int i = 0; i < admins.size(); i++) {
              if (Admin.equals(admins.get(i).toString())) {
              if (Password.equals(passwords.get(i).toString())) {
              ok = true;
              this.setVisible(false);
              //break;
                             JOptionPane.showMessageDialog(null, "Welcome, u have successfully logged in");
                             mainpage();
              else {
              ok = false;
              else {
              ok = false;
              if (ok == false) {
                             JOptionPane.showMessageDialog(null,
                        "Incorrect Password or Admin No, Please Try Again",
                        "Access Denied",
                        JOptionPane.ERROR_MESSAGE);
              else {
              this.setVisible(false);
    }

    Hi, sorry to bring this thread up again, but this is actually a continuation from my previous posted program. Hope u guys can help me again!
    Right now i'm supposed to come up with a simple quiz program, which consists of the center panel displayin the question (in a pic format), and a textfield to enter the answer at the lower panel. this goes on for a couple of pages and once it is completed, the final page would display the total correct answers out of the number of questions, as well as the score in percentage form.
    The few(or many) problems taht i'm facing are :
    1)How do i save the answers that are typed in each textfieldAnd later on checked for the correct answer based on the array given?
    2)How do i go about doing the final score in percentage form and total of correct answers?
    3)I previously tried out using canvas, but it didnt seem to work. my questions(pictures) that are supposed to displayed in the center(canvas) produce nothing. How do i rectify that?
    i'm really sorry for the mess in the codings, hope this wouldnt be a hassle for any of u out there. Once again thanks in advance!
    import java.applet.Applet;
    import java.awt.*;
    import java.awt.event.*;
    import java.awt.image.*;
    import java.io.*;
    import java.net.URL;
    import java.net.*;
    import java.util.Vector;
    import javax.swing.*;
    import java.awt.image.*;
    import java.lang.*;
    import java.awt.Graphics;
    public class eg31662 extends Applet implements ActionListener
        Panel panel1, panel2, panel3, panel4, panel5;
        Button login, enter;
        Label inst, top, admin, pass, startLabel;
        TextField adminF, passF, field;
        String Admin, Password;
        Vector admins, passwords;
         //Quiz declarations
         TextField ansF1,ansF2,ansF3;
         Button startBut, next0, next1, finishB, previous1;
         Image q1, q2, q3;
         Image ques[] = new Image[2];
         boolean text = false;
         boolean checked = false;
         int correct = 0;
         String [] answer = new String [2];
         String [] solution = {"11", "22", "33"};
         boolean text = false;
         boolean sound = true;
         int red,green,blue;
         int question =0;
         int good = 0;
         boolean pause= false;
         boolean start = true;*/
        Thread thread = null;
        boolean status = false;
        public void init()
            validateUser();
            setLayout (new BorderLayout());
            panel1 = new Panel(new FlowLayout());
            panel2 = new Panel(new FlowLayout());
            panel3 = new Panel(new FlowLayout());
            //login button
            login = new Button("Login");
            //instruction
            inst = new Label("Please type in your UserName and the given " +
                             "password in order to proceed");
            //label
            top = new Label("Top Label");
            admin = new Label("User Name :");
            pass = new Label("Password :");
            //input textfields
            adminF = new TextField(8);
            passF = new TextField(10);
            passF.setEchoChar('*');
            panel1.setBackground(Color.gray);
            panel2.setBackground(Color.orange);
              panel3.setBackground(Color.gray);
            panel2.add(admin);
            panel2.add(adminF);
            panel2.add(pass);
            panel2.add(passF);
            panel2.add(login);
            panel3.add(inst);
            panel1.add(top);
            add(panel1, BorderLayout.NORTH);
            add(panel2, BorderLayout.CENTER);
            add(panel3, BorderLayout.SOUTH);
            login.addActionListener(this);
            setSize(500,400);
        private void validateUser()
            String[] adminData    = {"t", "User1", "User2", "User3"};
            String[] passwordData = {"t", "P1", "P2", "P3"};
            admins = new Vector();
            passwords = new Vector();
            for(int j = 0; j < adminData.length; j++)
                admins.add(adminData[j]);
                passwords.add(passwordData[j]);
        private void Mainpage()
            boolean flag = true;
            removeAll();  // remove all components from container
            panel1 = new Panel(new FlowLayout());
            panel2 = new Panel(new FlowLayout());
              panel3 = new Panel(new FlowLayout());
            top = new Label("Welcome");
            enter = new Button("Enter");
            panel2.setBackground(Color.orange);
            panel1.setBackground(Color.gray);
            panel3.setBackground(Color.gray);
            startLabel = new Label("Welcome! " +
                                          "Please click on the 'Start' button to begin the quiz ");
              startBut = new Button("Start");
              startBut.requestFocus();
              Dimension dim = getSize();
              startBut.setSize(50,20);
            add(panel1, BorderLayout.NORTH);
            add(panel2, BorderLayout.CENTER);
            add(panel3, BorderLayout.SOUTH);
            panel2.add(startLabel);
            panel2.add(startBut);
            startBut.addActionListener(this);
            validate();
            repaint();
        private void Quiz1()
              //quizCanvas = new Canvas();
            boolean flag = true;
            removeAll();  // remove all components from container
            panel1 = new Panel(new FlowLayout());
            panel2 = new Panel(new FlowLayout());
            panel3 = new Panel(new FlowLayout());
            panel1.setBackground(Color.gray);
            panel2.setBackground(Color.orange);
            panel3.setBackground(Color.gray);
            add(panel1, BorderLayout.NORTH);
            add(panel2, BorderLayout.CENTER);
            add(panel3, BorderLayout.SOUTH);
              q1 = getImage(getDocumentBase(), "1.gif");
              ques[0] = q1;
              //ques[1] = q2;
              //previous = new Button("<");
              next0 = new Button("Done");
            ansF1 = new TextField(25);
              next0.addActionListener(this);
              //quizCanvas.insert(ques1);
            //panel3.add(previous);
            panel3.add(next0);
            panel3.add(ansF1);
            //panel2.add("1.gif");
              ansF1.requestFocus();
              ansF1.setText("focussing");
            validate();
            repaint();
         public void Quiz2(){
            boolean flag = true;
            removeAll();  // remove all components from container
            panel1 = new Panel(new FlowLayout());
            panel2 = new Panel(new FlowLayout());
            panel3 = new Panel(new FlowLayout());
            panel1.setBackground(Color.gray);
            panel2.setBackground(Color.orange);
            panel3.setBackground(Color.gray);
            add(panel1, BorderLayout.NORTH);
            add(panel2, BorderLayout.CENTER);
            add(panel3, BorderLayout.SOUTH);
              q2 = getImage(getDocumentBase(), "2.gif");
              ques[1] = q2;
              next1 = new Button("Done");
            ansF2 = new TextField(25);
              next1.addActionListener(this);
            panel3.add(next1);
            panel3.add(ansF2);
              ansF2.requestFocus();
              ansF2.setText("focussing");
            validate();
            repaint();
         public void Quiz3(){
            boolean flag = true;
            removeAll();  // remove all components from container
            panel1 = new Panel(new FlowLayout());
            panel2 = new Panel(new FlowLayout());
            panel3 = new Panel(new FlowLayout());
            panel1.setBackground(Color.gray);
            panel2.setBackground(Color.orange);
            panel3.setBackground(Color.gray);
            add(panel1, BorderLayout.NORTH);
            add(panel2, BorderLayout.CENTER);
            add(panel3, BorderLayout.SOUTH);
              q3 = getImage(getDocumentBase(), "3.gif");
              ques[2] = q3;
              finishB = new Button("Finish");
            ansF3 = new TextField(25);
              finishB.addActionListener(this);
            panel3.add(finishB);
            panel3.add(ansF3);
              ansF3.requestFocus();
              ansF3.setText("focussing");
            validate();
            repaint();
        public void start() {
            if(thread == null) {
                status = true;
        public void stop() {
            status = false;
        public void actionPerformed(ActionEvent ev)
            boolean ok = true;
            if(ev.getSource() == login)
                Admin = adminF.getText();
                Password = passF.getText();
                for (int i = 0; i < admins.size(); i++) {
                    if (Admin.equals(admins.get(i).toString())) {
                        if (Password.equals(passwords.get(i).toString())) {
                            ok = true;
                            JOptionPane.showMessageDialog(null,
                                        "Welcome, u have successfully logged in");
                            Mainpage();
                            break;
                        else {
                            ok = false;
                    else {
                        ok = false;
                if (!ok) {
                    JOptionPane.showMessageDialog(null,
                                  "Incorrect Password or Admin No, Please Try Again",
                                  "Access Denied",
                                   JOptionPane.ERROR_MESSAGE);
            if(ev.getSource() == startBut)
                   Quiz1();
              if (ev.getSource () == next0) {
                   saveanswer();
                   Quiz2();
              if (ev.getSource () == next1) {
                   //saveanswer();
                   Quiz3();
              if (ev.getSource () == finishB) {
                   //saveanswer();
                   //checkanswer();
         /*class quizCanvas extends Canvas {
              private Image quest;
              public quizCanvas() {
                   this.quest = null;
              public quizCanvas(Image quest) {
                   this.quest = quest;
              public void insert(Image quest) {
                   this.quest=quest;
                   repaint();
              public void paint(Graphics g) {
         public void checkanswer() {
              if (!checked) {
              /*question = 0;
                   for (int a=1;a<16;a++) {
                        question++;*/
                        if (ansF1) {
                             if (answer[1].toUpperCase().equals(solution[1])) {
                                  correct++;
                        if (ansF2) {
                             if (answer[2].toUpperCase().equals(solution[2])) {
                                  correct++;
                        if (ansF3) {
                             if (answer[3].toUpperCase().equals(solution[3])) {
                                  correct++;
              checked = true;     }
         public void saveanswer() {
              if (text) {
                   if (!ansF1.getText().equals("")) {
                        answer [Quiz1] = ansF1.getText();
                   //answer2[question] = tf2.getText();
                   if (!ansF2.getText().equals("")) {
                        answer [] = ansF2.getText();
                   if (!ansF3.getText().equals("")) {
                        answer [] = ansF3.getText();
    }

  • Need help with java program

    Modify the Inventory Program by adding a button to the GUI that allows the user to move to the first item, the previous item, the next item, and the last item in the inventory. If the first item is displayed and the user clicks on the Previous button, the last item should display. If the last item is displayed and the user clicks on the Next button, the first item
    should display. the GUI using Java graphics classes.
    ? Add a company logo to? Post as an attachment Course Syllabus
    here is my code // created by Nicholas Baatz on July 24,2007
      import java.awt.BorderLayout;
    import java.awt.GridLayout;
    import java.awt.event.ActionEvent;
    import java.awt.event.ActionListener;
    import javax.swing.Icon;
    import javax.swing.ImageIcon;
    import javax.swing.JButton;
    import javax.swing.JFrame;
    import javax.swing.JLabel;
    import javax.swing.JPanel;
    import javax.swing.JScrollPane;
    import javax.swing.JTextArea;
    public class Inventory2
    //main method begins execution of java application
    public static void main(final String args[])
    int i; // varialbe for looping
    double total = 0; // variable for total inventory
    final int dispProd = 0; // variable for actionEvents
    // Instantiate a product object
    final ProductAdd[] nwProduct = new ProductAdd[5];
    // Instantiate objects for the array
    for (i=0; i<5; i++)
    nwProduct[0] = new ProductAdd("Paper", 101, 10, 1.00, "Box");
    nwProduct[1] = new ProductAdd("Pen", 102, 10, 0.75, "Pack");
    nwProduct[2] = new ProductAdd("Pencil", 103, 10, 0.50, "Pack");
    nwProduct[3] = new ProductAdd("Staples", 104, 10, 1.00, "Box");
    nwProduct[4] = new ProductAdd("Clip Board", 105, 10, 3.00, "Two Pack");
    for (i=0; i<5; i++)
    total += nwProduct.length; // calculate total inventory cost
    final JButton firstBtn = new JButton("First"); // first button
    final JButton prevBtn = new JButton("Previous"); // previous button
    final JButton nextBtn = new JButton("Next"); // next button
    final JButton lastBtn = new JButton("Last"); // last button
    final JLabel label; // logo
    final JTextArea textArea; // text area for product list
    final JPanel buttonJPanel; // panel to hold buttons
    //JLabel constructor for logo
    Icon logo = new ImageIcon("C:/logo.jpg"); // load logo
    label = new JLabel(logo); // create logo label
    label.setToolTipText("Company Logo"); // create tooltip
    buttonJPanel = new JPanel(); // set up panel
    buttonJPanel.setLayout( new GridLayout(1, 4)); //set layout
    // add buttons to buttonPanel
    buttonJPanel.add(firstBtn);
    buttonJPanel.add(prevBtn);
    buttonJPanel.add(nextBtn);
    buttonJPanel.add(lastBtn);
    textArea = new JTextArea(nwProduct[3]+"\n"); // create textArea for product display
    // add total inventory value to GUI
    textArea.append("\nTotal value of Inventory "+new java.text.DecimalFormat("$0.00").format(total)+"\n\n");
    textArea.setEditable(false); // make text uneditable in main display
    JFrame invFrame = new JFrame(); // create JFrame container
    invFrame.setLayout(new BorderLayout()); // set layout
    invFrame.getContentPane().add(new JScrollPane(textArea), BorderLayout.CENTER); // add textArea to JFrame
    invFrame.getContentPane().add(buttonJPanel, BorderLayout.SOUTH); // add buttons to JFrame
    invFrame.getContentPane().add(label, BorderLayout.NORTH); // add logo to JFrame
    invFrame.setTitle("Office Min Inventory"); // set JFrame title
    invFrame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); // termination command
    //invFrame.pack();
    invFrame.setSize(400, 400); // set size of JPanel
    invFrame.setLocationRelativeTo(null); // set screem location
    invFrame.setVisible(true); // display window
    // assign actionListener and actionEvent for each button
    firstBtn.addActionListener(new ActionListener()
    public void actionPerformed(ActionEvent ae)
    textArea.setText(nwProduct[0]+"\n");
    } // end firstBtn actionEvent
    }); // end firstBtn actionListener
    textArea.setText(nwProduct[4]+"n");
    // prevBtn.addActionListener(new ActionListener()
    // public void actionPerformed(ActionEvent ae)
    // dispProd = (nwProduct.length+dispProd-1) % nwProduct.length;
    // textArea.setText(nwProduct.display(dispProd)+"\n");
    // } // end prevBtn actionEvent
    // }); // end prevBtn actionListener
    } // end main
    } // end class Inventory2
    class Product
    protected String prodName; // name of product
    protected int itmNumber; // item number
    protected int units; // number of units
    protected double price; // price of each unit
    protected double value; // value of total units
    public Product(String name, int number, int unit, double each) // Constructor for class Product
    prodName = name;
    itmNumber = number;
    units = unit;
    price = each;
    } // end constructor
    public void setProdName(String name) // method to set product name
    prodName = name;
    public String getProdName() // method to get product name
    return prodName;
    public void setItmNumber(int number) // method to set item number
    itmNumber = number;
    public int getItmNumber() // method to get item number
    return itmNumber;
    public void setUnits(int unit) // method to set number of units
    units = unit;
    public int getUnits() // method to get number of units
    return units;
    public void setPrice(double each) // method to set price
    price = each;
    public double getPrice() // method to get price
    return price;
    public double calcValue() // method to set value
    return units * price;
    } // end class Product
    class ProductAdd extends Product
    private String feature; // variable for added feature
    public ProductAdd(String name, int number, int unit, double each, String addFeat)
    // call to superclass Product constructor
    super(name, number, unit, each);
    feature = addFeat;
    }// end constructor
    public void setFeature(String addFeat) // method to set added feature
    feature = addFeat;
    public String getFeature() // method to get added feature
    return feature;
    public double calcValueRstk() // method to set value and add restock fee
    return units * price * 0.05;
    public String toString()
    return String.format("Product: %s\nItem Number: %d\nIn Stock: %d\nPrice: $%.2f\nType: %s\nTotal Value of Stock: $%.2f\nRestock Cost: $%.2f\n\n\n",
    getProdName(), getItmNumber(), getUnits(), getPrice(), getFeature(), calcValue(), calcValueRstk());
    } // end class ProductAddI can not get all the buttons to work and do not know why can someone help me

    You have to have your code formatted correctly to begin with before you add the code tags. All your current code is left-justified and is not indented correctly.
    I only see that you've added an actionlistener to the "first" button.
    I recommend that you:
    1) again, do this first in a nonGUI class, then use this nonGUI class in your GUI class.
    2) Have a integer variable that holds the location of the current Product that your application is pointing to.
    3) Have a method called getProduct(int index) that returns the product that is at the location specified by the index in your array / arraylist / or whatever collection that you are using.
    4) Have your first button set index to 0 and then call getProduct(index).
    5) Have your last button set your index to the last product in your collection (i.e.: index = productCollection.length - 1 if this is an array), and then call getProduct(index).
    5) Have your next button increment your index up to the maximum allowed and then call getProduct(index). If it's an array it goes up to the array length - 1.
    6) If you want the next button to cause the index to roll over to the first, when you are at the last then then increment the index and mod it ("%" operator) by the length of the array...

  • Need help with Java Programming

    Hello All,
    I dont know how to save all the lines separatly and then work with the numbers?
    Example TxtIn:
    2 5
    0 9 2 3 4 // I dont know how many lines will appear, and dont know how many numbers in a line
    1 2 3 9
    1 5 4
    2 0 0 5 6
    2 5 1 9
    4 6 1 5
    4 9 1 8
    9 1 4 8
    9 5 0
    Example TxtOut:
    1 9 4 0
    I would really appreciate your help in this.
    In my code, i only past one time in the text file, and clear the numbers of the list, but i need to make more check =S
    Here is the code:
    import java.io.File;
    import java.io.FileNotFoundException;
    import java.io.FileWriter;
    import java.io.IOException;
    import java.io.PrintWriter;
    import java.util.ArrayList;
    import java.util.Scanner;
    import java.util.StringTokenizer;
    * @author Antonio
    public class web {
        /** Creates a new instance of Main */
         * @param args the command line arguments
        public static void main(String[] args) throws FileNotFoundException {
            int contador;
            ArrayList<Integer> lista = new ArrayList<Integer>();
            Scanner scn = new Scanner(new File("in.txt"));
            try {
            PrintWriter fileOut = new PrintWriter(new FileWriter("out.txt"));
            int ciudades = scn.nextInt();
            int aerolineas = scn.nextInt();
            int ciudadabuscar = scn.nextInt();
            int aerolinea = scn.nextInt();
            int bandera=0;
            while (scn.hasNextLine()){
                    String cad = scn.nextLine();
                    StringTokenizer st = new StringTokenizer(cad," ");
             while (st.hasMoreTokens())
                    String t = st.nextToken();
                    lista.add ( Integer.parseInt(t) );
               int a[]= new int[lista.size()];
               for (int x=0; x<lista.size(); x++)
                            a[x] = lista.get(x);
                          for (int x=0; x<lista.size(); x++)
                   for (x=1;x<lista.size();x++){
                            if (ciudadabuscar == a[0] && aerolinea == a[1])//tenia x=1
                                for (x=2;x<lista.size();x++)
                                { fileOut.printf("%d ",a[x]);
                                  ciudadabuscar= a[2];
                                  bandera = 1;}
                         lista.clear();
            if(bandera==0){
            fileOut.println("No hay destinos posibles por esta línea");
            fileOut.close();
            }catch(FileNotFoundException ex){}catch(IOException ex){}
    }

    #1 Solution is the same as i am working but...if i found AND another pair needs tobe searched...i dont know how to start again with step 1...
    i onli continues reading..that is why i am never show
    2 5//i am reading the file looking for 2 and 5
    0 9 2 3 4
    1 2 3 9
    1 5 4 // I NEVER show the number 4....
    2 0 0 5 6
    2 5 1 9 // here i found them...and now i have to look in the file 1 5 and 9 5 (but 1 5 are before this..so i can never found them)
    4 6 1 5
    4 9 1 8
    9 1 4 8
    9 5 0 // here i found 9 5
    Correct OutTxt: 1 9 4 0
    My OutTxt: 1 9 0...Never show the number 4, because i dont know how to start again...
    thank u
    Edited by: Ing_Balderas on Dec 11, 2009 2:25 PM

  • Need help in java programming..

    Hi all
    I am a newbie to java.
    I have to develop a software which on installation will insert a icon in other software( lotus notes mail client) and when this icon will be clicked, it will prompt the software.
    Its something like when you install adobe pdf creater ,it insert its icons in Microsoft office suite like word, outlook etc and when u click the icon( create pdf) it prompts pdf creater to create the file.
    My question is how to program this ?
    On installing my software will run a script which will modify the code of lotus notes but how to wirte the script, i dont know.
    As i said, i am new to java and still learning, so I will really appreciate your help.
    Regards
    Sachin

    They create VB macros (usually) and place them in the default template directories for the appropriate software (or possibly, references to them in the registries for those softwares). And those, are Microsoft topics, find another forum.

  • Need help writing Java program

    I am a student conducting research as to the tolerance of users to a user interface. My idea is to take the existing tetris game but implement errors into it, so that on occasion the piece will not move in the direction you want it to. Also In the program there will need to be an introduction screen, 3 levels which end when you recieve a certain amount of points, a data table, for my use which collects information about time between moves, total time, par time( how long it would take if no errors occured), and levels completed. Also if a user fails to pass the level, at what point did they fail. The data will need to be organized in a logical order and finally there will need to be a way for me to retrieve the data. I already have the existing tetris code and I need to add to it, so if anyone could help me as I have no programming knowledge and I need this done as soon as possible, please contact me at [email protected] and I will be willing to pay for your time.
    Thanks,
    Ross

    I am a student conducting research as to the
    tolerance of users to a user interface. We call that Human Factors :-)
    My idea is to
    take the existing tetris game but implement errors
    into it, so that on occasion the piece will not move
    in the direction you want it to. So the idea is to piss the user off?!
    Also In the program
    there will need to be an introduction screen, 3
    levels which end when you recieve a certain amount of
    points, a data table, for my use which collects
    information about time between moves, total time, par
    time( how long it would take if no errors occured),
    and levels completed. okay...
    Also if a user fails to pass
    the level, at what point did they fail. The data will
    need to be organized in a logical order and finally
    there will need to be a way for me to retrieve the
    data. I already have the existing tetris code and I
    need to add to it, so if anyone could help me as I
    have no programming knowledge and I need this done as
    soon as possible, please contact me at
    [email protected] and I will be willing to
    pay for your time.
    Thanks,
    RossFirst of all, it's probably not a good idea to post your email address, not that anyone will email you anyway. Second, I'm not sure how you're going to accomplish this programming task if you don't know how to program. See the problem?

  • Need help for Java Strings

    Hi ppl,
    i hav a code which has to do some actions on the strings retrieved from the database. The code is in java swings
    I need to know, how do i check if there is a space between strings.
    For eg Kevin Dcosta. (There is a space between Kevin Dcosta)
    Please can someone provide me with the Java code for the same so tat i can append to my code. Or is there any readymade method in Java for the same??
    Thanks
    Divya..

    Hi,
    Go thr StringTokenizer Class it will help u out!........place whatever string u r reading in pu those in stringtokenizer like
    StringTokenizer str=new StringTokenizer(tmpmessage, " ");
    while(readTokenizer.hasMoreTokens())
    String name=readTokenizer.nextToken();
    /****** do whatever the action u want to do*************8
    }

Maybe you are looking for