Page 1 of 2 12 LastLast
Results 1 to 20 of 30
  1. #1
    moostico246 Guest

    Default making a monogram swing

    make a Swing version of the Monogram program::::


    /* This program finds a persons Monogram
    Programmer: your name
    Date: March 31, 2009

    */


    import java.util.Scanner;

    public class Monogram {
    public static void main (String[]args) {
    //declare vars
    String first, middle, last, monogram;
    Scanner input = new Scanner (System.in);

    System.out.println("Enter your first name: ");
    first = input.nextLine();
    System.out.println("Enter your middle initial: ");
    middle = input.nextLine();
    System.out.println("Enter your last name: ");
    last = input.nextLine();
    input.close();

    monogram =String.valueOf(first.charAt(0)).toLowerCase()+Str ing.valueOf(middle.charAt(0)).toUpperCase()+String .valueOf(last.charAt(0)).toLowerCase();
    System.out.println("your monogram is "+monogram );

    }
    }

  2. #2
    moostico246 Guest

    Default

    can someone helpppppp

  3. #3
    Eranga's Avatar
    Eranga is offline Moderator
    Join Date
    Jul 2007
    Location
    Colombo, Sri Lanka
    Posts
    11,372
    Blog Entries
    1
    Rep Power
    20

  4. #4
    moostico246 Guest

    Default

    well ok, how do you make a monogram using swing?

    make a Swing version of the Monogram program?


    /* This program finds a persons Monogram
    Programmer: your name
    Date: March 31, 2009

    */


    import java.util.Scanner;

    public class Monogram {
    public static void main (String[]args) {
    //declare vars
    String first, middle, last, monogram;
    Scanner input = new Scanner (System.in);

    System.out.println("Enter your first name: ");
    first = input.nextLine();
    System.out.println("Enter your middle initial: ");
    middle = input.nextLine();
    System.out.println("Enter your last name: ");
    last = input.nextLine();
    input.close();

    monogram =String.valueOf(first.charAt(0)).toLowerCase()+Str ing.valueOf(middle.charAt(0)).toUpperCase()+String .valueOf(last.charAt(0)).toLowerCase();
    System.out.println("your monogram is "+monogram );

    }
    }

  5. #5
    Eranga's Avatar
    Eranga is offline Moderator
    Join Date
    Jul 2007
    Location
    Colombo, Sri Lanka
    Posts
    11,372
    Blog Entries
    1
    Rep Power
    20

    Default

    Can you explain what the logic in your game is? I'm not clear what's it.

    And also what's you talking about Swing? Do you want to create a UI for that application?

  6. #6
    moostico246 Guest

    Default

    1st: its not a game, its only needed for practice.2nd: swing is UI, i think, im not da expert here,,,and 3rd: can u help?

  7. #7
    Eranga's Avatar
    Eranga is offline Moderator
    Join Date
    Jul 2007
    Location
    Colombo, Sri Lanka
    Posts
    11,372
    Blog Entries
    1
    Rep Power
    20

    Default

    Yes I can help you. But you must provide complete details about what you are doing.

    Basically you want to get the three first letters of user name, first, middle and last. You have done something above in your code. Fine, what happen when you run the code.

    Swing is the Java API use for UI developments in Java. And AWT too. Seems you don't have any idea about that.

  8. #8
    moostico246 Guest

    Default

    yes good now wer gettin somewhere..ok so when i run the code it asks for the first name, then the middle initial, and then the last name, then it says your monogram is xxx...ok and your right im not into computers lke dat, im a biology major, this class is juss an elective, so i really appreciate your help if we can juss get through dis now.

  9. #9
    moostico246 Guest

    Default

    can some1 help here

  10. #10
    Eranga's Avatar
    Eranga is offline Moderator
    Join Date
    Jul 2007
    Location
    Colombo, Sri Lanka
    Posts
    11,372
    Blog Entries
    1
    Rep Power
    20

    Default

    Ok, if you not much familiar with Java and stuff please ask your question more clearly. I can help you, and others too.

    At the time, forget about the Swing/UI and stuff. Answer the following.

    1. Did your code done the same thing you are expecting?
    2. If not what's the different between your exact result and the this Java code result?

  11. #11
    moostico246 Guest

    Default

    1.yes
    2.well im trying to convert my monogram file to file that has swing, meaning i have to use all pop-up dialogs; no printing to the screen or reading from it.

  12. #12
    Eranga's Avatar
    Eranga is offline Moderator
    Join Date
    Jul 2007
    Location
    Colombo, Sri Lanka
    Posts
    11,372
    Blog Entries
    1
    Rep Power
    20

    Default

    Fine, so the code processing is ok. Now you have to work on with the UI part.

    To collect information from the user you have to use JOptionPane, like a message box and there is a field for user input.

    All the UI components such as Jutton, JDialog and so on are based on Swing API, which is the standard API available in JDK releases.

    Look at the following code segment. I've change your code in order to handle the user input through the message box.

    Java Code:
    import java.util.Scanner;
    import javax.swing.JOptionPane;
    
    public class Monogram {
    
        public static void main (String[]args) {
    
            //declare vars
            String first, middle, last, monogram;
            Scanner input = new Scanner (System.in);
    
            //System.out.println("Enter your first name: ");
            first = JOptionPane.showInputDialog(null, "Enter your first name.");
    
            System.out.println("Enter your middle initial: ");
            middle = input.nextLine();
    
            System.out.println("Enter your last name: ");
            last = input.nextLine();
    
            //input.close();
    
            monogram = String.valueOf(first.charAt(0)).toLowerCase() +
                    String.valueOf(middle.charAt(0)).toUpperCase() +
                    String .valueOf(last.charAt(0)).toLowerCase();
    
            System.out.println("your monogram is "+monogram );
    
        }
    }

  13. #13
    DarrylBurke's Avatar
    DarrylBurke is offline Member
    Join Date
    Sep 2008
    Location
    Madgaon, Goa, India
    Posts
    11,192
    Rep Power
    19

    Default

    Why did you do moostico246's homework? Like a stray dog fed table scraps, it'll be back for more. I refuse to believe that this assignment was given without first imparting knowledge on how to approach it, yet the memeber appears totally blank on the matter, a sure sign of total neglect of studies.

    Didn't you notice the feeble attempt on the Quiz Time thread to disguise this homework as a "challenge"?

    Liars and cheaters shouldn't be helped at all. They deserve to fail.

    db

    edit This incompetent student also posted on the Sun forum where he/she/it started being rude and abusive when called on the lie that "this is not homework" to the extent that several of its abusive posts were blocked.
    New To Java - making a monogram swing [Locked]
    Last edited by DarrylBurke; 04-06-2009 at 07:56 AM.

  14. #14
    Eranga's Avatar
    Eranga is offline Moderator
    Join Date
    Jul 2007
    Location
    Colombo, Sri Lanka
    Posts
    11,372
    Blog Entries
    1
    Rep Power
    20

    Default

    Yes db, I agreed with you. I know that I've done his homework, from very first post I found that. But did you go through all the post made by him here in the forum? Just try to give influence that I'm aware what's going on here, I mean my comments are useless. So what I try to do first of all is help him to do this workout. Actually I didn't know about cross-posting, I'm not registered on Suns' forum too.

    After finishing his job on this I'm looking to advice what he's done for me. As far as I feel he's trying to insult on my comments. (That's what I feel, sorry if in any other case). And what happen is at the end, he's on my ignore list.


  15. #15
    moostico246 Guest

    Default

    thanx buddy

  16. #16
    Eranga's Avatar
    Eranga is offline Moderator
    Join Date
    Jul 2007
    Location
    Colombo, Sri Lanka
    Posts
    11,372
    Blog Entries
    1
    Rep Power
    20

  17. #17
    moostico246 Guest

    Default

    hey the file u did, wasnt exactly wat i needed, can u still help me if i show u that im actually doin somthin, im workin hard here, and java is not my thing..but ur great

  18. #18
    moostico246 Guest

    Default

    can someone help,,i got it so far, but that last part where the monogram is given out doesnt look right..

    //System.out.println("your monogram is "+monogram );
    monogram = JOptionPane.showInputDialog(null, "your monogram is "+monogram);


    import java.util.Scanner;
    import javax.swing.JOptionPane;

    public class Monogram {

    public static void main (String[]args) {

    //declare vars
    String first, middle, last, monogram;
    Scanner input = new Scanner (System.in);

    //System.out.println("Enter your first name: ");
    first = JOptionPane.showInputDialog(null, "Enter your first name.");

    //System.out.println("Enter your middle initial: ");
    middle = JOptionPane.showInputDialog(null, "Enter your middle initial." );

    //System.out.println("Enter your last name: ");
    last = JOptionPane.showInputDialog(null, "Enter your last name");

    //input.close();

    monogram = String.valueOf(first.charAt(0)).toLowerCase() +
    String.valueOf(middle.charAt(0)).toUpperCase() +
    String .valueOf(last.charAt(0)).toLowerCase();

    //System.out.println("your monogram is "+monogram );
    monogram = JOptionPane.showInputDialog(null, "your monogram is "+monogram);


    }
    }

  19. #19
    mtyoung is offline Senior Member
    Join Date
    Dec 2008
    Location
    Hong Kong
    Posts
    473
    Rep Power
    6

    Default

    JOptionPane (Java Platform SE 6)
    you will find which method you should call, and what the input parameters are.

    beware the return type of the method...

    and ... will you handle cases that user cancel to input some of those names?
    Last edited by mtyoung; 04-06-2009 at 11:29 AM.

  20. #20
    termolitov's Avatar
    termolitov is offline Member
    Join Date
    Apr 2009
    Location
    Virgin Islands
    Posts
    1
    Rep Power
    0

    Default Вы все здесь не надолго...

    Привет.Все
    копаются,что-то
    трут.
    И ведь ни кто не задумывается,
    секунды улетят
    и смерть не попросит себя упрашивать
    зайти.
    Не кто не предвидит
    что случится с тобой через 3 часа.
    Поэтому надо упиваться жизнью,а не штаны
    протирать
    за клавой !!!
    Может предпологаете я незнаю?..

Page 1 of 2 12 LastLast

Similar Threads

  1. Making a count..
    By Samgetsmoney in forum New To Java
    Replies: 15
    Last Post: 02-18-2009, 01:44 PM
  2. Help making table
    By jls7168 in forum New To Java
    Replies: 2
    Last Post: 01-26-2009, 03:53 PM
  3. Monogram program
    By mistah in forum New To Java
    Replies: 8
    Last Post: 12-24-2008, 04:57 AM
  4. code for making a java swing program a demo verson
    By fakhruddin in forum AWT / Swing
    Replies: 1
    Last Post: 11-27-2007, 08:54 PM
  5. Making a session in swing
    By sandor in forum AWT / Swing
    Replies: 3
    Last Post: 04-22-2007, 10:58 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
  •