Results 1 to 3 of 3
  1. #1
    Cubba27 is offline Member
    Join Date
    Nov 2009
    Rep Power

    Exclamation Methods, JOptionPane, Return Values

    Hey all,

    Basically i've written a program that uses 4 methods which are invoked by the main method, these methods are getInt, getDoub, getString and outputDialog. the first 3 methods use input JOptionPane and then return the values of type int, double and string. The fourth method is where i'm having difficulty, i want to display the returned values in a JOptionPane outputDialog.

    How can i draw the returned values from the previous three methods and display them within the JOptionPane?

    Thanks =)

  2. #2
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Blog Entries
    Rep Power


    Java Code:
    import javax.swing.JOptionPane;
    public class Fu2 {
       public static void main(String[] args) {
          int myInt = 5;
          double myDouble = 3.0;
          String foo = "myInt = " + myInt + "\n" + "myDouble = " + myDouble;
          JOptionPane.showMessageDialog(null, foo);

  3. #3
    hardwired's Avatar
    hardwired is offline Senior Member
    Join Date
    Jul 2007
    Rep Power


    Put each one in a JLabel and add the labels to a JPanel, add the panel to the JOptionPane.
    Java Code:
    JLabel label1 = new JLabel("int = " + usersIntValue);
    JPanel panel = new JPanel(new GridLayout(0,1));
    JOptionPane.showMessageDialog(null, panel, "title",

Similar Threads

  1. How do i show all the values in one window(JOptionPane)??
    By Antonioj1015 in forum Advanced Java
    Replies: 1
    Last Post: 11-25-2009, 04:17 PM
  2. design? return output within methods
    By jon80 in forum New To Java
    Replies: 1
    Last Post: 06-08-2009, 07:22 AM
  3. Using functions that return values?
    By Megapixelz in forum New To Java
    Replies: 1
    Last Post: 04-30-2008, 04:07 AM
  4. how to return values from hashmap
    By oregon in forum New To Java
    Replies: 2
    Last Post: 08-01-2007, 04:56 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