Results 1 to 4 of 4
Like Tree3Likes
  • 2 Post By Fubarable
  • 1 Post By Dcalladi

Thread: JOptionPane wont show up.

  1. #1
    Dcalladi is offline Member
    Join Date
    Oct 2011
    Posts
    27
    Rep Power
    0

    Default JOptionPane wont show up.

    i have a main class which is a JFrame it call as class called priceCheck()

    Java Code:
    public class priceCheck {
    
        public priceCheck(String barcode) {
            try {
                DriverManager.registerDriver(new com.mysql.jdbc.Driver());
                Connection conn = DriverManager.getConnection("jdbc:mysql://samp.inf.brad.ac.uk/dcalladi", "dcalladi", "Dannys21");
                ResultSet rs = conn.createStatement().executeQuery("select Name, FORMAT(Cost,2),Stock_Level where Barcode = " + barcode + "");
                while (rs.next()){
                    JOptionPane.showMessageDialog(null, "Name : "+rs.getString(1)+" Cost : "+rs.getString(2)+" Current Stock "+rs.getString(3)+"");
                    conn.close();
                }
            } catch (Exception ex) {
            } 
        }
    }
    obviously i can't have a panel or jframe for the first parameter for the JOptionPane so i heard you can have null and it should still appear but for some reason this dialog box isn't appearing. and i can't think of any reason why it isn't i have tried a System.out.println and it is getting to the class

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

    Default Re: JOptionPane wont show up.

    You probably wouldn't ever consider driving a car with a blindfold on, right? Likewise, don't ignore exceptions with an empty catch block unless you simply don't want to know why your code's not working. At least print a stack trace.
    doWhile and DarrylBurke like this.

  3. #3
    Dcalladi is offline Member
    Join Date
    Oct 2011
    Posts
    27
    Rep Power
    0

    Default Re: JOptionPane wont show up.

    Fixed my own problem got a bit of code blindness with the catch and the sql statement for got to enter into the statement the table im getting the results from silly me
    Fubarable likes this.

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

    Default Re: JOptionPane wont show up.

    Thanks for updating us on your problem and its resolution.

    Best of luck with your coding!

Similar Threads

  1. Applet Wont Show Supposed Output, Please Help
    By bdmchamp in forum Java Applets
    Replies: 2
    Last Post: 06-29-2011, 02:54 PM
  2. Applet Wont Show Supposed Output, Please Help!!!!
    By bdmchamp in forum New To Java
    Replies: 7
    Last Post: 06-27-2011, 12:43 AM
  3. Graphics wont show up(paintComponent)
    By TheBreadCat in forum New To Java
    Replies: 3
    Last Post: 02-13-2011, 07:00 PM
  4. wont show entire JLabel
    By Billaguana in forum AWT / Swing
    Replies: 6
    Last Post: 02-03-2011, 11:18 PM
  5. How do i show all the values in one window(JOptionPane)??
    By Antonioj1015 in forum Advanced Java
    Replies: 1
    Last Post: 11-25-2009, 05:17 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
  •