Results 1 to 3 of 3
  1. #1
    mercy_angel is offline Member
    Join Date
    May 2013
    Posts
    2
    Rep Power
    0

    Default problem with check box and text field

    Hello, I am having problem with my swing java app. I want this:
    From text field user enter number, and from combo box select item, and result is c(Math.sin(a *DefineConstants.PI/180)*DefineConstants.V/2.419;) And that result C show in label.(I defined constans),it is not finished with else if and so on, but it shows me errors. Please help.
    Java Code:
    private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {                                         
    int a;
    double c;
            a = Integer.parseInt(AngleText.getText());
           if (jComboBox1.getSelectedIndex() == 0){
           c =Math.sin(a *DefineConstants.PI/180)*DefineConstants.V/2.419;}
               ResultLabel.setText("Result is: " +String.valueOf(c));
        }

  2. #2
    jim829 is offline Senior Member
    Join Date
    Jan 2013
    Location
    Northern Virginia, United States
    Posts
    3,418
    Rep Power
    5

    Default Re: problem with check box and text field

    Change your signature on your actionListener to

    Java Code:
    public void actionPerformed(ActionEvent evt) {
    ...
    Regards,
    Jim
    The Java™ Tutorial | SSCCE | Java Naming Conventions
    Poor planning our your part does not constitute an emergency on my part.

  3. #3
    mercy_angel is offline Member
    Join Date
    May 2013
    Posts
    2
    Rep Power
    0

    Default Re: problem with check box and text field

    I solve this, but I have another problem. I want next:
    In the begining it shows message dialog and when I click OK, show this program. Problem is how to make when click OK to open program. When I clicked Ok, it opens me empty form
    Java Code:
    public PrelamanjeForm() {
           setTitle("Example");
        setBounds(200,100,400,200);
        setDefaultCloseOperation(EXIT_ON_CLOSE);
      
          
        JOptionPane.showMessageDialog(this,"Some text,"Title",JOptionPane.INFORMATION_MESSAGE);
        }
        
    private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {                                         
            int a = 0;
            double c;
            double d;
            double e;
    
          try{  a = Integer.parseInt(ugaoText.getText());}
           catch (Exception f) {
                JOptionPane.showMessageDialog(this, "Samo brojevi dozvoljeni", "GRESKA", JOptionPane.ERROR_MESSAGE);
            }
            if (jComboBox1.getSelectedIndex() == 0) {
                c = Math.sin(a * DefineConstants.PI / 180) * DefineConstants.V / 2.419;
                d = Math.asin(c);
                e = d * 180 / DefineConstants.PI;
                RezultatLabel.setText("Rezultat je: " + String.valueOf(d));
    .
    .
    .
    .

Similar Threads

  1. Enable/Disable Text Field upon checking check box
    By DGates in forum New To Java
    Replies: 2
    Last Post: 01-26-2012, 01:07 AM
  2. Alignment and Text Field size problem of Frame.
    By Javasubbu in forum AWT / Swing
    Replies: 2
    Last Post: 12-02-2011, 04:16 PM
  3. Problem Reading in data from Text Field
    By markious in forum AWT / Swing
    Replies: 2
    Last Post: 02-12-2010, 02:29 AM
  4. Problem with text field patern
    By Prashant.surwade in forum Advanced Java
    Replies: 1
    Last Post: 09-05-2009, 02:45 AM
  5. Replies: 2
    Last Post: 04-28-2008, 10:26 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •