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 2 of 2

Thread: Help with JOptionPane.showMessageDialog(text does not fit correctly)

  1. #1
    Junior Member
    Join Date
    Jul 2011
    Posts
    1
    My Mood
    Starving
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Help with JOptionPane.showMessageDialog(text does not fit correctly)

    I am having a Problem with my output not fitting correctly. Is there a way to resize a JOptionPane.showMessageDialog window? Or do I have to use a different method to show my output? If you need to see the code for my GUI let me know and I can post it as well.

      private void checkRecActionPerformed(java.awt.event.ActionEvent evt) {                                         
             try {
                Connection conn= DriverManager.getConnection("jdbc:mysql://127.0.0.1/abccomp", "root", "root");
                Statement stmt = conn.createStatement();
                ResultSet rs;
     
                rs = stmt.executeQuery("SELECT * FROM orders;");
     
                String createdBy;
                String date;
                int orderNum;
                int numNotebooks;
                int numPencils;
                int numPens;
                int numPaper;
                int numStickers;
                int numPaperClips;
                int numHighlighters;
                int numOfficeChairs;
                int numMarkers;
                String recOrd = "";
     
                while ( rs.next() )
                {
                    createdBy = rs.getString("createdby");
    		date = rs.getString("DateCreated");
                    orderNum = rs.getInt("ordernum");
                    numNotebooks = rs.getInt("number_of_Notebooks");
                    numPencils = rs.getInt("number_of_Pencils");
                    numPaper = rs.getInt("number_of_Paper");
                    numStickers = rs.getInt("number_of_Stickers");
                    numPaperClips = rs.getInt("number_of_PaperClips");
                    numHighlighters = rs.getInt("number_of_Highlighters");
                    numOfficeChairs = rs.getInt("number_of_OfficeChairs");
                    numMarkers = rs.getInt("number_of_Markers");
     
                    recOrd += "Order number:" + orderNum + "\nDate:" + date
                     + "\nOrder created by:" + createdBy + "Order Details:\n"
                     + numNotebooks + ":Notebooks" + numPencils + ":Pencils"
                     + numPaper + ":Paper" + numStickers + ":Stickers"
                     + numPaperClips + ":Paper Clips" + numHighlighters
                     + ":Highlighters" + numOfficeChairs + ":Office Chairs" 
                     + numMarkers + ":Markers\n\n";
                }
     
                JOptionPane.showMessageDialog(null, recOrd, "Recent Orders",JOptionPane.PLAIN_MESSAGE);
     
                conn.close();
                }
               catch (Exception e) {
                System.err.println("Got an exception! ");
                System.err.println(e.getMessage());
                }
     
     
        }                                        
     
        private void checkInvActionPerformed(java.awt.event.ActionEvent evt) {                                         
            try {
                Connection conn= DriverManager.getConnection("jdbc:mysql://127.0.0.1/abccomp", "root", "root");
                Statement stmt = conn.createStatement();
                ResultSet rs;
     
                rs = stmt.executeQuery("SELECT * FROM inventory;");
     
                int number;
                String product;
                String inv = "";
     
                while ( rs.next() )
                {
                    number = rs.getInt("number in stock");
    		product = rs.getString("product");
                    inv += product +":"+ number +"\n";
                }
     
                JOptionPane.showMessageDialog(null, "Inventory in stock\n" + inv, "Inventory in stock", JOptionPane.PLAIN_MESSAGE);
     
                conn.close();
              } catch (Exception e) {
                System.err.println("Got an exception! ");
                System.err.println(e.getMessage());
            }
        }

    Thanks in advance,
    Chris


  2. #2
    Forum old-timer
    Join Date
    Nov 2008
    Location
    Faversham, Kent, UK
    Posts
    472
    My Mood
    Mellow
    Thanks
    4
    Thanked 58 Times in 54 Posts

    Default Re: Help with JOptionPane.showMessageDialog(text does not fit correctly)

    Please explain what you mean by the output 'not fitting correctly'. I find you can put pretty much any amount of information into the message and it will all get displayed, although the message box may end up bigger than the screen, which isn't helpful...

    Maybe if you post up an SSCCE, we can check it out.

Similar Threads

  1. I can't get this loop to work correctly
    By Nismoz3255 in forum Loops & Control Statements
    Replies: 1
    Last Post: February 27th, 2011, 04:20 PM
  2. Replies: 3
    Last Post: November 9th, 2010, 01:19 PM
  3. showMessageDialog is not showing!
    By jonathan920 in forum What's Wrong With My Code?
    Replies: 3
    Last Post: October 27th, 2010, 04:14 AM
  4. "showMessageDialog" method in swing package
    By Delmi in forum Java Theory & Questions
    Replies: 1
    Last Post: May 13th, 2010, 02:52 PM
  5. Code not printing correctly
    By Movies32 in forum What's Wrong With My Code?
    Replies: 5
    Last Post: February 6th, 2010, 03:59 PM