We help IT Professionals succeed at work.

Saving "output from dialog box and jpg image" as a jpg image.

aboytes
aboytes asked
on
244 Views
Last Modified: 2010-03-31
I've asked this before but I haven't sucessfully accomplished this. Shown in the code below: When the code gets to this else if it asks to enter data and once entered it shows the output keyed in but I want that message to be saved WITH the jpg in label5 under Product status1.jpg. So when I open "Product status1.jpg" I want the jpg set in label 5 and the message inputted in the JOptionPane.showInputDialog(label5, "Enter data: ") to be together in that file. Is this possible? And if yes, can someone show me how to do this with code. Thank you if there is any questions feel free to ask.

    JLabel label5 = new JLabel("Completed!");
    label5.setIcon(new ImageIcon("Productdone.jpg"));

     else if (num == 242670001 && number == 10 ) {
       String message = JOptionPane.showInputDialog(label5, "Enter data: ");
       JOptionPane.showMessageDialog(label5, message);

             JOptionPane pane = new JOptionPane(label5,
               OptionPane.INFORMATION_MESSAGE);
               pane.createDialog(null, "Complete");
               pane.setVisible(true);
               saveComponentAsImage(pane, "Product status1.jpg");
Comment
Watch Question

Mick BarryJava Developer
CERTIFIED EXPERT
Top Expert 2010

Commented:
try:

 JOptionPane pane = new JOptionPane(message,
               OptionPane.INFORMATION_MESSAGE);
Mick BarryJava Developer
CERTIFIED EXPERT
Top Expert 2010

Commented:
and to add the icon

 JOptionPane pane = new JOptionPane(message,
               OptionPane.INFORMATION_MESSAGE, label5.getIcon());
Mick BarryJava Developer
CERTIFIED EXPERT
Top Expert 2010

Commented:
make sure the dialog isn't modal
and if that doesn't work then use a frame instead of a dialog

Author

Commented:
When I put this it gives me a "cannot resolve symbol" error. It shows it pointing to the new in the   JOptionPane pane = new JOptionPane(message. Any ideas why it's saying that?
     
else if (num == 242670001 && number == 10 ) {
            String message = JOptionPane.showInputDialog(label5, "Enter data: ");
            JOptionPane.showMessageDialog(label5, message);

              JOptionPane pane = new JOptionPane(message,
                 JOptionPane.INFORMATION_MESSAGE, label5.getIcon());
               pane.createDialog(null, "Complete");
               pane.setVisible(true);
               saveComponentAsImage(pane, "Product status1.jpg");
Java Developer
CERTIFIED EXPERT
Top Expert 2010
Commented:
This one is on us!
(Get your first solution completely free - no credit card required)
UNLOCK SOLUTION

Author

Commented:
ok the data entered is saving which is one part of what I am looking for but the jpg set to label5 is not saving with that information. any clues on why the jpg isn't saving?
Mick BarryJava Developer
CERTIFIED EXPERT
Top Expert 2010

Commented:
do you mean saving seperately, or is it not showing up in the dialog?

Author

Commented:
It's cause I wanted the output from the dialog box to save with the jpg picture. Right now the output from the dialog box is saving but it's not saving with the jpg in label5. Does that make sense? sorry it's kind of hard to explain
Mick BarryJava Developer
CERTIFIED EXPERT
Top Expert 2010

Commented:
so what are you getting exactly? Is it a jpg of the doialog including the productdone image?

Author

Commented:
As of right now I'm getting the output of the question "Enter data: " saved as a jpg. Which is one thing that I want but it's not saving the jpg "Productdone.jpg". I was wondering if this saved output, from the question "Enter data:", could include the jpg that is set to label5. Which  label5 has the jpg "Productdone.jpg" set to it? Is this possible?
Mick BarryJava Developer
CERTIFIED EXPERT
Top Expert 2010

Commented:
i would have thought that image would be included in the saved image.
Is it appearing in the dialog when it is displayed on the screen?

Author

Commented:
No all that is showing is the entered data, no picture. That is what is odd to me because on the showdialog it has label5 in the command but it's not showing or saving it. Any clues why it's not showing?

else if (num == 242670001 && number == 10 ) {
           String message = JOptionPane.showInputDialog(label5, "Enter data: ");
           JOptionPane.showMessageDialog(label5, message);

              JOptionPane pane = new JOptionPane(message,
                 JOptionPane.INFORMATION_MESSAGE, label5.getIcon());
               pane.createDialog(null, "Complete");
               pane.setVisible(true);
               saveComponentAsImage(pane, "Product status1.jpg");
Mick BarryJava Developer
CERTIFIED EXPERT
Top Expert 2010

Commented:
> but it's not showing

do you mean it does not appear on the dialog
if so check that the image is loading ok

Author

Commented:
Thank you for your time and patient. I have two quick questions is there a way to move the text from the side to be underneath the picture and is there a way to make the text larger?
Mick BarryJava Developer
CERTIFIED EXPERT
Top Expert 2010

Commented:
think you'd need to construct the panel yourself to do that, ie. not use JOptionPane.
Unlock the solution to this question.
Join our community and discover your potential

Experts Exchange is the only place where you can interact directly with leading experts in the technology field. Become a member today and access the collective knowledge of thousands of technology experts.

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

OR

Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.