Results 1 to 6 of 6
  1. #1
    IYIaster is offline Member
    Join Date
    Jul 2009
    Posts
    46
    Rep Power
    0

    Default JOptionPane withour parent frame.

    Is there a way to get a JoptionPane to work without having a parent frame. I java an application that runs as a service that has no GUI but, if there is certain errors I want it to show a jOptionPane. This didn't work.


    Java Code:
    JOptionPane.showMessageDialog(null, "Please insert a blank disc and reburn last backup.",
    "Disc Error", JOptionPane.ERROR_MESSAGE);

  2. #2
    iluxa is offline Senior Member
    Join Date
    Mar 2010
    Posts
    266
    Rep Power
    5

    Default

    how exactly did it not work? did it not show at all or threw an exception? it could actually be impossible to do if you have defined no Frames at all, but you should be able to do something like

    Java Code:
    JOptionPane.showMessageDialog(new JFrame(), "Please insert a blank disc and reburn last backup.",
    "Disc Error", JOptionPane.ERROR_MESSAGE);

  3. #3
    IYIaster is offline Member
    Join Date
    Jul 2009
    Posts
    46
    Rep Power
    0

    Default

    Quote Originally Posted by iluxa View Post
    how exactly did it not work? did it not show at all or threw an exception? it could actually be impossible to do if you have defined no Frames at all, but you should be able to do something like

    Java Code:
    JOptionPane.showMessageDialog(new JFrame(), "Please insert a blank disc and reburn last backup.",
    "Disc Error", JOptionPane.ERROR_MESSAGE);
    Doing it this way didn't work either. Running it from a command line the jOptionPane showed up. But, running it as a service it didn't.

  4. #4
    iluxa is offline Senior Member
    Join Date
    Mar 2010
    Posts
    266
    Rep Power
    5

    Default

    it could be that the service is not allowed to generate any UI... in which case you're basically screwed. One option is to do try some kind of native message box, and run it from System.getRuntime().exec()...

  5. #5
    j2me64's Avatar
    j2me64 is offline Senior Member
    Join Date
    Sep 2009
    Location
    Zurich, Switzerland
    Posts
    962
    Rep Power
    5

    Default

    Quote Originally Posted by IYIaster View Post
    Is there a way to get a JoptionPane to work without having a parent frame.

    i tried your code within a main method without frame and the dialog was shown. there are machines without graphical drivers installed on it, so you can't generate no guis on these machines. that could be the problem.

  6. #6
    IYIaster is offline Member
    Join Date
    Jul 2009
    Posts
    46
    Rep Power
    0

    Default

    Quote Originally Posted by j2me64 View Post
    i tried your code within a main method without frame and the dialog was shown. there are machines without graphical drivers installed on it, so you can't generate no guis on these machines. that could be the problem.
    Right, I ran the code also and it works fine when you just run the jar file. But, running the jar file as a service using java service wrapper it doesn't pop up at all.

Similar Threads

  1. Submit values to a parent page
    By carag in forum New To Java
    Replies: 1
    Last Post: 12-11-2009, 12:33 AM
  2. Replies: 7
    Last Post: 11-02-2009, 06:31 PM
  3. How show a popWindow that have JPanel like parent
    By Wolverine in forum AWT / Swing
    Replies: 4
    Last Post: 05-23-2009, 08:59 AM
  4. Parent & Child window issues......
    By jithan in forum New To Java
    Replies: 2
    Last Post: 09-20-2008, 09:21 AM
  5. disable parent window
    By ismailsaleh in forum AWT / Swing
    Replies: 1
    Last Post: 01-07-2008, 11:15 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
  •