Need help with the following code (Want an input popup with numeric pad)

Hello,
I put the following code in an event :
import javax.swing.JOptionPane;
value = javax.swing.JOptionPane.showInputDialog("Price", "");
try {
Double newPrice = new Double(value);
line.setPriceTax(newPrice);
} catch (NumberFormatException e) {
JOptionPane.showMessageDialog(null, "Not valid number: " + value, "Error", JOptionPane.PLAIN_MESSAGE);
But this only gives an input popup screen and then i have to use a keyboard instead of my touchscreen to give the input,
i would rather like it to be a popup input screen with a numeric pad attached.
Is this possible, and how??
Thanks in advance.
Jeroen

hii,
set321go wrote
make your own. Create a custom OptionPane and add --->
// global def.
private final JLabel amountLabel = new JLabel(" Input Trades Amount : ");
private JFormattedTextField amountTextField;
private double amount = 0.00;
private NumberFormat amountFormat;
// in panel class add --->
amountFormat = NumberFormat.getNumberInstance();
amountFormat.setMinimumFractionDigits(2);
amountFormat.setMaximumFractionDigits(2);
amountFormat.setRoundingMode(RoundingMode.HALF_EVEN);
amountLabel.setFont(new Font("Serif", Font.BOLD, 16));
amountLabel.setForeground(KopikSalesTest.textColor);
amounTextField = new JFormattedTextField(amountFormat);
amountTextField.setValue(0.00);
amountTextField.setFont(new Font("Serif", Font.BOLD, 20));
amountTextField.setForeground(Color.someColor);
amountTextField.setBackground(Color.someColor);
amountTextField.addFocusListener(new FocusListener() {
            public void focusGained(FocusEvent e) {
                amountTextField.requestFocus();
                amountTextField.setText(amountTextField.getText());
                amountTextField.selectAll();
            public void focusLost(FocusEvent e) {
                //on exit
somePanel.add(amountLabel);
somePanel.add(amountTextField); ... kopik

Similar Messages

  • What's wrong with the following code?

    What's wrong with the following code?
    Circle cir1;
    double rad = cir1.radius

    The circle Object was never instantiated.
    In other words, you have set a declaring of a Circle, but it has not been created in memory yet.
    You will create it using the " = new Circle( PARAMETERS_HERE ); "
    Or some other method that returns a circle.

  • Do we need to put the following code in the web-xml for the project to run

    Hi^^^,
    actually I have created a project in Eclipse WTP and I am running it from remote server. Its giving me 404 error when I tried to run it.
    I know 404 error is generally due to some error in deployment descriptor.
    I am going through this tutorial for creating project in eclipse WTP
    this says that I need to include the following code in web-xml. Please look at the quotes below
    "Web modules in J2EE has a deployment descriptor where you configure the web application and its components. This deployment descriptors is called the web.xml. According to the J2EE specification, it must be located in the WEB-INF folder. web.xml must have definitions for the Servlet and the Servlet URI mapping. Enter the following lines into web.xml:"
    "Listing 2. Deployment Descriptor web.xml"
    <servlet>
    <servlet-name>Snoop Servlet</servlet-name>
    <servlet-class>org.eclipse.wtp.tutorial.SnoopServlet</servlet-class>
    </servlet>
    <servlet-mapping>
    <servlet-name>Snoop Servlet</servlet-name>
    <url-pattern>/snoop/*</url-pattern>
    </servlet-mapping>
    My question is, it is necessary to include the above lines between <servlet> and </servlet-mapping> in web-xml
    thanks and regards,
    Prashant

    pksingh79 wrote:
    actually I have created a project in Eclipse WTP and I am running it from remote server. Its giving me 404 error when I tried to run it.
    I know 404 error is generally due to some error in deployment descriptor. what's the url you've put.
    <servlet>
    <servlet-name>Snoop Servlet</servlet-name>
    <servlet-class>org.eclipse.wtp.tutorial.SnoopServlet</servlet-class>
    </servlet> Every Servlet has to have a <servlet></Servlet> tag in the web.xml
    the <servlet-name>is for the naming the servlet and the <servlet-calss>is for class file of the servlet in your case the .class file is to be in the package of tutorial,if it's not then how the container will no where the calss file is
    <servlet-mapping>
    <servlet-name>Snoop Servlet</servlet-name>
    <url-pattern>/snoop/*</url-pattern>
    </servlet-mapping>You type something in your url likk http://localhost:8080/webappname (Tomcat server),so for url mapping instead of typing the entire class file name ,you just enough have to type what you've put in the <url-mapping> tag and it has to be inside of <servlet-mapping>
    I think the problem is in <url-pattern> change it like /snoop<url-pattern>
    My question is, it is necessary to include the above lines between <servlet> and ></servlet->mapping> in web.xmlSo now you think whether you need something inside <servlet>and </servlet-mapping>

  • Hi! i bought my earpods several months ago and something's wrong with the control, i want to replace it with a new pair but i lost my receipt

    hi! i bought my earpods several months ago and something's wrong with the control, i want to replace it with a new pair but i lost my receipt

    Image persistance on Apple displays:
    http://support.apple.com/kb/HT5455
    Apple say this about LCD screen burn in:
    http://support.apple.com/kb/HT2807
    which includes suggestions for curing that effect.
    Alternatively:
    How to fix screen burn and/or stuck pixels on an LCD monitor:
    JScreenFix
    http://www.jscreenfix.com/basic.php

  • Need explanation of the following code

    HI All,
    I need your help on explanation of the following code :
    what I don't understand is how it route the request (all the benefit of the replace statement )
    If the input is /scarr/LH/SPFLI/402
    how he know to route it and
    what is the benefit for using the wild card and the concatenate CONCATENATE '^' lv_verif_pattern '$'
    Edited by: James Herb on Apr 13, 2010 9:53 AM
    Edited by: James Herb on Apr 13, 2010 9:53 AM

    DATA: lt_routing_tab TYPE z_resource_routing_tab,
      CONSTANTS: param_wildcard TYPE string VALUE '([^/])*'.
      FIELD-SYMBOLS: <ls_routing> LIKE LINE OF lt_routing_tab.
      CALL METHOD get_routing
        RECEIVING
          rt_routing_tab = lt_routing_tab.
      LOOP AT lt_routing_tab ASSIGNING <ls_routing>.
    *   replace all parameters placeholders by regex
        lv_verif_pattern = <ls_routing>-url_info.
        lv_signature = <ls_routing>-url_info.
        REPLACE ALL OCCURRENCES OF REGEX '\{([A-Z]*[_]*[a-z]*[0-9]*)*\}'
        IN lv_verif_pattern WITH param_wildcard.
        CONCATENATE '^' lv_verif_pattern '$'  INTO lv_verif_pattern.
    *   check if pattern matches current entry
        FIND ALL OCCURRENCES OF REGEX lv_verif_pattern
        IN url_info MATCH COUNT lv_count.
    *   pattern matched
        IF lv_count > 0.
    *     get controller class name
          lv_controller_name = <ls_routing>-handler_class.
          ls_class-clsname = lv_controller_name.
    *     check if class exists
    *     class found
          IF sy-subrc = 0.
    *       create controller
            CREATE OBJECT eo_controller TYPE (lv_controller_name).
    *       create parameter table
            SHIFT lv_verif_pattern RIGHT DELETING TRAILING '$'.
            SHIFT lv_verif_pattern LEFT DELETING LEADING ' ^'.
            SPLIT lv_verif_pattern AT param_wildcard INTO TABLE lt_url_parts.
            lv_url_info = url_info.
            LOOP AT lt_url_parts INTO lv_url_part.
              SHIFT lv_signature LEFT DELETING LEADING lv_url_part.
              SHIFT lv_signature LEFT DELETING LEADING '{'.
              SHIFT lv_url_info LEFT DELETING LEADING lv_url_part.
    Edited by: James Herb on Apr 13, 2010 9:56 AM

  • How to display rectangles with the following code in a JPanel?

    I am trying to make a bunch of random rectangles appear inside a JPanel on a GUI form. Im not sire how to display the form and panel with random rectangles. I have in my package the MyRectangle class, a blank JForm class called RectGUI and the class for the panel RectGUIPanel. The following code is from my panel and it should create random rectangles okay but how do I display them inside of a Panel on my RectGUI form? Thanks for the assistance.
    //Declare variables
        private int x;
        private int y;
        private int width;
        private int height;
        private Color color;
        Random rand = new Random();
        public class RectanglePanel extends JPanel
            public void displayRectangles()
                // Declare an arraylist of MyRectangles
                ArrayList<MyRectangle> myArray = new ArrayList<MyRectangle>();
                int maxNumber = 300;
               // Declare Frame and Panel
                JFrame frame = new JFrame();
                Container pane = frame.getContentPane();
                RectanglePanel rect = new RectanglePanel();
                // Set Frame attributes
                frame.setSize(700, 500);
                frame.setLocation(100,100);
                frame.setAlwaysOnTop(true);
                frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
                frame.setTitle(" Rectangle Program");
                frame.setVisible(true);
                for (int i = 0; i < maxNumber; i++)
                    MyRectangle rec = createRandomRec();
                    myArray.add(rec);
                    rect.repaint();
            public MyRectangle createRandomRec()  
                   x = rand.nextInt();
                   y = rand.nextInt();
                   width = rand.nextInt();
                   height = rand.nextInt();
                   color = new Color(rand.nextInt(256), rand.nextInt(256), rand.nextInt(256));
                   return new MyRectangle(x, y , width, height, color);
        }

    I am trying to make a bunch of random rectangles appear inside a JPanel on a GUI form. Im not sire how to display the form and panel with random rectangles. I have in my package the MyRectangle class, a blank JForm class called RectGUI and the class for the panel RectGUIPanel. The following code is from my panel and it should create random rectangles okay but how do I display them inside of a Panel on my RectGUI form? Thanks for the assistance.
    //Declare variables
        private int x;
        private int y;
        private int width;
        private int height;
        private Color color;
        Random rand = new Random();
        public class RectanglePanel extends JPanel
            public void displayRectangles()
                // Declare an arraylist of MyRectangles
                ArrayList<MyRectangle> myArray = new ArrayList<MyRectangle>();
                int maxNumber = 300;
               // Declare Frame and Panel
                JFrame frame = new JFrame();
                Container pane = frame.getContentPane();
                RectanglePanel rect = new RectanglePanel();
                // Set Frame attributes
                frame.setSize(700, 500);
                frame.setLocation(100,100);
                frame.setAlwaysOnTop(true);
                frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
                frame.setTitle(" Rectangle Program");
                frame.setVisible(true);
                for (int i = 0; i < maxNumber; i++)
                    MyRectangle rec = createRandomRec();
                    myArray.add(rec);
                    rect.repaint();
            public MyRectangle createRandomRec()  
                   x = rand.nextInt();
                   y = rand.nextInt();
                   width = rand.nextInt();
                   height = rand.nextInt();
                   color = new Color(rand.nextInt(256), rand.nextInt(256), rand.nextInt(256));
                   return new MyRectangle(x, y , width, height, color);
        }

  • Whats wrong with the following code?

    if currencyName =( "Euros" )
              amount = amount * 1.02;
          else if currencyName =( "Yen" )
              amount = amount * 1.20;
          else if currencyName =( "Pesos" )
              amount = amount * 10;I get error that a ( is needed
    I tried the following:
    if (currencyName =( "Euros" ))
              amount = amount * 1.02;
          else if (currencyName =( "Yen" ))
              amount = amount * 1.20;
          else if (currencyName =( "Pesos" ))
              amount = amount * 10;
          }This gave me error required boolean with arrow pointing to the equals sign.

    Now it's not putting the changed number into amount (I think)
    when I run it gives me the orginal number instead of the mutilpied number.
    I must be missing something rather obvious here.
           // get dollar amount
          double amount =
            Double.parseDouble( dollarJTextField.getText() );
          // get currencty name
          String currencyName = dollarJTextField.getText() ;
          // perform currency conversion
          if (currencyName.equals( "Euros" ))
              amount*= 1.02;
          else if (currencyName.equals( "Yen" ))
              amount*= 1.20;
          else if (currencyName.equals( "Pesos" ))
              amount*= amount * 10;
          //display converted amount
          convertedJTextField.setText( String.valueOf( amount) );

  • Need help in the following query

    Hi ,
    I have the following query to pull out data for a particular timeperiod( campaign)
    select
    da.acct_nr,smas.mrkt_id,smas.fld_sls_cmpgn_perd_id,smas.acct_key,smas.upln_acct_key,smas.awrd_sls_amt,smas.fld_net_sls_amt
    ,smas.stf_ind,da1.acct_nr,
    smas.fld_sls_cmpgn_perd_id,smas.acct_key,smas.upln_acct_key,smas.awrd_sls_amt,smas.fld_net_sls_amt
    ,smas.stf_ind,da1.acct_nr,prev.*
    From cdw.sum_mrkt_acct_sls smas
    join codi.dim_acct da
    on (smas.mrkt_id = da.mrkt_id and smas.acct_key = da.acct_key)
    join codi.dim_acct da1
    on (smas.mrkt_id = da1.mrkt_id and smas.UPLN_acct_key = da1.ACCT_KEY)
    where smas.acct_key in
    select dwnln_acct_key from codi.dim_ldrshp_genlgy
    where mrkt_id = 66 and fld_sls_cmpgn_perd_id = 20100304
    and root_upln_acct_key = (select acct_key from codi.dim_acct where acct_nr = '0032622' and mrkt_id = 66)
    and
    smas.mrkt_id = 66
    and smas.fld_sls_cmpgn_perd_id = 20100304
    and smas.sls_org_key <> -100
    order by 1
    So this query will pull out data for campaign 20100304
    No i want to modify the query to pull out data for 3 such campaigns.
    for a smas.acct_key
    so data will
    smas.acct_key all the data for 1st campaign , all the data for 2nd campaign. all the data for 3rd campaign
    Could you please help in modifying this query.
    Thanks

    How about this ??
    select da.acct_nr,
           smas.mrkt_id,
           smas.fld_sls_cmpgn_perd_id,
           smas.acct_key,
           smas.upln_acct_key,
           smas.awrd_sls_amt,
           smas.fld_net_sls_amt,
           smas.stf_ind,
           da1.acct_nr,
           smas.fld_sls_cmpgn_perd_id,
           smas.acct_key,
           smas.upln_acct_key,
           smas.awrd_sls_amt,
           smas.fld_net_sls_amt,
           smas.stf_ind,
           da1.acct_nr,
           prev.*
      From cdw.sum_mrkt_acct_sls smas
      join codi.dim_acct da on (smas.mrkt_id = da.mrkt_id and
                               smas.acct_key = da.acct_key)
      join codi.dim_acct da1 on (smas.mrkt_id = da1.mrkt_id and
                                smas.UPLN_acct_key = da1.ACCT_KEY)
    where smas.acct_key in (select dwnln_acct_key
                               from codi.dim_ldrshp_genlgy
                              where mrkt_id = 66
                                and fld_sls_cmpgn_perd_id in( 20100304,20100305,20100306)
                                and root_upln_acct_key =
                                    (select acct_key
                                       from codi.dim_acct
                                      where acct_nr = '0032622'
                                        and mrkt_id = 66))
       and smas.mrkt_id = 66
       and smas.fld_sls_cmpgn_perd_id in( 20100304,20100305,20100306)
       and smas.sls_org_key - 100
    order by 1

  • CS3 Crashing with the following code

    Try this in CS3.
    1) Open a new page.
    2) Paste the following between the body tags.
    <cfoutput>
    <form>
    <select name="whatever">
    <cfloop index="x" from="1" to="12">
    <option value="#x#">#x#</option>
    </cfloop>
    </select>
    </form>
    </cfoutput>
    3) Save the file using a cfm extension
    4) in design mode click on the dropdown.
    5) That's crash-tastic!
    wtf adobe. This only works if the file extension is .cfm
    which leads me to believe it's some cf parsing code that DW uses
    when coding in Coldfusion.

    mikechyu wrote:
    > Try this in CS3.
    Try this
    http://www.adobe.com/go/kb402776
    David Powers, Adobe Community Expert
    Author, "The Essential Guide to Dreamweaver CS3" (friends of
    ED)
    Author, "PHP Solutions" (friends of ED)
    http://foundationphp.com/

  • Need help for the following select query-- illegal character

    select product_group_id from product_group where description like '%%'
    I am not able to identify this character.
    When I try to type this character at
    SQL prompt, it does not accepts it.
    This character is in the description field and I have to replace it with NULL..
    Any suggestions..
    Thanks in advance
    null

    I'm not sure about the character you are talking about. But if you find this character in the ASCII character set, you can do all the operation against it with the help of CHR() function.

  • Need help executing the following part of code

    declare
    mpostcode varchar2(10);
    begin
    mpostcode := 'AA11AA';
    insert into url_tab
    values
    ('this is test url',sys.UriFactory.getUri('http://pcls1.craftyclicks.co.uk/xml/rapidaddress?postcode=AA11AA'));
    end;
    right now i have added postcode directly But i will like to add memory variable..
    like say.. But this results in error
    declare
    mpostcode varchar2(10);
    begin
    mpostcode := 'AA11AA';
    insert into url_tab
    values
    ('this is test url',sys.UriFactory.getUri('http://pcls1.craftyclicks.co.uk/xml/rapidaddress?postcode='||mpostcode||'));
    end;
    This results in quote string not properly terminated..
    Kindly help and guide..
    Edited by: susf on Sep 24, 2012 10:03 PM
    Edited by: susf on Sep 24, 2012 10:30 PM

    ('this is test url',sys.UriFactory.getUri('http://pcls1.craftyclicks.co.uk/xml/rapidaddress?postcode='||mpostcode||));
    Modify the above to
    ('this is test url',sys.UriFactory.getUri('http://pcls1.craftyclicks.co.uk/xml/rapidaddress?postcode='||mpostcode));
    Edited by: susf on Sep 24, 2012 10:39 PM
    Other example
    declare
    mpostcode varchar2(10);
    begin
    mpostcode := 'AA11AA';
    insert into url_tab(url_name,url)
    values
    ('this is test url',sys.UriFactory.getUri('http://pcls1.craftyclicks.co.uk/xml/rapidaddress?postcode='||mpostcode);
    end;
    You are short of a Paranthesis for Insert Values.
    Modify it to
    ('this is test url',sys.UriFactory.getUri('http://pcls1.craftyclicks.co.uk/xml/rapidaddress?postcode='||mpostcode));

  • Please help me on a form i push the submit button and all i get is a page with the following code wh

    <?php
    //--------------------------Set these paramaters--------------------------
    // Subject of email sent to you.
    $subject = 'Results from Contact form';
    // Your email address. This is where the form information will be sent.
    $emailadd = '[email protected]';
    // Where to redirect after form is processed.
    $url = 'http://www.karenwebster.info/confirmation.html';
    // Makes all fields required. If set to '1' no field can not be empty. If set to '0' any or all fields can be empty.
    $req = '1';
    // --------------------------Do not edit below this line--------------------------
    $text = "Results from form:\n\n";
    $space = ' ';
    $line = '
    foreach ($_POST as $key => $value)
    if ($req == '1')
    if ($value == '')
    {echo "$key is empty";die;}
    $j = strlen($key);
    if ($j >= 20)
    {echo "Name of form element $key cannot be longer than 20 characters";die;}
    $j = 20 - $j;
    for ($i = 1; $i <= $j; $i++)
    {$space .= ' ';}
    $value = str_replace('\n', "$line", $value);
    $conc = "{$key}:$space{$value}$line";
    $text .= $conc;
    $space = ' ';
    mail($emailadd, $subject, $text, 'From: '.$emailadd.'');
    echo '<META HTTP-EQUIV=Refresh CONTENT="0; URL='.$url.'">';
    ?>
    where do i put this and what am imissing

    I don't know why but after about an hour the tool bar you rferred to came on its self jsut as the support solution and you have advised and it is now working, but the toolbar just disappears and that is why I could not find the link or correct store link. Weird! But thanks, Gordon

  • Need help receiving the "verification code" for Keychain setup.

    Have 15"MacBook Pro" and Iphone 4-S.  I am trying to set up Keychain.  Verification Code notice says it has been sent to my iPhone.  I never receive it.have tried numerous times, no luck.

    I assume you have checked that you have the correct country and phone number entered.

  • Help! I have an imac m6498 question(s) need help on the following ASAP thanx

    i found an imac m6498 at my grandmas's, its working smooth and great. However, i have these problems:
    idont have admin (she doesnt remember the password nor how to remove it)
    i dont have the cd repair and backup etc, nor does she
    cd drive works well (i need info on how i could reset this so i could use the pc like it was new)
    i was thinking of transferring mac os 9 [or leopeord, cuz i  saw a forum that its possible] into a usb ext hard drive and installing it there
    the main problem is, i dont have admin. It says "you do not have access privileges"
    other questions:
    is there a way / combo buttons/commands that i could do to reset, change, redeem the password.
    thank you, sorry for the woording, i rushed it. heehhe

    James,
    That machine is over 10 years old and is not an Intel based iMac, Apple began using Intel microprocessors in 2006 a full 5 years after your machine was made. It is a PPC (Power PC) based machine which cannot run Leopard. In other words you are in the wrong forum. You can reset the password per Resetting an account password however you need the original Install discs. If you don't have those your last option is to contact Apple and see if you can get a duplicate of the originals, you need these because they are machine specific. I suspect that due to the age of the machine you won't be able to get them.

  • Hashtables: What on earth is wrong with the following code!?

    I'm loosing my mind here:
    [jdk1.4.2]
    //random code...
            Hashtable threads = new Hashtable(20);
            threads.put(portNum, ipThread); //portNum is of type int
                                            //ipThread is of type ThreadX, ThreadX extends Thread
    //other code...
            ThreadX t;
            t = (ThreadX)threads.get(packet.getPort());  //packet.getPort() returns an INTAnd the compiler returns this:
    path>javac *.java
    IPServer.java:58: cannot resolve symbol
    symbol : method put (int,ThreadX)
    location: class java.util.Hashtable
    threads.put(destinationPort, ipThread);
    ^
    IPServer.java:67: cannot resolve symbol
    symbol : method get (int)
    location: class java.util.Hashtable
    t = (ThreadX)threads.get(packet.getPort());
    ^
    2 errors
    Thanks ahead of time.

    From the JDK 1.4.2 documentation
    "This class implements a hashtable, which maps keys to values. Any non-null object can be used as a key or as a value.
    To successfully store and retrieve objects from a hashtable, the objects used as keys must implement the hashCode method and the equals method. "
    I assumed from that an int or double or any other primitive, which implements both the hashCode and equals method, would work.

Maybe you are looking for

  • Apps are Quitting in 10.4.7

    Recently installed 10.4.7 and now many applications (Quicktime, Safari etc.) are quitting very often. In fact I can no longer my QT Pro 7.3 as it quits whenever I go to open files that I sed to be able to easily open and view. Thx for any help.

  • Updated to IOS 7.1 & gets "white screen of death"

    Recently, I've updated my iOS to 7.1. Few hours later white lines appeared on the screen until it eventually covered up the whole screen. I've never experienced having this white screen before so I don't know how to deal with this. Hopefully, someone

  • HFM configuration error

    Hi, While configuring HFM on windows machine,I performed following steps Shared services configuration which succeeded then after essbase I moved on to HFM In that I was able to configure database,DCOM but configuration fails while configuring applic

  • Importing multiple personalizations at once

    Hello. We have a number of personalizations set up in the Supplier form that are specific to a set of about 8 responsibilities. Instead of setting up the personalizations separately for each responsibility, I am attempting to create it once, export i

  • TS1436 it says "disc burner software not found" what is that mean

    I try to burn a cd off itunes for windows and I get "Disc Burner Software Not Found".. does anyone know why or how