Image trouble in application + comments on code ?

I have tried to insert an image in this slowly-becoming application but it won't work.
I have commented the parts that don't work (the paint method).
The error only occurs when I un-comment the Paint-method.
It would also be great if you would like to give some comments on my code, this is my first 'project' and I'm going to be grateful for any feedback.
thanks,
David
Here's my code:
import java.awt.*;
import java.awt.image.*;
import java.awt.event.*;
import javax.swing.*;
import java.awt.Toolkit;
public class MainWindow {
public JFrame frame;
public Image img;
     public MainWindow() {
          frame = new JFrame("App. Title here");
          frame.setResizable(false);
          frame.setSize(620,420);
          frame.setBackground(Color.white);
          frame.setDefaultCloseOperation(frame.EXIT_ON_CLOSE);
          JPanel panel = new JPanel();
          Font font = new Font("Verdana", Font.BOLD, 12);
          JLabel heading = new JLabel("Application Heading");
          heading.setFont(font);
          heading.setBackground(Color.white);
          heading.setOpaque(true);
          img = Toolkit.getDefaultToolkit().getImage("image.jpg");
          buildMenu();
          panel.add(heading);
          frame.setContentPane(panel);
          frame.setVisible(true);
     public void buildMenu() {
          JMenuBar mb = new JMenuBar();
          JMenu menu = new JMenu("File");
          JMenuItem item = new JMenuItem("Exit");
          //Closes the application from the Exit menu item.
          item.addActionListener(new ActionListener() {
               public void actionPerformed(ActionEvent e) {
                    System.exit(0);
          menu.add(item);
          mb.add(menu);
          frame.setJMenuBar(mb);
     public static void main(String[] args) {
          try {
               UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
          catch (Exception err) {
               System.out.println("Error loading Look & Feel: "+ err);
          MainWindow SplashScreen = new MainWindow();
     public void paint(Graphics g) {
          g.drawImage(img, 4, 20, this);
}

Thanks for your reply, but another problem has occured.
The image shows up now, which is great, but the menu doesn't ? I have tried to find the problem with no luck.
Here's my code:
many thanks,
David
import java.awt.*;
import java.awt.image.*;
import java.awt.event.*;
import javax.swing.*;
import java.awt.Toolkit;
public class MainWindow_new extends JFrame { // JWindow for splashScreen
public JFrame frame;
public Image img;
     public MainWindow_new() {
          super("App. Title here");
          setResizable(false);
          setSize(620,420);
          setBackground(Color.white);
          setDefaultCloseOperation(frame.EXIT_ON_CLOSE);
          JPanel panel = new JPanel();
          Font font = new Font("Verdana", Font.BOLD, 12);
          MediaTracker tracker = new MediaTracker(this);
          img = Toolkit.getDefaultToolkit().getImage("images\\jpgs\\arena.jpg");
          try {
               tracker.addImage(img, 0);
               tracker.waitForID(0);
          catch (InterruptedException err) {
               System.out.println("MediaTracker Interrupted");
               err.printStackTrace();
          buildMenu();
          setContentPane(panel);
          setVisible(true);
     public void buildMenu() { // Opens buildMenu method definition
          JMenuBar mb = new JMenuBar();
          JMenu menu = new JMenu("File");
          JMenuItem NewItem = new JMenuItem("New Game");
          JMenuItem LoadItem = new JMenuItem("Load Game");
          JMenuItem ExitItem = new JMenuItem("Exit");
          //Closes the application from the Exit menu item.
          ExitItem.addActionListener(new ActionListener() { // Opens addActionListener method
               public void actionPerformed(ActionEvent e) { // Opens actionPerformed method
                    System.exit(0);
          menu.add(NewItem);
          menu.add(LoadItem);
          menu.addSeparator();
          menu.add(ExitItem);
          mb.add(menu);
          setJMenuBar(mb);
     public static void main(String[] args) {
          try {
               UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
          catch (Exception err) {
               System.out.println("Error loading Look & Feel: "+ err);
          MainWindow_new mainWindow = new MainWindow_new();
     public void paint(Graphics g) {
          g.drawImage(img,10,10,this);
}

Similar Messages

  • 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

  • Blob in classic report - broken images in translated application

    Hello,
    I have an application containing a classic report with a blob column displayed as inline images. The application's UI is translated and published (from en to de in my case) according to APEX docu. Everything seems to work fine so far but all classic reports with blobs show broken images in the translated application.
    The report query is something like:
    SELECT  IMAGE_NAME,
            CATALOG_MIME,
            CATALOG_FILENAME,
            CATALOG_LAST_UPD,
            ID,
            dbms_lob.getlength(CATALOG_IMAGE) CATALOG_IMAGE
    FROM    IMAGE imgThe images are displayed by using the format mask "IMAGE:....inline" on the CATALOG_IMAGE column and the generated image URLs (<img src="...">) look like this:
    In primary language (App ID 251, working): http://server/pls/apex/apex_util.get_blob?s=724178467531162&a=251&c=6844840372320206&p=5305&k1=288447&k2=&ck=7475F2F4A0CFA99CC137C9F9008CE3F9&rt=CR
    In translated app (App ID 151, broken images): http://server/pls/apex/apex_util.get_blob?s=724178467531162&a=251&c=6844840372320206,151&p=5305&k1=288447&k2=&ck=4576169EC6C9645C83E321610FE4BE6B&rt=CR
    Also by entering the broken image URL directly the server says: "The requested URL /pls/apex/apex_util.get_blob was not found on this server."
    Is this a bug in APEX (using 3.1.2), anyone else encountered this? Is there a solution or workaround?
    Thanks for infos,
    Stefan

    Follow-up by myself:
    I found a workaround for this by using the apex_util.get_blob_file_src function instead of declarative blob support. The code generated by this seems to work also in the translated application.
    Btw, the original problem remains in APEX 3.2, as just tested at apex.oracle.com. I've made a test comparing declarative blob support to apex_util.get_blob_file_src in the sample application in my workspace (SMEINDL), application id 50912, page 3 (products). If anyone is interested, please have a look at it.
    Stefan

  • Dynamically Changing stylesheets and images of B2B application

    Hello All,
    We have a requirement to dynamically  change the stylesheets and images of B2B application based on Country  US or UK of the logged-in user.
    On looking into B2B source code, we identified  that stylesheets are defined in init-config.xml , ExtendedInitStyleHandler, BrowserType, ExtendedStyleManager, java classes are used.
    Can  anyone  provide suggestions how this can be achieved?
    Thanks,
    Raj

    What you are trying to achieve is not a simple task. It is better to put some thought and resources to build what yuo need. There is no out-of-the-box way to change the stylesheet dynamically.
    Would it be a feasible option
    No. But technically you can have your own tag with another parameter to specify the country and you can have custom logic to add the right stylesheet.
    The class ExtendedInitStyleHandler initializes the application with the list of stylesheets defined in the init-config.xml and any extensions in the /xcm/customer/modification/initconfig.xml
    It is the tag <isa:stylesheets/> that adds the stylesheet(s) to the JSP and class StyleSheetsTag uses ExtendedStyleManager
    Try this out. Just prior to placing the tag <isa:stylesheets>, use the following class, methods and code in <% Java scriptlet  %>
    public class ExtendedStyleManager;
    public static Iterator getStyles();
    public static void clear(); and
    public static void addStyleSheet(StyleSheet style);
    1. read the current styles (getStyles()),
    2. keep a copy of the safe,
    3. Clear the list (clear()),
    4. Add your country specific stylesheet();
    5. Add rest of the styles you need from the saved list
    6. <isa:stylesheets/>
    It is possible to write a custom tag lib too with the above logic and a country - parameter and use the custom tag in place of the isa tag.

  • I uninstalled and reinstalled but at the end of installation there were erros.  See attached screen shot.  I now cannot open the application.  error code 10810 comes up when I try to open.

    I could not update photoshop CS6 and Jeff from forum advised unistalling and reinstalling (Tk93580659). Mac OSX. In real trouble, as suggested I uninstalled and reinstalled but at the end of installation there were errors.  See attached screen shot.  Now I cannot open the application.  Error code 10810 comes up when I try to open (see 2nd screenshot).  Please help.  I have now lost photoshop altogether whereas previous at least I still could use it but could not update.  Thank you for any help to instal successfully.  Dr Koh

    Still looking for a solution to specific installation errors (see screeshot) referring to "Language Pack installation failure":
    ERROR: DW050: The following payload errors were found during install:
    ERROR: DW050: - Adobe Photoshop CS6 Core: Failed due to Language Pack installation failure
    ERROR: DW050: - Adobe Photoshop CS6 International English Language Pack_AdobePhotoshop13-en_GB: Install failed
    Unfortunately previous advice of using CCS cleaner tool, and suggestions from links for 1) "exit code 6 and 7" and 2) "Troubleshoot instal logs" did not work at all. So I am desparate to fix this because I have spent a lot of money purchasing Photoshop CS6 but have no functioning program. Surely Adobe can help solve this problem with installing, or else it means a lot of money spent on Photoshop CS6 for nothing. I am appealing directly to Adobe to help because I have come to the end of my options. I thank the forum for their suggestions but so far the solution for this specific "Language Pack installation failure" problem is missing. Thank you.
    Dr Koh

  • Error 1003 occurred at Open VI Reference in Dist Copy Non-VI Files.vi- Dist Build LLB Image.vi- Dist Build App Image.vi- Build Application.vi

    When trying to build  an application using labview 7.1 and windows XP,  I get the error
    Error 1003 occurred at Open VI Reference in Dist Copy Non-VI Files.vi->Dist Build LLB Image.vi->Dist Build App Image.vi->Build Application.vi
    I've tried the crtl-shift-run as well as  a mass compile and I still get the error.
    Any ideas?
    Thanks,
    Mike

    Hopefully this thread, or this KB article might help.
    It seems like this could come from a lot of things, but there's suggestions in those which might lead you in the right direction
    Message Edited by Day on 09-22-2006 02:07 PM

  • Images corrupted in application package.

    Hi All,
    I am using .png images in my application. After building the application. It creates myfirst.app ... if I right click it in finder and select "Show package Content" .. it shows list of resources. If I try to open the images (.png) ... some of those images are corrupted. But it the app works fine on the device .. and the images displayed are just fine.
    Why does it show's corrupted in package? I am trying to upload it to the app store. I get following message ..
    "The binary you uploaded was invalid. The signature was invalid, or it was not signed with an Apple submission certificate."
    can it be the same image issue?
    thanks.
    Kiran

    yes .. there was an option in the project settings which was compressing the images automatically .. I unchecked it .. and few changes in the project settings ... it worked ..
    thanks for the reply ..
    Kiran

  • Error while calling COM routines via application prog(return code 1028533-)

    Hello Expert,
    In Interactive Demand Planning ( /SAPAPO/SDP94 ), when I'm trying to load data in a planning book , error
    'Error while calling COM routines via application program (return code 1028533-)' is encountered.
    In my selection id, i have only two locations....there is no material selection. 
    When I select the 1st location and load the data its getting loaded properly.....but when i select the 2nd location and try loading data ...the above error is coming.
    I did run /SAPAPO/TS_LCM_CONS_CHECK but the problem persist.
    Any advise to fix this issue would be much appreciated.
    Thanks.
    Tom

    Hi Tom,
    Please see if below exiting threads help you.
    COM error 40134 in Interactive Planning on SCM 5.0 Support Pack SAPKY50011
    Error for COM Routine application program (return code 40028)
    Thukral

  • Finding Application Comments for a report

    Hello,
    Can anyone tell me what table or view I can access "Application Comments". I did a search on that an didn't find anything in this forum.
    I'm creating an application where other applications can be launched from while maintaining authentication (all in same workspace).
    I have the list of apex_applications.application_name as links in the report, but would like to add a description of the application in an adjacent column to the link. I thought the application comments would be a good feild to use if I can find it and join to the apex_applications view.
    I'm using APEX 4.1.0.00.32
    Thanks,
    Wayne

    Found by looking through C:\apex41\builder\f4000.sql for the create/view comments pages (p1236).
    select * from APEX_040100.WWV_FLOW_APP_COMMENTS;I've included a consolidated view of all application comments to the 4.2 wishlist
    Apex 4.2 wish list
    I didn't realise this information wasn't in the apex_dictionary already.

  • Problem in connection SUP 2.1 application and X-CODE 4.2.1

    Hello, I have a problem with the development of a native application in X-Code, is experiencing an error when making the connection between application server and SUP, this is the error "[ERROR] [SUPMessageClient.m: 47] - Operation failed, Unable to access the key, "someone has gone through this and can help me? I thank

    thanks for reply, I solved the problem...
    1 - I created a new user in SCC
    2 - I reset to default settings IOS Simulator

  • DISPLAYING IMAGES IN WEB APPLICATIONS

    When we store images in a column, we are having problems reading and displaying it on web applications.
    can somebody help?
    Thomas

    What version of Oracle do you use? What is the datatype of the column where images are stored? What are you using to read and display the images on web applications? Do you get any errors?

  • Comment out code in Update Rule

    Hello,
    Quick question.
    How do I comment out code in the update rule?  I need to comment out a large amount of code for testing purposes.
    Thanks,
    Sheila

    Hi Sheila
    Go to Update rule code (routine) ->> select the code you want to comment out with mouse ->> then go to top menu Utilities -> Block/Buffer-> Insert Comment *
    This will comment out the code that you had selected.
    Regards
    Pradip
    (don't forget points)

  • HT201210 in my phone when i open it appers a mesage with this message : error in application occured .error code : DF XX2700/6F1D WHAT'S THAT?

    in my phone when i open it appers a mesage with this message : error in application occured .error code : DF XX2700/6F1D WHAT'S THAT?

    i googled it - try a different sim card - did you go through a demagnetizer or something?

  • Can I upload images to an application in user mode

    Can I upload images to an application in user mode and make these images available in the server (in the IMAGES folder) -I mean not in Developing mode by openning the application and upload images to shared components-
    I saw the it's done in the Sample Application but I think it's complicated and ........... didn't get it.

    There's the chapter How to Upload and Download Files in an Application in the Advanced Tutorials. Worked for me, but took me some time.
    C.

  • Trouble installing I get Exit Code: 6

    Trouble installing I get Exit Code: 6. Brand new computer Windows 8.1
    Please see specific errors below for troubleshooting. For example, ERROR:
    -------------------------------------- Summary --------------------------------------
    - 0 fatal error(s), 2 error(s)
    ----------- Payload: Microsoft Visual C++ 2012 Redistributable Package (x64) 11.0.61030.0 {3E272A93-C06B-4206-AD02-0EBE02535E20} -----------
    ERROR: Third party payload installer vcredist_x64.exe failed with exit code: -2147024546
    ERROR: Failed to install Microsoft Visual C++ 2012 Redistributable Package (x64). Please try installing it by double clicking on the executable at "C:\Users\M\AppData\Local\Temp\{DED1BA74-560D-4A74-8990-B332AD56BADC}\Photoshop_15_LS20_w in64\Adobe CC 2014\payloads\Microsoft VC 2012 Redist (x64)\vcredist_x64.exe", or download and install the latest Microsoft Visual C++ 2012 Redistributable Package (x64) from Microsoft website - www.microsoft.com

    Errors "Exit Code: 6," "Exit Code: 7"
    Mylenium

Maybe you are looking for

  • How do I tell if my Ipod is 5th generation?

    I have an ipod, that I have had for 2 years. I have just spent £275 getting a Parrott car kit and ipod blue tooth installed in my car. After installing it, the ipod software isn't supported and according to Parrott, they only work with 5th generation

  • Why is the resolution of my Lion login screen so low?

    I just turned on my MacBook Air, and I found that the login screen was enlarged, in which it seemed to me that the resolution of the login screen was very low. But after logging in, the resolution went back to normal. How can I fix this?

  • Apache not listing all directories

    Hi, I am trying to transfer my LAMP application from Ubuntu to ArchLinux. Everything is fine in Ubuntu, but when I look at my page in Arch, some of the functions are missing. I installed firebug, and realized that users' pictures cannot be found, sin

  • Where are my actions?

    I just upgraded to CS5 from CS4, and My actions are not in CS5, I tried to find them in my actions folder of CS4 (going through the applicaitons folder and everything), but they are not there either. They are all there and work fine in CS4, but I can

  • When i download ios6, do i need to back anything up

    This is my first i product and just got the prompt to download ios6. Will my ipad stay the same or will it wipe it out. Do I need to back anything up. I am very tech challenged as you can tell. Thank you.