How to display image using from open dialog box?

I've developed a program that can display image by named the file that I want to display in my program.
But how can I display an image from an Open Dialog Box?
I attch here with my program.
import java.io.*;
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import javax.swing.event.*;
import javax.swing.filechooser.*;
public class SuDisplayTool6 extends JFrame implements InternalFrameListener,ActionListener
JTextArea display1;
JDesktopPane desktop;
JInternalFrame displayWindow;
JInternalFrame listenedToWindow;
static final String SHOW = "Show Image";
static final int desktopWidth = 800;
static final int desktopHeight = 600;
private static final int kControlX = 88 ;
private DrawingPanel panel;
public SuDisplayTool6(String title)
super("Internal Frame");
desktop = new JDesktopPane();
desktop.putClientProperty("JDesktopPane.dragMode","outline");
desktop.setPreferredSize(new Dimension(desktopWidth, desktopHeight));
setContentPane(desktop);
addMenu();
createDisplayWindow();
desktop.add(displayWindow);
Dimension displaySize = displayWindow.getSize();
displayWindow.setSize(desktopWidth, displaySize.height);
protected void createDisplayWindow()
JButton b1 = new JButton("Show Image");
b1.setActionCommand(SHOW);
b1.addActionListener(this);
display1 = new JTextArea(3,30);
display1.setEditable(false);
JScrollPane textScroller = new JScrollPane(display1);
textScroller.setPreferredSize(new Dimension(200,75));
textScroller.setMinimumSize(new Dimension(10,10));
displayWindow = new JInternalFrame("Header Graph",true,false,true,true);
JPanel contentPane = new JPanel();
contentPane.setBorder(BorderFactory.createEmptyBorder(10,10,10,10));
contentPane.setLayout(new BoxLayout(contentPane, BoxLayout.Y_AXIS));
contentPane.add(Box.createRigidArea(new Dimension(0,5)));
contentPane.add(textScroller);
b1.setAlignmentX(CENTER_ALIGNMENT);
contentPane.add(b1);
displayWindow.setContentPane(contentPane);
displayWindow.pack();
displayWindow.show();
protected void createListenedToWindow()
listenedToWindow = new JInternalFrame("Image",true,true,true,true);
listenedToWindow.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
listenedToWindow.setSize(800,450);
panel = new DrawingPanel();
listenedToWindow.setContentPane(panel);
public void internalFrameClosing(InternalFrameEvent e)
public void internalFrameClosed(InternalFrameEvent e)
listenedToWindow = null;
public void internalFrameOpened(InternalFrameEvent e)
public void internalFrameIconified(InternalFrameEvent e)
public void internalFrameDeiconified(InternalFrameEvent e)
public void internalFrameActivated(InternalFrameEvent e)
public void internalFrameDeactivated(InternalFrameEvent e)
public void actionPerformed(ActionEvent e)
if (e.getActionCommand().equals(SHOW))
if (listenedToWindow == null)
createListenedToWindow();
listenedToWindow.addInternalFrameListener(this);
desktop.add(listenedToWindow);
listenedToWindow.setLocation(desktopWidth/2 - listenedToWindow.getWidth()/2,
desktopHeight - listenedToWindow.getHeight());
listenedToWindow.show();
else
public static void main(String[] args)
JFrame frame = new SuDisplayTool6("Su Display Tool");
frame.addWindowListener(new WindowAdapter()
public void windowClosing(WindowEvent e)
System.exit(0);
frame.pack();
frame.setVisible(true);
private void addMenu()
JMenuBar menuBar;
JMenu menu, submenu;
JMenuItem menuItem;
final JFileChooser fc = new JFileChooser();
fc.addChoosableFileFilter(new ImageFilter());
menuBar = new JMenuBar();
setJMenuBar(menuBar);
menu = new JMenu("File");
menuBar.add(menu);
menuItem = new JMenuItem("Open...");
menu.add(menuItem).addActionListener(new ActionListener()
public void actionPerformed(ActionEvent e)
int returnVal = fc.showOpenDialog(SuDisplayTool6.this);
menuItem = new JMenuItem("Save");
menu.add(menuItem);
menuItem = new JMenuItem("Save As...");
menu.add(menuItem).addActionListener(new ActionListener()
public void actionPerformed(ActionEvent e)
int returnVal = fc.showSaveDialog(SuDisplayTool6.this);
menuItem = new JMenuItem("Close");
menu.add(menuItem);
menu.addSeparator();
menuItem = new JMenuItem("Exit");
menu.add(menuItem).addActionListener(new WindowHandler());
menu = new JMenu("Edit");
menuBar.add(menu);
menu = new JMenu("View");
menuBar.add(menu);
menuItem = new JMenuItem("Zoom In");
menu.add(menuItem);
menuItem = new JMenuItem("Zoom Out");
menu.add(menuItem);
menu.addSeparator();
submenu = new JMenu("Header");
menuItem = new JMenuItem("CDPX");
submenu.add(menuItem);
menuItem = new JMenuItem("SX");
submenu.add(menuItem);
menuItem = new JMenuItem("CX");
submenu.add(menuItem);
menu.add(submenu);
menu = new JMenu("Help");
menuBar.add(menu);
menuItem = new JMenuItem("About");
menu.add(menuItem).addActionListener(new WindowHandler());
private class WindowHandler extends WindowAdapter implements ActionListener
public void windowClosing(WindowEvent e)
System.exit(0);
public void actionPerformed(ActionEvent e)
if(e.getActionCommand().equalsIgnoreCase("exit"))
System.exit(0);
else if(e.getActionCommand().equalsIgnoreCase("About"))
JOptionPane.showMessageDialog(null,"This program is written by Nenny Ruthfalydia.","About",JOptionPane.PLAIN_MESSAGE);
class DrawingPanel extends Panel
final ImageIcon imageIcon = new ImageIcon("image8.jpg");
Image image = imageIcon.getImage();
public void paint (Graphics g)
g.drawImage(image, 10, 10, this);

so much wrong with this post...
a) use the code tags to format the code. Now it is an unreadable mess
b) scriptlets in your JSP. I don't even want to look at that mess. Learn how to combine servlets and JSPs to create clean, readable and maintainable code in which view logic and business logic are separated. The rule: no java code in your JSP, only tags and EL expressions (learn about JSTL).
So you get a blank screen. When you do "view source" in your browser, do you see anything there? If nothing, check if you are behind a proxy server. The solution to a post of not too long ago was that the blank screen was being caused by faulty proxy server settings (the user figured it out himself, I don't know what was done to solve it).
If all this fails you will have to do some debugging magic using your favorite IDE. It will probably be something stupid you are overlooking in the code. It is annoying, but debugging code that does not work is a big part of your job. Better get good at it.

Similar Messages

  • How to display image returned from servlet?

    Currently: I am getting an image from a database and displaying it using the below code.
    Desired: I want to display HTML also, not just the image.
    response.setContentType("image/jpg");
    ServletOutputStream out = response.getOutputStream();       
    java.io.InputStream in = DatabaseClass.getImageStream(image_name);       
    int bufferSize = 1024;
    byte[] buffer = new byte[bufferSize];
    int length = 0;
    while ((length = in.read(buffer))!=1)
      out.write(buffer,0,length);
    in.close();
    out.flush();
    out.close();I have read about doing this with the image tag (<img src=name.jpg), but this requires storing the image in a file on the server...which is not what I want.
    Any/All suggestions appreaciated. Thanks!

    The <img> tag doesn't necessarily require storing the image on the server. You can just as easily do this:
    <img src="/servlet/imageServlet" width="320" height="240" alt="My image" />

  • How to uncheck a checkbox from a dialog box and remove from view

    Hi All,
    I have button where on click opens a dialog box which has 5 check boxes with text for each check box [generating dynamically using row repeater].
    If one or all of the check box is checked, the check box with its text should get displayed in the view on closing the dialog box. I am able to display this, that is the checked ones.
    But, after closing the dialog box if the user wants to unselect a check box that is not required for the next time, the check box that is unchecked should get removed from the view.  How is this possible ?
    Thanks,
    Ravikiran

    Hi Robin,
    Pleas find the below code,
    var oDialogScope = new sap.ui.commons.Dialog({
      width : "20%"
      oDialogScope.setTitle("Add Scope of Work");
      var oScopeButton = new sap.ui.commons.Button({
      text : "OK",
      var oRowRep = new sap.ui.commons.RowRepeater();
      var oChkBox = new sap.ui.commons.CheckBox({
      text : "{EventDropDown>label}",
      checked : "{EventDropDown>checked}",
      change : function(oEvent) {
      var l1 = new sap.ui.commons.CheckBox({
      editable : false
      l1.setChecked(this.getChecked());
      l1.setText(this.getText());
      oScopeButton.attachPress(function() {
      var cellM = new sap.ui.commons.layout.MatrixLayoutCell();
      cellM.addContent(l1);
      var oScopeRow = sap.ui.getCore().byId("SR1");
      oScopeRow.addCell(cellM);
      oDialogScope.close();
      return;
      oRowRep.bindRows("EventDropDown>/checked", oChkBox);
      oDialogScope.addContent(oRowRep);
      oDialogScope.addContent(oScopeButton);
      oDialogScope.addStyleClass("DialogCss");
      oDialogScope.open();
    Regards,
    Ravikiran

  • Delete from Open Dialog Box?

    I'm a new convert from Windows to Mac.
    My question is: Is there a way to delete a file from a list of files in an Open or Save As dialog box?
    (On Windows I could just highlight the filename and press the Delete key.)
    Thanks.
    MacBook   Mac OS X (10.4.10)  

    There is no built-in way, but a lot of us use a third-party add-on called DefaultFolder which solves this problem and a lot of other problems with the open/save dialogs.

  • How to display a screen as Popup Dialog box in Module Pool

    Hi All,
    I have a requirement to display a popup dialoge box into module pool.
    i need to display a screen as a popup on the current screen on a button click.I have developed a screen and in atribute tab i have defined the screen type as modal dialog box but  it is displaying previous screen screen is hide i want to display on the same screen as a popup.
    Thanks
    Narendra

    Hi Narendra,
    Try to trigger the popup once it is done with the previous action might be anything.
    i have shown one sample code where after i click on save button when the data is saved successfully
    after that it has to trigger me a popup asking for conformation for the next action.
    A small piece of code
    INSERT INTO ZORMD1 VALUES WA_ZORMD1.
        IF SY-SUBRC = 0.
          G_LOCAL1 = 0.
          MESSAGE S000.  " Data saved successfully and immediately call the popup
    CALL FUNCTION 'POPUP_TO_CONFIRM_STEP'
            EXPORTING
      DEFAULTOPTION  = 'Y'
    TEXTLINE1 = 'SUCCESSFULLY SAVED'
              TITEL = 'POPUP FOR conformation'
             START_COLUMN         = 25
             START_ROW            = 10
            CANCEL_DISPLAY       = 'X'
           IMPORTING
    ANSWER  = G_PRINT
    IF G_PRINT = 'J'.
    PERFORM PRINT_OUT.
    ENDIF.
    Do the modification according to your requirement.
    Cheers!!
    VEnk@

  • How to display image using Carousel in ADF using BLOB column DB

    Hello everyone ,
    I tried creating a Carousel component in ADF do display an image , but it seems to be not working .
    This is what i tried .
    1 ) Created an empty page .
    2) From data control drag and drop view object ( one of the column in DB is blob which saves the image ) as Carousel .
    3 ) Drag and drop the image over Carousel component ,
    Now what should be the source for the image ?? from expression builderi tried giving #{item.Image} images are not picking up .
    Could you please advice .
    --Keerthi                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   

    Keerthi,
    You cannot display a BLOB as image as it is. You need to convert them to display in your UI.
    Check out this blog on how to use a servlet to convert the blob into image and display in the page.
    http://tompeez.wordpress.com/2011/12/16/jdev11-1-2-1-0-handling-imagesfiles-in-adf-part-3/
    -Arun
    P.S : Always mention your JDev version and the technologies used.

  • How to display image file from the link in the field

    Hi all,
    I have a column where it keeps the link of the image files reside. The link will be in the server such as \\server\picture1.jpg
    I have try to code in Read_Image_File('\\server\picture1.jpg', 'ANY','OM_ITEM.ITEM_URL');
    But I was encountered error run, ORA-01465: invalid hex number.
    Any one please help me. Thanks.
    Regards,
    Lim

    There are tons of informations missing here, for instance (but not limited to) the exact forms version you are using (note: 10g is not a version, but 10.1.2.0.2 is). Without Version informations a correct answer is not possible
    You might want to go through the links from the Announcement entitled "<a href=http://forums.oracle.com/forums/ann.jspa?annID=432>Before posting on this forum please read </a>" which contains links to the documentation and instructions on how to post proper questions for example.
    cheers

  • How to invoke 'File Open' dialog box in Forms (under unix)

    Hi all,
    On the Unix platform (motif), how do I get the File Open Dialog
    Box by using Forms45.
    Thanks and regards,
    Srinivasa.
    null

    going from 6i to 10g is a migration. That's no easy step normally.
    client-server-functionality has gone. web-functionality is new.
    Install the new webutil-toolset from oracle and use the new file-open-dialog from the webutil.pll. That's the way you work in the new 10g-environment.
    Read in the forms-section of the OTN the migration-papers and the webutil-doc's

  • Photoshop crashes with open dialog box on Windows 8.1

    I just upgraded from Windows 8.0 to Windows 8.1. I have Photoshop CC, I also have Photoshop Elements installed. On occasion, Photoshop CC hangs when using the open dialog box. It then crashes explorer. The only way to resolve it is to restart the PC.
    Has anyone seen this behavior. I do not have any logs as of now.
    Thanks,
    Bill Byrnes

    I don't know if this is helpful or exactly on topic with this thread... but I have to share somewhere...
    I've been dealing this problem for months and I finally fixed it on my own.
    My Antivirus, AVG, which is great, except for this glitch, was the root cause of the issue. 
    History:  If I right-clicked a file in my Save/Open Dialogue Photoshop (CS6 Extended) would crash.. for the last few months, actually...  If I avoided right-clicking I'm ok, but my instincts are to organize, rename, etc. while in the save/open pop-up window ... So I've often crashed Photoshop when all I do is right-click on a file in the list of files...
    Well, I figured out the cause of the glitch:
    "Permanently Shred with AVG” .. this option, added without my knowledge during an AVG update, was added around the same time this problem started (realizing this in hindsight).. THIS was conflicting with my Adobe Photoshop file explorer window in the Save/Open dialogue!!! After months of trying to figure this out, this is definitely the solution.
    Once I turned that AVG Shell Extenstion off.... I am now able to right-click files in Photoshop save/open pop-up window again without it crashing…  finally !!!!
    ...hope this helps folks even if it's just a related clue to other issues....
    Basically ,run command prompt as Administrator, then type:
    For 32-bit :  regsvr32 /u “C:\Program Files\AVG\AVG2014\avgse.dll”
    For 64-bit:   regsvr32 /u “C:\Program Files (x86)\AVG\AVG2014\avgse.dll”
    I found this info about turning off  "Permanently Shred with AVG" option at this link:
    http://techdows.com/2013/09/avg-2014-how-to-remove-permanently-shred-with-avg-option-from- context-menu.html#comment-21176
    thanks!
    -Camilo

  • Illustrator cc2014 open dialog box won't work yosemite

    I have a Macbook Pro Retina 2014 with a fresh install of Yosemite and Creative Cloud, after a while, when I used the open dialog box for 4 or 5 times to open documents, that dialog box won't work anymore, I have to quit and reopen the Illustrator application, the shortcut won't work either. Is anybody got that problem before?
    When I was on Mountain Lion, I never got this problem, I presume it's related to Yosemite.

    Gelouis,
    I believe it is a bug in CC2014, appearing when you have the Illustrator open/place dialogue set to column view and sort by date or sort by kind. You may change it to view by name or list view.
    https://forums.adobe.com/message/7145022#7145022
    https://forums.adobe.com/thread/1723170
    https://forums.adobe.com/message/7183002#7183002
    Or you may get it right by changing the sort to something else.

  • How to  upload and display image using bsp application

    hi
    I  just wants to know that
    1- how to  upload image from BSP page with attachment into sap server .?
    2-how to display image in to BSP page(webpage).
    thanks

    Hello Gupta Prashant,
    Just to upload and display an image, import image in MIME repository. Not only still images but also flash files can also be uploaded in the MIME repository. Once you import the image in it, use normal html code for image call;
    <img src = "file.jpg/gif" width=  height=>
    Besides it, if your requirement is to store the image in the database and fetch it based on specified field-name, then you have to go for BLOBs i.e Binary Large Object, using this you can also store images, videos, pdfs, applications in the database.
    MBLOB - Medium BLOBs store videos and pdfs,
    LBLOB  - Large BLOBs store movie files and applications.
    You have got 2 ways to use it; some databases store BLOB objects into themselves and some store the path of the BLOB object maintained on the FTP server.
    You can also implement it in ABAP;
    read the following link and practice the tutorial;
    [ Use of MIME Types|http://help.sap.com/saphelp_45b/helpdata/en/f1/b4a6c4df3911d18e080000e8a48612/content.htm]
    also check this
    [TYPES - LOB HANDLE|http://help.sap.com/abapdocu/en/ABAPTYPES_LOB_HANDLE.htm]
    And looking at your question, in order to upload an image, you can make use of FILEUPLOAD tag provided by HTMLB.
    Step 1: FILEUPLOAD provides a browse button to choose desired image file.
    Step 2: Store that image in database using BLOBs.
    Step 3: Retrieve the image using normal select query and display it on the screen.
    Hope it helps you,
    Zahack

  • I would like to use the windows explorer open dialog box instead of the adobe open dialog box. How can I change that?

    I would like to use the windows explorer open dialog box instead of the adobe open dialog box. How can I change that?

    The top screenshot is the Windows Open dialog box. All File > Open... commands in all Windows programs bring it up.   Try File > Open in Notepad for example.
    It belongs to Windows not Adobe. You cannot change this because there is no such thing as an Adobe Open dialog box.
    The bottom screenshot is Windows Explorer. It is Windows' OS File Browser, not an Open dialog.  It is not called up by Photoshop or any Windows program.
    You have to click on "My Computer" or a Folder icon to get to it. You can double-click a psd, jpeg or other image file in the Explorer window so that it opens in Photoshop.
    There is Adobe Bridge and Minibridge   Alt + Ctrl + O or File > Browse in Bridge

  • How to read bytes(image) from a server ?how to display image after read byt

    How to read bytes(image) from a server ?how to display image after reading bytes?
    i have tried coding tis , but i couldnt get the image to be display:
    BufferedInputStream in1=new BufferedInputStream(kkSocket.getInputStream());
    int length1;
    byte [] data=new byte[1048576];
    if((length1=in1.read(data))!=-1){
    System.out.println("???");
    }System.out.println("length "+length1);
    Integer inter=new Integer(length1);
    byte d=inter.byteValue();

    didn't I tell you about using javax.imageio.ImageIO.read(InputStream) in another thread?

  • Diable "open dialog box" on right mouse click so I can use l mouse to advance to next slide and r mouse click to "go back."  How in PP 2010 for mac????

    I do presentations in PP10.  I am new to macair, and used to Windows.  HOW DO I DISABLE THE "OPEN DIALOG BOX ON RIGHT CLICK"?  I would like to use L mouse to advance slide, and R mouse to go back.  The default is to use R mouse to open dialog box.  I can disable this by unchecking the box in "advanced" on the PC.  How do I do it with the Mac????
    Thanks
    hacmd

    Hi Rod,
    As originally stated in my opening post, the SWF is to be inserted into an Articulate '13 slide (what I called an aggregator originally - I tried not to bring them up since I don't want the chatter about "There's your problem - using Articulate"! ).
    Recall that posting this published file to our LMS did not allow right-mouse click functionality as the flash player menu just gets in the way.
    If I insert the captivate 6 files into Articulate as a Web Object (referencing the entire folder with html, htm and assets, and then posted to our LMS, and it DOES allow RM click operations in both IE and FF (although no sound on the Captivate slide in FF). But this is not what we want to do as this introduces 2 navigation controls (the Captivate one and the Articulate Player).
    Why must anything be posted to a web server for this functionality to work?
    I am able to go into the Captivate 6's published folder, and launch the Captivate demonstration by simply double clicking on the index.html file and this works great in both FF and IE after changing the security settings for flash.
    Again - I can not believe I am the only one out there trying to use the right-mouse click feature to do a software simulation by embedding the Captivate SWF into an Articulate '13 project.

  • I use Apple Mail and dislike Outlook.  If I create a note in Apple Mail, move it to desktop for easy access and then open the note, it opens in Outlook.  How do I stop Outlook from opening?  Do I need to uninstall Outlook?  Will it disrupt other software?

    I use Apple Mail and dislike Outlook.  If I create a note in Apple Mail, move it to my desktop for easy access and then open the note, it opens in Outlook.  How do I stop Outlook from opening?  Do I need to uninstall Outlook?  Will it disrupt other software?

    Open Apple Mail, and open Preferences (under Mail in the Menu Bar).  On the General tab, check the "Default Email Reader" and set it to Mail (6.6).

Maybe you are looking for