Java inputing information

well Im having problems with my Java
im doing a cource which I just want to pass and Ive got a little problem. I was going to hand this in... but then was told I need a input thingy to input the values into my array and I have an example code for importing String values. but I have nothing on how to input into my arrays
im to use JOptionPane.inputdialog (etc etc) to put a value in my array
heres my code
import java.awt.*;
import java.awt.event.*;
import java.text.DecimalFormat;
import javax.swing.*;
public class Case03 extends JFrame{
//Defining Fiancial Values in these Arrays
String AccountNo[] = {"1001", "1002", "1003", "1004", "1005", "3002", "5001", "6001", "6003", "6004", "6005", "2001", "3001", "4001"};
String AccountTitle[] = {"Cash\t", "Accounts Receivable", "Merchandise Inventory",
"Supplies\t", "Prepaid Insurance", "Sam's Drawing\t",
"Purchases\t", "Delivery Expense", "Miscellaneous Expense",
"Rent Expense\t", "Salary Expense", "Accounts Payable",
"Sam's Capital\t", "Sales\t"};
//Will be the Heading Display on the output
String Output = "Sam's Computers\nTrial Balance\nFor Month Ending 30 May, 2001\n\n\nAccount Title\t\t Account No\t Debit\t Credit\n\n";
//Defining Double Values into the array of Debit and Credit
double Debit[] = {6143.40, 756.00, 7840.00, 476.00, 150.00, 370.00, 5018.00, 92.00, 40.60, 500.00,
720.00, 0.00, 0.00, 0.00};
double Credit[] = {0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 2144.00,
10970.00, 8992.00};
//Defining the Deciaml Format into Two Places
DecimalFormat twoDecimalPlaces = new DecimalFormat("0.00");
public Case03()
//Name of The Frame/Window
super("Finance Listing");
//Where The Information is Stored Into the Container
Container c = getContentPane();
try {
for(int i = 0; i < AccountNo.length; i++)
//Displaying Fiancial Information to the Text Frame
Output += AccountTitle[i] + "\t" + AccountNo[i] + "\t" +
twoDecimalPlaces.format(Debit) + "\t" +
twoDecimalPlaces.format(Credit[i]) + "\n";
//Inserting The Totals of Debit and Credit
Output += "\n\t\t\t_____________________";
Output += "\n\t\tTotal" + "\t" +
twoDecimalPlaces.format(Total(Debit)) + "\t" +
twoDecimalPlaces.format(Total(Credit));
catch (Exception e)
JOptionPane.showMessageDialog (null, "There are Errors\n Now Exiting", "Error",
JOptionPane.ERROR_MESSAGE);
System.exit (1);
//Text Area For Financial Information to be Displayed
JTextArea Text = new JTextArea(Output, 10, 10);
//Non-Editable Text
Text.setEnabled(false);
//Changing and Setting Font Type And Size as well as Background Colour
Font Arial = new Font("Arial", Font.BOLD, 12);
Color BackGround = new Color(1, 1, 1);
Text.setFont(Arial);
Text.setBackground(BackGround);
Text.repaint();
//Adding Text to the Container
c.add(Text);
//Setting Text Size
setSize(430, 430);
//Showing the Finace Report
show();
public static void main(String args[]){
Case03 a = new Case03();
a.addWindowListener(new WindowAdapter()
//Exiting the System when Closing Window
public void windowClosing(WindowEvent e)
System.exit(0);
//This is Adding up The Values For a Total
//double v Array will Hold Decimal Place Values
public double Total(double v[]){
//Final is Equal to 0 and Can hold Decimal Values
double Final = 0;
//Array V will move to next cell when s is looped And Give Values by 1
for(int s = 0; s < v.length; s++)
//Establishing Final as the Result Number put in Total(Debit/Credit)
//Which Will Add up Debit or Credit to Display Answer Though
//twoDeicmalplaces.format
Final += v[s];
//Return the Final Answer
return Final;
I need to be able to input my values into my double arrays using JOptionPane.inputdialog, but im not expereinced enoght to know excaly how and not get errors, im trying to do it, but I need some help
can any one help me out please. I have nobody else too :(
thanks

I agree. While there are certainly problems in some situations, most normal usage is going to not be a problem. So someone uses JS to fill inform data or add fields to a form? They can already fill in data. The new fields aren't going to be used by the server anyway. It makes little difference.
The real problems come when you are trying to store sensitive info in hidden fields. That could be messed with. And the solution is to not use hidden fields, but use the server (session data) to hold that.
Even calling submit() on a form should still be calling the onsubmit function, if you have one, to validate the data. But you often can't be sure that JS is enabled at all, so maybe you just validate things anyway on the server, and that avoids that problem.

Similar Messages

  • Form fields won't display input information

    We are having a very odd issue that's happened on two occassions. We have a basic PDF form where someone has input information into various fields, but the information doesn't display, unless you click within the field. At that point you can see what's been typed in. As soon as you tab to the next field, the information is no longer visable -- it's still there, but you can't see it. I don't know if this is relavent, but it's interesting that one part of the form has some checkboxes and that information displays with no problem.
    One form was one we created in-house, and we've been using it for about 9 months with no problems at all. The other form is an external form that was sent to us.
    Neither of these are a LiveCycle designer form.
    We get the same results regardless of whether we open within Mac or Windows.
    Both forms, in their final state, were emailed to us via an outside source (different, unrelated sources). That seems to be the only common attribute.
    Any ideas?

    One thing you can try is opening the form in Acrobat, exporting the form data to an FDF file, and re-import it.
    You can also run a JavaScript the will correct things as much as possible. For example, see: http://blogs.adobe.com/pdfdevjunkie/script_to_fix_mac_osx_previewa.html
    I've written a script that is more comprehensive in that it addresses other type of fields. Post again if you'd like it.
    Please note, though, that any of these methods can only do so much. Preview screws things up in a way that's not easily reversible.

  • Input information in worklist application's task details

    Hi,
    I want to show the input information to the approvers, in the task details of the worklist application
    Can someone help me on this?
    Regards

    Pass the input information to the human task as a parameter.
    Re-generate the simple task form or build a custom task form. This will give you a JSP that the worklist app will use to show the task data including the input data you provided.
    For simple formatting I just create the simple task form and move things around on the JSP as needed.

  • Help calling up previously inputed information.

    My teacher made the simpleInput part, so that actual inputing works, and also I have two other classes with defined variables with getters, setters, and a default constructor and a premade constructor. Question is, when I run this program and I type "input" and input the information it doesn't save... when I go and use my "print" function, all that happens is it prints "null" for the actor/actress/director, and it prints blank for the other. And clues as how and what I need to do to call up the information I've already inputed... instead of getting a blank?
    public class Operation {
         private String inputInfo;
         public String inputInfo(){
              String value;
              do { System.out.println("Select either 'actor, actress, or director : ");     //Tells you what to type for the input
              value = SimpleInput.inputString();
              if (value.equalsIgnoreCase("Actress")){
                   return value;
              } else if (value.equalsIgnoreCase("Actor")) {
                   return value;
              } else if (value.equalsIgnoreCase("Director")){
                   return value;
              } else if (!value.equalsIgnoreCase("quit")){
                   System.out.println("That option is unknown, please try again.");
              } while (!value.equalsIgnoreCase("Director") || !value.equalsIgnoreCase("Actor") || !value.equalsIgnoreCase("Actress") ||
                        !value.equalsIgnoreCase("quit"));     
              return value;
         public String inputTitle(){
              Movie go;
              go = new Movie();
              String value;
              System.out.println("Enter the title of the movie :");
              value = SimpleInput.inputString();
              go.setTitle(value);
              return value;
         public String getinputInfo(){
              return inputInfo;
         public void setinputInfo(String inputInfo){
              this.inputInfo = inputInfo();
         public void printOutInfo(){
              Movie go;
              go = new Movie();
              Operation gogo;
              gogo = new Operation();
              inputInfo();
              inputTitle();
              System.out.println(gogo.getinputInfo());
              System.out.println(gogo.getTitle());
         public void startInterface(){
              String command; //Setting command to a String
              do {            //Another do - while start, with else if statements
                   System.out.println("Input Command or type 'help' : ");
                   command = SimpleInput.inputString();
                   if (command.equalsIgnoreCase("help")) {  //Different commands avaiable.
                        System.out.println("This is a help message");
                        System.out.println("Possible commands are:");
                        System.out.println("     help - This help message");
                        System.out.println("     input - Input information for a Movie.");
                        System.out.println("     print - Print will print out the information about the last movie input.");
                        System.out.println("     star - This will input the name of an actor/actress and check if it belongs to " +
                                  "one of the four from the last movie input.");
                        System.out.println("     director - This will input the name of a director and see if" +
                                  " it matches the name of the director for the last movie input.");
                        System.out.println("     quit - This will exit the application.");
                   } else if (command.equalsIgnoreCase("input")){
                        inputInfo(); inputTitle();
                   } else if (command.equalsIgnoreCase("print")){                    
                        printOutInfo();
                   } else if (!command.equalsIgnoreCase("quit")){
                        System.out.println("Unknown Command -- " + command );
                        } while (!command.equalsIgnoreCase("quit")); // Condition the while sets.
         public static void main(String[] args) {
              Operation go;
              go = new Operation();
              go.startInterface();

    I did that but all i get is null... like I'm almost positive I'm setting it right... but it seems like when I go and try and run another method i'm not calling it right... because it always coming up that nothing was ever there... now I can get it to work if I have it set it in the same method, then go and print it... but i want this in two different methods.
    Example:
    Input Command or type 'help' :
    input
    Select either 'actor, actress, or director :
    actor
    Enter the title of the movie :
    aldksfj
    Enter the year the movie was made :
    1900
    Input Command or type 'help' :
    print
    Select either 'actor, actress, or director :
    actor
    null <----- I want the input i entered in here... but ya.
    0
    Input Command or type 'help' :
    public class Operation {
         private String inputInfo;
         public String inputInfo(){
              Operation go;
              go = new Operation();
              String value;
              do { System.out.println("Select either 'actor, actress, or director : ");     //Tells you what to type for the input
              value = SimpleInput.inputString();
              if (value.equalsIgnoreCase("Actress")){
                   System.out.println(go.getinputInfo());
                   this.inputInfo = value;
                   return value;
              } else if (value.equalsIgnoreCase("Actor")) {
                   this.inputInfo = value;
                   return value;
              } else if (value.equalsIgnoreCase("Director")){
                   this.inputInfo = value;
                   return value;
              } else if (!value.equalsIgnoreCase("quit")){
                   System.out.println("That option is unknown, please try again.");
              } while (!value.equalsIgnoreCase("Director") || !value.equalsIgnoreCase("Actor") || !value.equalsIgnoreCase("Actress") ||
                        !value.equalsIgnoreCase("quit"));     
              return value;
         public String inputTitle(){
              Movie go;
              go = new Movie();
              String value;
              System.out.println("Enter the title of the movie :");
              value = SimpleInput.inputString();
              go.setTitle(value);
              return value;
         public int inputYear(){
              Movie go;
              go = new Movie();
              int value;
              do {
              System.out.println("Enter the year the movie was made :");
              value = (int)SimpleInput.inputLong();
              if (value < 1800 || value >= 2007){
                   System.out.println("No movie was made in this time zone, try again :");
              } else if (value >= 1800 && value < 2007){
                   return value;
             while (value < 1800 || value >= 2007);
              go.setYear(value);
              return value;
         public String getinputInfo(){
              return inputInfo;
         public void setinputInfo(String inputInfo){
              this.inputInfo = inputInfo();
         public void printOutInfo(){
              Movie go;
              go = new Movie();
              Operation gogo;
              gogo = new Operation();
              System.out.println(gogo.getinputInfo());
              System.out.println(go.getTitle());
              System.out.println(go.getYear());
         public void startInterface(){
              String command; //Setting command to a String
              do {            //Another do - while start, with else if statements
                   System.out.println("Input Command or type 'help' : ");
                   command = SimpleInput.inputString();
                   if (command.equalsIgnoreCase("help")) {  //Different commands avaiable.
                        System.out.println("This is a help message");
                        System.out.println("Possible commands are:");
                        System.out.println("     help - This help message");
                        System.out.println("     input - Input information for a Movie.");
                        System.out.println("     print - Print will print out the information about the last movie input.");
                        System.out.println("     star - This will input the name of an actor/actress and check if it belongs to " +
                                  "one of the four from the last movie input.");
                        System.out.println("     director - This will input the name of a director and see if" +
                                  " it matches the name of the director for the last movie input.");
                        System.out.println("     quit - This will exit the application.");
                   } else if (command.equalsIgnoreCase("input")){
                        inputInfo(); inputTitle(); inputYear();
                   } else if (command.equalsIgnoreCase("print")){                    
                        printOutInfo();
                   } else if (!command.equalsIgnoreCase("quit")){
                        System.out.println("Unknown Command -- " + command );
                        } while (!command.equalsIgnoreCase("quit")); // Condition the while sets.
         public static void main(String[] args) {
              Operation go;
              go = new Operation();
              go.startInterface();

  • Looking for Java Input Method implementations

    Hi,
    I have developed a Java-based research application for computational linguistics. I'm currently internationalizing this application. I'm looking for FREE implementations of the Java Input Method Framework. Could you please give me a hint?
    Thanks in advance,
    Wolfgang Lezius
    University of Stuttgart, Germany

    http://forum.java.sun.com/thread.jsp?forum=16&thread=270024 contains few useful links.

  • Help!How to change the language of java compile information?

    Hi,every body!
    my first language is not english, so please forgive me for my poor english.
    My OS is Windows XP Chinese edition&#65292;and my JDk is 1.6 u5 multi-language edition. The problem is that&#65292;when I compile java programs with problems, the jdk gives a error information in Chinese. I think the informatin is translated terribly. Some even hard to understand. I wanna modify jdk to display error info in English. I try to find a answer on google, but failed. please give me a hand, thanks!

    To Darryl.Burke , I 'm sorry to make you hava a so feeling. I just wanna get a answer ASAP. I copy my reply it's because that i think above reply in the two forum it is similar, and i can use the same word to reply. It doesn't means i don't respect the replyers. I don't want you misunderstand me. I have reflected upon my mistakes. I hope you can help me in the future as before.Thanks all the same.

  • BasicTableUI.java Copyright information

    I was wondering if someone could clarify some copyright information for me. I am Modifying BasicTableUI very heavily and some of it I could easily copy and paste, but I this is a commercial product I am working on and was curious how much flexibility there is with using snippets of the Swing source code, specifically BasicTableUI, in a closed source commercial application.
    Thank you for your time,
    Brandon

    Well we are a small two person company and do not have any lawyers, but I was just hoping someone could tell me the type of license the java source is under, an apache style license or something more like GNU?
    Edited by: Officialhopsof on Sep 10, 2011 4:32 PM

  • JAVA API :: Information needed

    Hi. I tought BI Publisher Java API would give me access to the server repository. And then, just execute something like:
    Report r = Report.newReport("MyReportName");
    r.Generate()
    But as far as I see, It only gives me the possibility yo LOCALLY consume an XML (somehow obtained) and use a XSL previously obtained.
    What if just want to execute a report via JAVA, according to all the information I have completed for the report?
    For example, if I have a report that uses a SQL DataSource, and receives 2 parameters, can't I just execute something like...
    Report r = Report.newReport("MyReportName");
    r.setParam("BILL_ID", 2292);
    r.setParam("DATE","01/01/2011");
    r.setTemplate("Template1");
    r.setOutput("PDF");
    r.Generate();

    Hi -
    Here are some helpful methods:
    LibrarySession.getClassObjectCollection() - gets the set of all ClassObjects
    ClassObject.getDirectSubclasses() - gets the immediate subclasses of a ClassObject
    ClassObject.getSubclasses() - gets the subclasses, sub-subclasses, etc. of a ClassObject
    David Pitfield
    Oracle

  • Java debug information

    hy,
    I was wondering, is it possible to let an Xlet log java output (debug information) and send it to a server on the set top box. These logging information should give information about all the applications running on the stb.
    This in order to help debug problems on commercial STB without debug output and without the need to implement special functionality in all the applications.
    Can someone point me out some resources? (I am a beginning java developer, so I think this is rather a java issue than an MHP or javaTV issue)
    Thanks

    I've used a couple of development boxes and have found that writing to standard out, via calls to System.out.println() works well. There is probably a serial port on your debug box that you can connect up to a PC to read the the debug output.
    If you want to know what applications can be run on the STB then you'll need to write a bit of code to query the org.dvb.application.AppsDatabase. getAppIDs() will return an enumeration org.dvb.application.AppID objects each of which can be looked up in the database to give you more information about the application in question
    Roger

  • Java input validation with regular expression

    I am trying to make sure the user can only enter numbers 0 - 100, can any of you Java geniuses give me a hint. My regex matches the inputs I want, but when I enter a '9' I encounter an error when I cast the string to a double. Actually the input value is never assigned to the perc variable, but only when the input is a single digit. Here' s the piece of code that's giving me this headache:
    while(!in.hasNext("[0-9]")){
         try {
              perc = in.next("[0-9]{1,2}|100");
              break;
         } catch (InputMismatchException e) {
              System.out.println("Bad Input - Try Again");
              perc = in.next();
    dblPerc = Double.parseDouble(perc);And here's the error:
    Exception in thread "main" java.lang.NumberFormatException: empty String
            at sun.misc.FloatingDecimal.readJavaFormatString(FloatingDecimal.java:994)
            at java.lang.Double.parseDouble(Double.java:510)
            at applicant_database.View.showInput(View.java:46)
            at applicant_database.View.main(View.java:101)

    Add debugging code to your program to see what you're getting.

  • Java Input and Output streams

    I have maybe simple question, but I can`t really understand how to figure out this problem.
    I have 2 applications(one on mobile phone J2ME, one on computer J2SE). They commuinicate with Input and Output Streams. Everything is ok, but all communication is in sequence, for example,
    from mobile phone:
    out.writeUTF("GETIMAGE")
    getImage();
    form computer:
    reply = in.readUTF();
    if(reply.equals("GETIMAGE")) sendimage()
    But I need to include one simple thing in my applications - when phone rings there is function in MIDlet - pauseApp() and i need to send some signal to Computer when it happens. But how can i catch this signal in J2SE, because mayble phone rings when computer is sending byte array? and then suddnely it receives command "RINGING"....?
    Please explain how to correcly solve such problem?
    Thanks,
    Ervins

    Eh?
    TCP/IP is not a multiplexed protocol. And why would you need threads or polling to decipher a record-oriented input stream?
    Just send your images in packets with a type byte (1=command, 2=image, &c) and a packet length word. At the receiver:
    int type = dataInputStream.read();
    int length = dataInputStream.readInt();
    byte[] buffer = new byte[length];
    int count, read = 0;
    while ((count = dataInputStream.read(buffer,count,buffer.length)) > 0)
    read += count;
    // At this point we either have:
    // type == -1 || count = -1 => EOF
    // or count > 0, type >= 0, and buffer contains the entire packet.
    switch (type)
    case -1:
    // EOF, not shown
    break;
    case COMMAND: // assuming a manifest constant somewhere
    // process incoming command
    break;
    case IMAGE:
    // process or continue to process incoming image
    break;
    }No threads, no polling, and nuthin' up my sleeve.
    Modulo bugs.

  • Powershell - input information in script that is sent to a list in Sharepoint

    I got this question from a co-worker of mine. Today we sit on a wss 3.0 installation which acts as a management portal.
    Here we have an event log list, where we post events/changes. He is regulary using powershell, and would like to sit here and create the log events, filling out stuff like title, description. The rest of the information whatever that may be, like person
    filling out the log, date, tag the item as an event should be autofilled, and then sent to a SharePoint Foundation 2013 list.
    Is this possible? I was thinking that the best solution for him, would then be to have some kind of PowerShell GUI?? When he then press save/send, it is automatically sent to the correct list in SharePoint.

    Hi,
    You can create a windows application that will execute your powershell script. Below link might help:
    http://blogs.msdn.com/b/kebab/archive/2014/04/28/executing-powershell-scripts-from-c.aspx
    Best Regards,
    Brij K

  • Java & Database information

    Hello everyone,
    First of all, I am very new to Java so please respond accordingly.
    I have a database with serveral fields.
    When I call up the data and display it on a website, the time also appears in the field, and for a birhtday that's weird.
    I think I have to make the display field a Date field or something like that, I am just not sure on how to do this.
    The books I have (Core Java2 (part 1 & 2) are not much help.
    If anyone would like to see the code I have, please let me know.
    Thanks in advance!

    Hello again,
    I have changed the code to what you have suggested.
    Jbuilder doesn't complain about anything, but when I call it up on the website, it returns with this error:
    Compilation of 'C:\bea\wlserver6.1\config\mydomain\applications\.wlnotdelete\WEB-INF\_tmp_war_myserver_myserver_intranet_nl\jsp_servlet\_photobook\__results.java' failed:
    C:\bea\wlserver6.1\config\mydomain\applications\.wlnotdelete\WEB-INF\_tmp_war_myserver_myserver_intranet_nl\jsp_servlet\_photobook\__results.java:131: reference to Date is ambiguous, both class java.sql.Date in java.sql and class java.util.Date in java.util match
    probably occurred due to an error in /photobook/results.jsp line 70:
    Date birthday = rs.getDate("birthday");
    Full compiler error(s):
    C:\bea\wlserver6.1\config\mydomain\applications\.wlnotdelete\WEB-INF\_tmp_war_myserver_myserver_intranet_nl\jsp_servlet\_photobook\__results.java:131: reference to Date is ambiguous, both class java.sql.Date in java.sql and class java.util.Date in java.util match
    Date birthday = rs.getDate("birthday"); //[ /photobook/results.jsp; Line: 70]
    ^
    1 error
    Mon Oct 06 11:34:41 CEST 2003

  • Java input xml data and xsl template -output file excel

    i need help or same special link on web.
    i must develop code or use a special tool that make this.
    INPUT:
    xml that contain real data
    xsl that explain a report template
    OUTPUT:
    file excel that show the template xsl with xml data source
    thank for help me.

    Hi,
    Please refer to "Oracle XML Publisher User's Guide".
    Applications Releases 11i and 12
    http://www.oracle.com/technetwork/indexes/documentation/index.html
    This is also explained in the document attached in (Publishing Concurrent Requests with XML Publisher [ID 295409.1]).
    Thanks,
    Hussein

  • Java Input Stream

    If i have a .txt file in the format:
    1 //indicating the number of lines the question is
    What is my favorite color?
    1. red
    2. blue
    3.orange
    4. yellow
    5. green // these 5 are answers
    1 //indicating number of lines the question is
    How many cars in BMW series?
    1. .....
    2. .....
    3. ..... //answers are always 5 lines
    4 ......
    5 .......
    so each question has exactly 5 answers in the txt file provided.
    I want to make my program read the question and 5 lines of answers. Then ask user for answer (get input). And then continue the same pattern throughout the file. I know how to read the whole file but i am having trouble getting it to read question line, 5 answers , get usr_input and do the same thing for rest. Any help?

    The program below just reads the whole thing: yes line by line. If i put a do { while lets say (oneLine != null), then it reads the whole thing. But I want it to read the question, then asnwers (5 of them) and ask usr_input.. and continue this pattern. I know i should set up a do while loop for each question.. and that's my main problem.
    //the rest of code or the above part which checks for accurate file names and all that works fine. Here is where the problems lies:
    String oneLine=null; /* the contents of a line of the user input file */
         try {
         oneLine = fileIn.readLine();
         int store = Integer.parseInt(oneLine);
         catch (IOException e) {
         System.err.println("Sorry, unable to read a line from the file: " + filename);
         System.exit(0);
         System.out.println("Read the line: " + oneLine);

Maybe you are looking for

  • PDF Export: How to set bottom margin to 0

    Greetings, I am new to Crystal and I did  not see this question on the forums, so please forgive me, if this topic has been covered elsewhere. I am using Crystal Reports Standalone, XI R2 (product version 11.5.0.313). I am exporting a report to PDF a

  • Officejet 6600 "The print carriage cannot move"

    Ran through the published problem solving steps, however, I still receive message of Carriage Jam. Have checked cartiages and everything appears okay there. Please help with any comments. Thank you.

  • Can I install bootcamp on my oldish Mac Pro?

    background--- https://discussions.apple.com/thread/4760740 I have an old Mac Pro running OS X 10.6.8 and I want to install Windows. The machine was built 1-4-18 Oct 1996 in Ireland. from the other thread dalstott of NC said "I looked up the document

  • Boost weak signal?

    I have a PowerBook G4 titanium that is airport ready but has no airport card that I've been trying to get hooked up to a 2Wire wireless router/modem for wireless. I recently purchased a mac wireless pc card which FINALLY solved the problem (after som

  • No volume on my mac

    I have done the info from the Help. Still can't get the volume right.