Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 6 of 6

Thread: Java project

  1. #1
    Junior Member
    Join Date
    Jan 2010
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Java project

    A text field, in which a row of numbers can be written. Next to it a button, with the help of which the written information can be saved as a file //to show where the file will be saved and its name//
    Another field for searching in the file. And the found result, if it coincides, to be saved in new file. Example:
    We write the row 12982732937 // save it in file.
    We are searching 7, if there is coincidence, we save the result in another file. If there is no message

    Thanks you.


  2. #2
    mmm.. coffee JavaPF's Avatar
    Join Date
    May 2008
    Location
    United Kingdom
    Posts
    3,336
    My Mood
    Mellow
    Thanks
    258
    Thanked 294 Times in 227 Posts
    Blog Entries
    4

    Default Re: Java project

    Hello monika88a.

    Welcome to the Java Programming Forums.

    Have you started to code any of this yet? You will need to use Java Swing for the text field and button..
    Please use [highlight=Java] code [/highlight] tags when posting your code.
    Forum Tip: Add to peoples reputation by clicking the button on their useful posts.

  3. #3
    Junior Member
    Join Date
    Jan 2010
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: Java project

    Quote Originally Posted by JavaPF View Post
    Hello monika88a.

    Welcome to the Java Programming Forums.

    Have you started to code any of this yet? You will need to use Java Swing for the text field and button..
    Do you know how make a code?

  4. #4
    Super Moderator helloworld922's Avatar
    Join Date
    Jun 2009
    Posts
    2,895
    Thanks
    23
    Thanked 619 Times in 561 Posts
    Blog Entries
    18

    Default Re: Java project

    Code is what you right to tell the computer what to do. It looks something like this:

    public static void main(String[] args)
    {
         System.out.println("Hello world!");
    }

    Obviously, your Java code will look different because it must fulfill different functionality. I would recommend reading Learning the Java Language by Sun (the makers of Java, err at least the current maintainers of it). You may also want to take a look at How to Use Text Fields (also written by Sun).

  5. #5
    Junior Member
    Join Date
    Jan 2010
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: Java project

    Quote Originally Posted by JavaPF View Post
    Hello monika88a.

    Welcome to the Java Programming Forums.

    Have you started to code any of this yet? You will need to use Java Swing for the text field and button..
    yes here is code forim text field :
    void jTextFiled1_actionPerformed(ActionEven e) {
     
     
    }



    and save button:

    void save_actionPerformed(ActionEven e) {
     
     
    }
    I dont know hot to connect save button to save text in texfiled... please help from first part of condition
    Last edited by helloworld922; January 20th, 2010 at 12:02 AM.

  6. #6
    Super Moderator helloworld922's Avatar
    Join Date
    Jun 2009
    Posts
    2,895
    Thanks
    23
    Thanked 619 Times in 561 Posts
    Blog Entries
    18

    Default Re: Java project

    What I would do is create instance variables for a JButton and JTextField in your main application GUI class. Then, add your application as the ActionListener for the JButton. Everytime the JButton is clicked, it will send an ActionEvent to your actionPerformed method (you must implement this method

    public class GUI implements ActionListener
    {
         // a simple class that implements an ActionListener
         public void actionPerformed(ActionEvent e)
         {
              // any code you want whenever this method is triggered
              if (e.getAction.equals("Add"))
              {
                   // received an action labeled "Add". Stuff to handle this action is here
              }
         }
    }

    By default, JButton sends out the action that matches it's displaying text, but this can be changed using the setActionCommand(String action) method. To add your program as an action listener to a JButton (or most other swing components):

    someJButton.add(someActionListener);

    Practically, this should be somewhere inside of your GUI initializer method, so it can look something like this:
    someJButton.add(this);

    Because you don't need to keep track of the text everytime it changes and only when the button is pressed, you can poll the text only when the action event is fired. To get the text in the JTextField:

    someJTextField.getText();

    hopefully that helps you with the swing portion of your program.

Similar Threads

  1. Programmer for a Java based game project
    By Takkun in forum Project Collaboration
    Replies: 4
    Last Post: June 14th, 2010, 05:47 PM
  2. Short java project
    By derky in forum Paid Java Projects
    Replies: 3
    Last Post: October 28th, 2009, 09:48 PM
  3. Java stock project help
    By lotus in forum File I/O & Other I/O Streams
    Replies: 2
    Last Post: July 12th, 2009, 04:16 AM
  4. Best way to architect my java and XML project...
    By samiles in forum File I/O & Other I/O Streams
    Replies: 6
    Last Post: June 16th, 2009, 08:43 AM
  5. Adventure ride project
    By Ciwan in forum Java Theory & Questions
    Replies: 12
    Last Post: February 15th, 2009, 12:08 PM