Results 1 to 7 of 7
  1. #1
    dynamix is offline Member
    Join Date
    Jan 2013
    Posts
    5
    Rep Power
    0

    Default How do I put my results in GUI?

    Hi everyone,

    How can I show the results of the console into a GUI ??

    Can anyone help me do that please :( The java project is attached in this post.

    Thanks... .
    Attached Files Attached Files

  2. #2
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,316
    Blog Entries
    1
    Rep Power
    26

    Default Re: How do I put my results in GUI?

    Please provide the details of your problem. Please post the cost here in the forum inside of [code] [/code] tags and not as a zip file. If it's too big to post in the forum, then you are asking us to review too much code. After all, you're asking for free advice, and so it is your responsibility to make it easy as possible for others to be able to help you.

  3. #3
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,316
    Blog Entries
    1
    Rep Power
    26

    Default Re: How do I put my results in GUI?

    And please don't re-post the same question multiple times in the forum. This goes against forum rules which you've agreed to, and is not fair to the volunteers that staff this forum. I've closed your other thread.

  4. #4
    dynamix is offline Member
    Join Date
    Jan 2013
    Posts
    5
    Rep Power
    0

    Default Re: How do I put my results in GUI?

    Sorry for posting it twice. I did it by mistake. Below is my code, which output I want to show in a GUI but I am not being able to do so :S. Here's the code:

    Java Code:
    public class Main {
    
        public static void main(String[] args) {
        		
        Item one = new Item ("Apple",001,001,3.4);
        Item two = new Item ("Nokia",002,002,2.4);
        Item three = new Item ("Blackberry",003,003,2.1);
        Item four = new Item ("Toshiba",004,004,2.2);
        Item five = new Item ("Ericsson",005,005,1.4);
        Customer cone = new Customer ("Fehmi",null,null);
        Customer ctwo = new Customer ("Rrustem",null,null);
        Customer cthree = new Customer ("Sabedin",null,null);
        Customer cfour = new Customer ("Adnan",null,null);
        Customer cfive = new Customer ("Shyqyri",null,null);
        
    	double sum = one.getItemprice(one)+two.getItemprice(two)+three.getItemprice(three)+four.getItemprice(four)+ five.getItemprice(five);
        double tax = sum *0.27 ;
        
        System.out.println ("||| Item : "+one.getItemName(one)+"         ||| Item ID : "+one.getItemid(one)+"     ||| Store Id :  "+one.getstoreId(one)+"      ||| Item Price : "+one.getItemprice(one) + "    ||| Customer name :" + cone.getCustomername(cone));
        System.out.println ("||| Item : "+two.getItemName(two)+"         ||| Item ID : "+two.getItemid(two)+"     ||| Store Id :  "+two.getstoreId(two)+"      ||| Item Price : "+two.getItemprice(two)+ "    ||| Customer name :" + ctwo.getCustomername(ctwo));
        System.out.println ("||| Item : "+three.getItemName(three)+"    ||| Item ID : "+three.getItemid(three)+"     ||| Store Id :  "+three.getstoreId(three)+"      ||| Item Price : "+three.getItemprice(three)+ "    ||| Customer name :" + cthree.getCustomername(cthree));
    
        System.out.println ("||| Item : "+four.getItemName(four)+"       ||| Item ID : "+four.getItemid(four)+"     ||| Store Id :  "+four.getstoreId(four)+"      ||| Item Price : "+four.getItemprice(four)+ "    ||| Customer name :" + cfour.getCustomername(cfour));
        System.out.println ("||| Item : "+five.getItemName(five)+"      ||| Item ID : "+five.getItemid(five)+"     ||| Store Id :  "+five.getstoreId(five)+"      ||| Item Price : "+five.getItemprice(five)+ "    ||| Customer name :" + cfive.getCustomername(cfive));
    
        System.out.println ("");
        
        System.out.println ("||| Total Income Today : "+sum);
        System.out.println ("||| Total Taxes : "+tax);
    
        	 }
       
        }

  5. #5
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,316
    Blog Entries
    1
    Rep Power
    26

    Default Re: How do I put my results in GUI?

    Quote Originally Posted by dynamix View Post
    Sorry for posting it twice. I did it by mistake.
    Please -- the two questions were posted in two completely different sub forums making "by mistake" impossible. But regardless, we know you won't do this again and we appreciate this.

    Below is my code, which output I want to show in a GUI but I am not being able to do so :S. Here's the code:

    Java Code:
    public class Main {
    
        public static void main(String[] args) {
        		
        Item one = new Item ("Apple",001,001,3.4);
        Item two = new Item ("Nokia",002,002,2.4);
        Item three = new Item ("Blackberry",003,003,2.1);
        Item four = new Item ("Toshiba",004,004,2.2);
        Item five = new Item ("Ericsson",005,005,1.4);
        Customer cone = new Customer ("Fehmi",null,null);
        Customer ctwo = new Customer ("Rrustem",null,null);
        Customer cthree = new Customer ("Sabedin",null,null);
        Customer cfour = new Customer ("Adnan",null,null);
        Customer cfive = new Customer ("Shyqyri",null,null);
        
    	double sum = one.getItemprice(one)+two.getItemprice(two)+three.getItemprice(three)+four.getItemprice(four)+ five.getItemprice(five);
        double tax = sum *0.27 ;
        
        System.out.println ("||| Item : "+one.getItemName(one)+"         ||| Item ID : "+one.getItemid(one)+"     ||| Store Id :  "+one.getstoreId(one)+"      ||| Item Price : "+one.getItemprice(one) + "    ||| Customer name :" + cone.getCustomername(cone));
        System.out.println ("||| Item : "+two.getItemName(two)+"         ||| Item ID : "+two.getItemid(two)+"     ||| Store Id :  "+two.getstoreId(two)+"      ||| Item Price : "+two.getItemprice(two)+ "    ||| Customer name :" + ctwo.getCustomername(ctwo));
        System.out.println ("||| Item : "+three.getItemName(three)+"    ||| Item ID : "+three.getItemid(three)+"     ||| Store Id :  "+three.getstoreId(three)+"      ||| Item Price : "+three.getItemprice(three)+ "    ||| Customer name :" + cthree.getCustomername(cthree));
    
        System.out.println ("||| Item : "+four.getItemName(four)+"       ||| Item ID : "+four.getItemid(four)+"     ||| Store Id :  "+four.getstoreId(four)+"      ||| Item Price : "+four.getItemprice(four)+ "    ||| Customer name :" + cfour.getCustomername(cfour));
        System.out.println ("||| Item : "+five.getItemName(five)+"      ||| Item ID : "+five.getItemid(five)+"     ||| Store Id :  "+five.getstoreId(five)+"      ||| Item Price : "+five.getItemprice(five)+ "    ||| Customer name :" + cfive.getCustomername(cfive));
    
        System.out.println ("");
        
        System.out.println ("||| Total Income Today : "+sum);
        System.out.println ("||| Total Taxes : "+tax);
    
        	 }
       
        }
    I don't see any GUI code as yet. Has the instructor given you any guidance or requirements for what you must do? Any idea how you want to create it? Are you familiar with creating Swing GUI's in general? If not, you can get ideas on how to create these by going through the Swing tutorial which you can find here: Using Swing Components.

    Your first step before writing any code will be that you'll need to plan just what type of GUI you'd like to create. It could be as simple as spitting out a few JOptionPanes all the way to creating a complex GUI with multiple nested JPanels that can swap views on command... But again the requirements and your desires will determine everything.

  6. #6
    dynamix is offline Member
    Join Date
    Jan 2013
    Posts
    5
    Rep Power
    0

    Default Re: How do I put my results in GUI?

    Hi fudarable,

    It can be just a table with these columns: Item name, Item ID, store ID, Price, and Customer name. Filled with the information which is shown in code. It can be as simple as possible. It is just that I am not being able to do create it.

    Thank you very much for your recommendations and everything else. I really appreciate it.

  7. #7
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,316
    Blog Entries
    1
    Rep Power
    26

    Default Re: How do I put my results in GUI?

    Myself, if I wanted to display tabular data, I'd create a JTable and display the data that way. If you look at the JTable API, you can find a constructor that accepts two Vectors. I'd create a Vector<String> for my column headings, fill it with my Column heading Strings and use it as the second parameter, and then create a Vector of Vectors, to hold the data and use that as the first parameter for the constructor. You would create a Vector<Object> for each row, fill it with each row's data, and then add that to the data Vector<Vector>, and again use it as the JTable constructor's first parameter. You could then display the JTable in a JScrollPane, and that in a JOptionPane for the simplest GUI.

Similar Threads

  1. How do I put my results in GUI?
    By dynamix in forum SWT / JFace
    Replies: 1
    Last Post: 03-17-2013, 03:39 PM
  2. Can't Get Multiple Results...
    By Atia of the julii in forum New To Java
    Replies: 1
    Last Post: 01-11-2012, 10:04 AM
  3. Sin() Wrong Results
    By MemoNick in forum New To Java
    Replies: 1
    Last Post: 12-07-2011, 02:21 PM
  4. wrong results with recursion
    By sara12345 in forum New To Java
    Replies: 0
    Last Post: 04-12-2010, 04:49 PM
  5. Sometimes get the right results sometimes dont
    By Battlefeldt in forum New To Java
    Replies: 0
    Last Post: 12-18-2009, 01:03 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
  •