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