Results 1 to 3 of 3
Like Tree1Likes
  • 1 Post By Rylogy

Thread: A simple question

  1. #1
    Rylogy is offline Member
    Join Date
    Feb 2012
    Rep Power

    Question A simple question

    Hi. I need someone to point me in the right direction. I have about 70+ lines of code under a button; I was wondering how can I make it so that the code is elsewhere, but when I press the button it calls that action(that way I don't have to repeat the code to other actions). Any examples/suggestions? Thanks.
    Java Code:
     private void button1ActionPerformed(java.awt.event.ActionEvent evt) {                                        
            xystr = textField1.toString();
            XorY = xystr.charAt(0);
            angle = Double.parseDouble(textField2.getText());
            xy = Double.parseDouble(textField3.getText().substring(3));
            result.setText("Length = " + textField3.getText().substring(3) + " with ");
            if ("x".equals(textField1.getText())) {

  2. #2
    DarrylBurke's Avatar
    DarrylBurke is offline Forum Police
    Join Date
    Sep 2008
    Madgaon, Goa, India
    Rep Power

    Default Re: A simple question

    That's already a method that's being called from the ActionListener's actionPerformed(...)

    Drop the visual designer that spewed out that code and learn to program a GUI yourself: Trail: Creating a GUI With JFC/Swing (The Java™ Tutorials)

    Moving this thread to AWT/Swing

    If you're forever cleaning cobwebs, it's time to get rid of the spiders.

  3. #3
    Rylogy is offline Member
    Join Date
    Feb 2012
    Rep Power

    Default Re: A simple question

    I'll gladly take your advice. Thanks db
    DarrylBurke likes this.

Similar Threads

  1. A simple question
    By chris.bos in forum New To Java
    Replies: 11
    Last Post: 12-02-2011, 05:37 PM
  2. Simple Question
    By new2oojava in forum New To Java
    Replies: 1
    Last Post: 09-29-2011, 07:14 AM
  3. Please help. Simple question
    By owencain in forum New To Java
    Replies: 14
    Last Post: 06-16-2011, 01:07 AM
  4. very simple Question
    By arsenal4ever_11 in forum NetBeans
    Replies: 2
    Last Post: 05-27-2010, 08:51 PM
  5. some simple question?
    By jperson in forum New To Java
    Replies: 4
    Last Post: 05-03-2010, 05:32 PM

Posting Permissions

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