Loading a JPEG into a swing application...

I need help embedding a JPEG in a swing application(preferrably in it's own container). What should container should I use? Any helpful methods?

Swing related questions should be posted in the Swing forum.
Read the Swing tutorial on [url http://java.sun.com/docs/books/tutorial/uiswing/components/icon.html]How to Use Icons.

Similar Messages

  • Load external jpeg into flash movie

    Hi, how do i load external jpeg into flash movie?
    Can someone show me the actionscript? Thanks

    hi, i pasted the code on a mc but it didn't work.
    However, when i put in on frame action, it works.
    However, i realised the image flickered (more like refreshed)
    after afew sec...
    Is this normal? Is it the loop problem? how do i get rid of
    that?

  • Entry points for integrating Openoffice writer into Java swing application

    I googled the web and also took a look in below 2 web sites, just seems it is very difficult to get an entry point for me to try my frist application with open office writer integrated with my swing application.
    http://wiki.services.openoffice.org/wiki/Documentation/DevGuide/OpenOffice.org_Developers_Guide
    http://api.openoffice.org/
    What my question is:
    1. Where can I get the completed jar files for using the open office writer api for my java application?
    2. Is there any step by step practical example for using the api? It seems that the above links are quite messy and difficult to find an entry point to get a start, but just contain many segments separated through out the web site.
    Thanks much for any suggestion.

    Information regarding OOo is not on Sun websites, or in these forums. There may be 3rd-party sites that have some info regarding OOo use.

  • Make DB application users load bulkdata(.CSV) into tables from Application.

    I have created an Apex application which has report and form pages.
    my application allows the user to add a record/ update an existing record through form page.
    but in 1 scenario every day my user gets arround 500 records in .csv files. Its hectic for him to upload each record 1 by 1.
    please help me out how to make him load bulk data(.csv) into the tables(reports) from the application itself. I meant to ask, what changes should i make in the application as a developer in order to fulfill this requirement and how ?

    Hi,
    These links might help build solution
    http://dbswh.webhop.net/dbswh/f?p=BLOG:READ:0::::ARTICLE:11000346061523
    http://dbswh.webhop.net/dbswh/f?p=BLOG:READ:0::::ARTICLE:126300346812330
    Regards,
    Jari

  • Loading sound clips in my swing application

    I have searched all the forums, din't find what i want.
    I have many small sound files to be played in my application. Even on mouse Pressed, Drage etc etc....
    Now I was looking for a better way of Loading the Sound files in memory as the application starts.....
    If I use the Clip Interface of javax.sound and initilize them and open a stream, invoke the open() method, and store it in hashmap. So that when ever i need that file i will lookup for that clip and trigger the start() method which actually plays the sound. IS the approach the right approach, will not the Cip object keep the IO handle open, I have nearly 40 Clips to be loaded.
    Can any one suggest me the better way of implementing this.
    TIA
    Zoha

    As far as I know,there is no facility for detecting mouse scrolling wheel in JDK 1.3.
    Check it in the later releases of JDK.

  • Open image in Swing Application

    Hi,
    I'm having trouble getting an image to open into my swing application and I cant figure out whats wrong. In response to selecting the "Open" button or menu item a JFileChooser opens up and i select an image but the image doesn't actually load. If anyone could help i'd really appreciate it.
    import javax.swing.*;
    import javax.swing.event.*;
    import java.awt.*;
    import java.awt.event.*;
    import java.awt.image.*;
    import java.io.*;
    import javax.swing.border.*;
    import javax.imageio.*;
    class PhotoEditor extends JPanel implements ActionListener {
         * Create the GUI and show it.  For thread safety,
         * this method should be invoked from the
         * event-dispatching thread.
        JMenu imageMenu, effectsMenu;
        JFileChooser fc = new JFileChooser();
        BufferedImage img = null;
           public JMenuBar createMenuBar() {     
         JMenuBar menuBar = new JMenuBar();
        /* Build the first menu: */
        JMenu fileMenu = new JMenu("File");
        menuBar.add(fileMenu);
        fileMenu.setMnemonic(KeyEvent.VK_F);
        //a group of JMenuItems under the File option:
            String[] menuItems1 = {"Open", "Save","Save As..", "Close"};
        String[] menuIcons1 = {"Open.gif", "Save.gif", "", ""};
        for (int i = 0; i<menuItems1.length; i++)
                  JMenuItem fileMI = new JMenuItem(menuItems1, new ImageIcon(menuIcons1[i]));
              fileMI.addActionListener(this);
              fileMenu.add(fileMI);
    //adding a separator to the drop down menu list
    fileMenu.addSeparator();
    JMenuItem exitMI = new JMenuItem("Exit", new ImageIcon("Exit.gif"));
    exitMI.addActionListener(this);
    fileMenu.add(exitMI);
    /* Code which builds all the menu here */
    return menuBar;
         public JToolBar createToolBar() {     
         JToolBar toolB = new JToolBar(FlowLayout.LEFT);
    toolB.setLayout(new FlowLayout());
    // contentPane.add(toolB, "North");
    JButton newButton = new JButton(new ImageIcon("new24.gif"));
    newButton.addActionListener(this);
    toolB.add(newButton);
    newButton.setToolTipText("New");
    newButton.setActionCommand("New");
    //adding a separator to the drop down menu list
    toolB.addSeparator();
    JButton openButton = new JButton(new ImageIcon("open24.gif"));
    openButton.addActionListener(this);
    toolB.add(openButton);
    openButton.setToolTipText("Open");
         openButton.setActionCommand("Open");
    /* More code building the toolbar*/
    return toolB;
         public void actionPerformed(ActionEvent e) {
    Object eventSource = e.getSource();
    if ((eventSource instanceof JMenuItem) || (eventSource instanceof JButton));{
    String label = (String) e.getActionCommand();
    //Sets up the Action Listeners
    if (label.equals("Exit")) {
    System.exit(0);
    // Closes application
    else if (label.equals("Open")) {
         openImage();
    /* More codes for each button or menu item */
    protected void openImage() {
              int returnVal = fc.showOpenDialog(this);
    if (returnVal == JFileChooser.APPROVE_OPTION) {
    File file = fc.getSelectedFile();
         try {
                   img = ImageIO.read(file);
                        catch (IOException e1) {
    public void paintComponent(Graphics g) {
         super.paintComponent(g);
    g.drawImage(img, 500, 500, null);
    private static void createAndShowGUI() {
    //Create and set up the window.
    JFrame frame = new JFrame("Photo Editor");
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    //Create a main label to put in the content pane.
    JLabel main = new JLabel();
    // main.setOpaque(true);
    // main.setBackground(new Color(128, 128, 128));
    main.setPreferredSize(new Dimension(800, 600));
    //Set the menu bar and add the label to the content pane.
    PhotoEditor mainmenu = new PhotoEditor();
    frame.setJMenuBar(mainmenu.createMenuBar());
         frame.getContentPane().add(mainmenu.createToolBar(), BorderLayout.PAGE_START);
    frame.getContentPane().add(main, BorderLayout.CENTER);
    //Display the window.
    frame.pack();
    frame.setVisible(true);
    public static void main(String[] args) {
    //Schedule a job for the event-dispatching thread:
    //creating and showing this application's GUI.
    javax.swing.SwingUtilities.invokeLater(new Runnable() {
    public void run() {
    createAndShowGUI();

    Your PhotoEditor class extends JPanel. In that class you override paintComponent(). But you never add the panel to the GUI, so that method is never invoked.
    Personally I would have the PhotoEditor class extend JFrame. Then in the constructor you build all the components for the frame
    a) build the menu
    b) build the toolbar
    Then I would create a PhotoPanel class that you extend and override the paintComponent(). Then you add this panel to the GUI as your main panel.
    For a simple example of drawing a background image on a panel search the forum for my BackgroundImage example.

  • How to load a text file in a Java swings application

    hi,
    I am trying to retrieve a Java code(or say any text from an existing file) and display it in a swing application.
    I am not able to do so.
    Please help me.

    public String readFile(File f){
              try {
                   BufferedReader read = new BufferedReader(new FileReader(f));
                   String line = read.readLine();
                   String total = "";
                   while(line != null){
              //          System.out.println(line);
                        total += line;
                        line = read.readLine();
                   read.close();
                   return total;
              } catch (Exception e){
                   e.printStackTrace();
              return "";
         }that will read a file into a string, i hope you can figure out the rest

  • Embed Google Maps into Swing Application

    Hi,
    I am trying to build a swing application and i need to embed Google map into it.Is there any way to do this? Which component do i use?
    I guess i am having some difficulty with this because the Swing component needs to support the complex javascript that Gmaps uses.
    Please suggest some solution or API.
    Thanks!

    look on google's site. they have some java component.

  • Register Applications photoshop CC   Lightroom 300 baht per month Creative Cloud desktop install and load the program into Lightroom down normally open normally, but the work load photoshop program installed. Open access Like we use it to fill a 30-day tr

    Register Applications photoshop CC   Lightroom 300 baht per month Creative Cloud desktop install and load the program into Lightroom down normally open normally, but the work load photoshop program installed. Open access Like we use it to fill a 30-day trial version, serial no.

    1) WHAT if I juse JUST ONE Adobe program pretty often? 
    They have a single use subscription for $20/mo.  Similar to upgrading extended version every 1.5 years.
    2)  WHAT if I created projects like 2 months ago and I didn't use Photoshop for a full month.  Who assures us that with the CC series the projects are opened with the old CS ones?Or don't use it every day?
    Same problem if you own it.  If upgrade price is $400 every 1.5 year that is same as $16/month.  You can choose not to update and version will be same as when you last used it.
    3) WHAT if I don't use Adobe 24/7?  and 5) Making an day-based subscription??  Same problem if you own it.  If upgrade price is $400 every 1.5 year that is same as $16/month.
    4) Adobe, do you think to be the only one making these softwares?
    Competition is always a factor in market.
    6) After all this mess, you discriminate Europeans, too?
    Taxes charged by Governments and municipalities are not controlled by Adobe.

  • New "Loading Database Data into Endeca Information Discovery Applications" product enablement video available on YouTube!

    Hi All,
    The Endeca Information Discovery Information Curriculum Development team just added a new video, "Loading Database Data into Endeca Information Discovery Applications", to the Video  Feature Overviews section of the Oracle Endeca Information Discovery YouTube channel.
    The URL for the video is https://www.youtube.com/watch?v=ix6bGULuY1I&list=PLQl6jp6EE5H2K4JDic6bIPA7yZgbi1KAQ .
    Here’s a description of the video tutorial:
    The goal of this video tutorial is to enable you to configure Studio to use data from a JDBC data source and to create your own application in Studio.
    The target audience is Studio administrators who have to configure a JDBC data source in Studio’s Data Source Library.  As a secondary audience, business users will learn how to load data from a JDBC data source and create a discovery application in Studio.
    As always, if you have any ideas for additional videos, please let us know.
    Thanks!

    Hi All,
    The Endeca Information Discovery Information Curriculum Development team just added a new video, "Loading Database Data into Endeca Information Discovery Applications", to the Video  Feature Overviews section of the Oracle Endeca Information Discovery YouTube channel.
    The URL for the video is https://www.youtube.com/watch?v=ix6bGULuY1I&list=PLQl6jp6EE5H2K4JDic6bIPA7yZgbi1KAQ .
    Here’s a description of the video tutorial:
    The goal of this video tutorial is to enable you to configure Studio to use data from a JDBC data source and to create your own application in Studio.
    The target audience is Studio administrators who have to configure a JDBC data source in Studio’s Data Source Library.  As a secondary audience, business users will learn how to load data from a JDBC data source and create a discovery application in Studio.
    As always, if you have any ideas for additional videos, please let us know.
    Thanks!

  • Getting errors loading flat file into BI 7 from application server

    We are able to load the file via local (from the PC) successfully but when we try and load the exact same file from the application server we get an error:
    Error 'The argument '151.8470707' cannot be interpreted as a number' when assigning application structure, line 478, contents "11 140604     1000 8110 902070    P..."
    What is really strange if we split the file into 2 we are able to load each of the sections successfully from the appliation server.  We have a need to load the whole file from the application server and don't wish to split it up.  Can anyone tell me how to make this work??

    what I should do is the following:
    open the 3 files you have using notepad and compare line 478 in the original file (that had the error) with the corresponding line in one of those 2 other files. what are the differences? the answer to this question might give you a clue.
    and if you don't see any differences try to cut and paste that one line with the error to a new 4th file and load this one and see if the error reoccurs (I think it will).
    regards, André

  • How to change the cursor type when a TableView class was added to a Swing application?

    We can resize column width by dragging the column divider in the table header. This is a built-in feature of the TableView class.
    Normally, the cursor will become to east-resize (or west-resize) type with positioning the cursor just to the right of a column header.
    However, I found that the cursor is remaining the default type at the same position if I integrate JavaFX into Swing Application. That is adding the TableView to a Scene, and then adding this Scene to a JFXPanel, finally, adding this JFXPanel to the JFrame.
    The sample codes are listing below:
    public class Run extends JFrame {
        Run() {
            setSize(600, 450);
            setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
            initComponents();
        private void initComponents() {
            final JFXPanel fxPanel = new JFXPanel();
            this.getContentPane().add(fxPanel);
            Platform.runLater(new Runnable() {
                @Override
                public void run() {
                    initFX(fxPanel);
        private void initFX(JFXPanel fxPanel) {
            Scene scene = null;
            try {
                scene = FXMLLoader.load(
                    new File("res/fxml_example.fxml").toURI().toURL()
            } catch (Exception ex) {
                ex.printStackTrace();
            fxPanel.setScene(scene);
        public static void main(String[] args) {
            SwingUtilities.invokeLater(new Runnable() {
                @Override
                public void run() {
                    new Run().setVisible(true);
    fxml_example.fxml:
    <?xml version="1.0" encoding="UTF-8"?>
    <?import javafx.scene.Scene?>
    <?import javafx.scene.control.TableView?>
    <?import javafx.scene.control.TableColumn?>
    <Scene xmlns:fx="http://javafx.com/fxml">
        <TableView fx:id="tableView"
                   editable="true">
            <columns>
                <TableColumn text="COL1">
                </TableColumn>
                <TableColumn text="COL2">
                </TableColumn>
                <TableColumn text="COL3">
                </TableColumn>
                <TableColumn text="COL4">
                </TableColumn>
                <TableColumn text="COL5">
                </TableColumn>
            </columns>
        </TableView>
    </Scene>
    So, are there anyone can advise how to fix these codes; make the cursor can change to east-resize (or west-resize) type when this TableView class was added to a Swing application?

    Thanks for the report. I've just filed a JIRA issue: https://javafx-jira.kenai.com/browse/RT-34009
    //Anton.

  • OUT OF MEMORY - during loading images (JPEG's)

    Hallo,
    We use the OHJ (version 4.1.12) inside a Java/Swing application with JDK 1.3.1.
    Our online help contains a lot of larger JPEG images. When the user navigates through the online help - an out of memory occurs while loading the images.
    I tried to split the help pages in a lot of small HTML pages, but this doesn't help. It seems that the OHJ does not clear the memory
    when loading the next HTML page.
    Can the OHJ deal with larger images ?
    Any other possibilities ?
    Thanks
    Markus Pohle

    >
    It seems that the OHJ does not clear the memory when loading the next HTML page.
    Can the OHJ deal with larger images ?
    We have never seen such a problem with large images and OHJ. Could you send us a ZIP containing your help content by e-mail to [email protected] so that we can try to reproduce it?
    Thanks,
    -brian

  • How to add images into a java application (not applet)

    Hello,
    I am new in java programming. I would like to know how to add images into a java application (not an applet). If i could get an standard example about how to add a image to a java application, I would apreciated it. Any help will be greatly apreciated.
    Thank you,
    Oscar

    Your' better off looking in the java 2d forum.
    package images;
    import java.awt.*;
    import java.awt.image.*;
    import java.io.FileInputStream;
    import javax.imageio.ImageIO;
    import javax.swing.*;
    /** * LogoImage is a class that is used to load images into the program */
    public class LogoImage extends JPanel {
         private BufferedImage image;
         private int factor = 1; /** Creates a new instance of ImagePanel */
         public LogoImage() {
              this(new Dimension(600, 50));
         public LogoImage(Dimension sz) {
              //setBackground(Color.green);      
              setPreferredSize(sz);
         public void setImage(BufferedImage im) {
              image = im;
              if (im != null) {
                   setPreferredSize(
                        new Dimension(image.getWidth(), image.getHeight()));
              } else {
                   setPreferredSize(new Dimension(200, 200));
         public void setImageSizeFactor(int factor) {
              this.factor = factor;
         public void paintComponent(Graphics g) {
              super.paintComponent(g);
              //paint background 
              Graphics2D g2D = (Graphics2D) g;
              //Draw image at its natural size first. 
              if (image != null) {
                   g2D.drawImage(image, null, 0, 0);
         public static LogoImage createImage(String filename) { /* Stream the logo gif file into an image object */
              LogoImage logoImage = new LogoImage();
              BufferedImage image;
              try {
                   FileInputStream fileInput =
                        new FileInputStream("images/" + filename);
                   image = ImageIO.read(fileInput);
                   logoImage =
                        new LogoImage(
                             new Dimension(image.getWidth(), image.getHeight()));
                   fileInput.close();
                   logoImage.setImage(image);
              } catch (Exception e) {
                   System.err.println(e);
              return logoImage;
         public static void main(String[] args) {
              JFrame jf = new JFrame("testImage");
              Container cp = jf.getContentPane();
              cp.add(LogoImage.createImage("logo.gif"), BorderLayout.CENTER);
              jf.setVisible(true);
              jf.pack();
    }Now you can use this class anywhere in your pgram to add a JPanel

  • Swing application w/images

    Hello,
    Java Image I/O provides ways to load and save images into swing applications. Does anyone know of other APIs? We're using Spring/RMI with a Swing client. The images would be stored on the server by index or something. Whats the best approach to write such an application? something that will provide the most flexibility (multiple image formats... viewing, saving, printing etc.) . thanks

    Thanks for the response. Can i incorporate the ability to view TurboCad sketches (.tcw files) using this API?

Maybe you are looking for

  • I've just purchased the photographer's package, but the download for Lr doesn't show in my app list?

    I've just purchased the photographer's package, but the download button for Lightroom doesn't show in my app list. How come? I've checked everything and my computer system should be able to run it perfectly.

  • Display variable values selected as header in WAD

    Hi All Gurus, I need to display the variable values entered for running the report as a header to the report being displayed. I'm using NW2004s BI and standard template 0analysis_pattern. Is there a way I can display the variable values as header inf

  • Noob/PC Convert/MS Media Center

    I just bought my first Mac last night to replace my PC that I've been having problems with. I also bought it with the understanding that it could pretty much do whatever my PC could do. I primarily used the PC for internet and watching/recording live

  • SAP ISU data modeling and BW

    Hello Guru's, I am new to SAP ISU ,  can any help me with BW integrations of SAP ISU. Like IS-U data model and standard industry processes, how BW is different in SAP ISU landscape. what are the function modules used for metering and billing module.

  • Simple encryption applet

    I'm just wondering if somewhere on the web there was any site with the ability to simply input a String, and a salt, and have it encrypt it, or enter a String (encrypted) and the salt used and have it decrypt it. I put applet in the title, but I don'