Help with images within an applet

I created a card game applet which calls images placed within the same directory. In appletviewer the game runs fine,not in browsers. I downloaded the browser plugin since i use swing classes. If I remove the image the applet loads up without the grafix. Here is the IO error generated. I thought applets can read files within the same directory and sub directories? Would creating a jar file solve this problem? Anyhelp would be appreciated.
java.security.AccessControlException: access denied (java.io.FilePermission main2.gif read)

You're running into the good old security issue. An applet in a browser can not simply refer to files in the same directory as the applet gets downloaded to the client and runs on their machine. Making references to local files has no effect.
Easiest way around this is to use URL's to your images to load them in.
Try using Applet.getImage(URL)
Rob.

Similar Messages

  • Help with images within applets

    I created a card game applet which calls images placed within the same directory. In appletviewer the game runs fine,not in browsers. I downloaded the browser plugin since i use swing classes. If I remove the image the applet loads up without the grafix. Here is the IO error generated. I thought applets can read files within the same directory and sub directories? Would creating a jar file solve this problem? Anyhelp would be appreciated.
    java.security.AccessControlException: access denied (java.io.FilePermission main2.gif read)

    When running in a browser, your applet must be signed in order to be able to access local resources. Check out the "Signed Applets" forum for many discussions about this, as well as methods for signing applets.

  • Help with image ready on ps3 extended

    I am pretty new to photo shop and have cs3 extended.
    I have a Yorkie website where I cut out my Yorkies and paste them to differnet backgrounds.... a lady that does the ANIMATED pictures  HAS DID A COUPLE FOR ME ....BUT I NEED TO LEARN TO DO THIS MYSELF.  She will not tell folks how to do:)
    The problem is once you work with a pic that is animated already then try to  add a dog.....by pasting....it removes the animation in the background pic.... and the picture no longer moves once the dog is added ?....She said she puts thru IMAGE READY...which I do not see anywhere on CS3 extended.  I will try to insert a pic she did for me and any help would be greatly appreciated....as I can do but then the picture is no longer animated once altered in my photoshop but she is doing somehow.....so has to be poss ?  If I were to do this pic it would stop moving once the dogs were added....plus not as good as her but practicing........could it be the fact she is doing in layers and I am doing copy and paste...I do know she puts thru Image ready and I do not know where this is located on cs3 extended or how to do?
    am

    well...........l when I try to open Gif with the import and chose the video frames to layers...am getting a message saying I need Quicktime 7.1 to be able to do??? and when selecting import that is the only option I have to open my animated picture?...YOU HAVE BEEN SO MUCH HELP!   THANK YOU SO MUCH...! 
       BLUE MONDAY EXCLUSIVES   
    Date: Sat, 17 Apr 2010 20:23:27 -0600
    From: [email protected]
    To: [email protected]
    Subject: Re: Help with image ready on ps3 extended
    I'm not sure anyone mentioned this but if not to open GIFs using the import you have to enter the GIF name as GIF isn't listed as one of the options.
    It sounds like you are viewing the images in a maximized screen mode. To view more than one document, press F to cycle through the screen modes. FYI, only the contents of the currently selected document can be viewed in the layers palette.
    I'll just talk about copy/paste so as not to confuse...
    If you are going to copy/paste, click the frame around the dog document to target it. Your layers palette will now contain the contents of the dog document. Click on the layer in the layers palette with the selected dog over transparency. With that layer highlighted in your layers palette, press Ctrl A; then Ctrl C. (Select<Select All; Edit<copy if you prefer using the menu.) This will copy that layer into your clipboard.
    Next, click the frame of the document containing the animation. Click the topmost layer in the layers palette because we want you dog to be in the top layer. Press Ctrl + V. (Edit<Paste if you prefer using the menu).
    Your dog is most likely going to be too big. Use Edit<Free Transform to size and move the dog to the desired location.
    At this point, your dog should be showing in each frame in the animation palette.
    Example:
    http://forums.adobe.com/servlet/JiveServlet/downloadImage/25315/with-palettes-open.jpg
    I'm using the older Image Ready me method. The highlighted place in the palette is where you switch methods between the old method and the new timeline. Notice, I have the layers and animation palette both in the workspace...and I'm not in a maximized mode. The red arrow shows the correlation between the frame and the layer represented by it in the layers palette.
    Image:second-image.jpg
    Here I have a second image to slip into my animation. I have the creature selected and on it's own layer with transparency around it. Notice that the the layer with the isolated creature is highlighted. At this stage, I'll press Ctrl + A; then Ctrl + C to select and save this image to my clipboard.
    Image:creature-added.jpg
    Here, I've pasted (Ctrl + V or Edit<Paste) in my creature and resized it (Ctrl + T or Edit<free transform) so he can be jumped. I also added a shadow under my creature which I added to a layer under my creature. Notice that when Frame on is selected in the animation palette that the eye is on both the creature and the shadow. If I click the eye to turn them (creature and shadow layer) off, they disappear from the entire animation. I can make them appear at any frame by clicking the desired frame in the animation then turning on the eye icon for the creature and shadow layer in the layers palette. I can also adjust opacity if desired.
    You could even more than the one image if you want the dog to appear to move. Use the eyeball visibility to determine which pose will be used for that frame.
    Example:
    Image:jump-creature-gif.gif
    Here, I used transform warp to adjust the pose of the creature for a few frames as he's jumping the creature...just for fun.
    >

  • Need help with paint() within applet

    Hi,
    I am having some problems in using the paint() method within an applet.
    I need to use drawString() in the paint() method.
    However, I discovered that when i used drawString() in paint() method.
    It clears the background which has other GUI components wipe out.
    Pls help, thanx
    Sample code:
    public class watever extends javax.swing.JApplet {
    //initialize some components and variables
    public void init() {
    //adding of components to contentPane
    public void paint(Graphics g) {
    g.drawString("The variable is " + sum, 80, 80);
    }

    super.paint(g) the paint method draws the components to, so if you override it and then never tell it to draw the components they don't get drawn.

  • Help!  Image in an applet

    Hi, I'm having some trouble displaying an image in my applet. I drew something in MS Paint, saved it as a gif, and want to draw it in my applet. I have tried using two methods to load the image:
    map = getImage(getCodeBase(),"cheese.gif");
    and
    Toolkit toolkit = getToolkit();
    map =toolkit.createImage("cheese.gif");
    System.out.println(map == null) prints false for both methods, meaning that (I assume) Java has found and knows what .gif I am requesting. I am drawing the image with
    g.drawImage(map, 25, 150, this);
    I have tried replacing "this" with "getContentPane()" as well, but that was fruitless.
    I think am importing all the right classes, like java.awt.*.
    My applet extends JApplet (I don't know this has anything to do with it). I would post the entire applet, but it is quite lengthy at the moment. Any help would be much appreciated, thanks in advance, and sorry about the long post. If anyone needs anymore information to help me, I will be glad to help.

    Try this html and code:
    <HTML>
        <HEAD>
            <TITLE></TITLE
        </HEAD>
        <BODY>
            <APPLET CODE="ImgApplet.class" width=500 height=500>
            <PARAM NAME=pic VALUE="ImgAppletPic.jpg">
            </APPLET>
        </BODY>
    </HTML>
    import java.awt.*;
    import java.applet.*;
    public class ImgApplet extends Applet {
        // var to store the pic;
        Image pic;
            // retrieving image;
            public void init() {
            pic = getImage(getCodeBase(), getParameter("pic"));
            public void paint(Graphics g) {
            g.drawImage(pic, 10, 10, this);
    }

  • Help with images in Spry menus

    I need help making this work: I want my menu buttons and
    submenu buttons to be images rather than text. I've been able to
    set it up to use different images for each of the main and
    sub-level buttons, but only for the active state. I cannot figure
    out how to use a different set of "hover images" for the hover
    state. Note-- Each button and submenu button in the entire menu are
    different images, so I suspect I need to use different ID's for
    each, but I am not sure how to set that up in the
    SpryMenuBarHorizontal.css file for each different button in, at
    least, the active and hover states. Can anyone offer some help with
    this?:

    V1 - Thank you for the suggestion, but this does not exactly
    solve my dilemma. In its simplest terms, this is what I want to do:
    Create a single drop-down menu where there is "Item 1" with
    submenus "Item 1.1", "Item 1.2", and "Item 1.3". But, I want to use
    different images for each item and subitem in their Active and
    Hover states. So, in this example, there would be 8 different
    images... An Active and a Hover image for each of Item 1, Item 1.1,
    Item 1.2 and Item 1.3.

  • [CS3][JS] Help with image resizing

    I'm still a newbie of ID scripting.
    I'm using js scripting in Indesign CS3 to make an auto-impaginator and I have a problem with images.
    I charged my contents from an xml set of tables, that I put into a fixed textFrame of the master page.
    Because of the table needs to fill multiple pages, I made a function that keep creating pages and link the textFrames so that the table continues in various pages.
    In this whole process I have some images too, that I need to resize them to fill the cell, because now they pass the parent cell.
    I found a method that looks at the bounds and resizes the image and the rectangle too, but it doesn't work always, because if a image is overflowing, it hasn't any bound and it fails, and this causes other problems in my process, so I would find another method.
    So:
    Is there another way to resize an image on-the-way while importing it? Some xml attribute or preference?
    Or some method that works also if the image is overflowing?

    These forums are pointless. Adobe must believe that other users will cut the mustard. Absolutely a waste of effort for everyone. Adobe should PAY at least a junior developer involved in the projects to monitor and help with these posts. FLEX rules yeah and thousands more do scripting than develop plug ins...
    Come on Adobe, step up your better than this. Customer Service can be free to the customers ... we are not talking about GET IT ALL FREE, talking about buy it and create a community and support it, but then again LAYERS and INDESIGN SECRETS have people who actually want to help users rather than rabbit hole everything.
    Please join hands and SING...

  • Urgent Help with Image Gallery

    Hi,
    I really need help with an image gallery i have created. Cannot think of a resolution
    So....I have a dynamic image gallery that pulls the pics into a movie clip and adds them to the container (slider)
    The issue i am having is that when i click on this i am essentially clicking on all the items collectively and i would like to be able to click on each image seperately...
    Please see code below
    var xml:XML;
    var images:Array = new Array();
    var totalImages:Number;
    var nbDisplayed:Number = 1;
    var imagesLoaded:int = 0;
    var slideTo:Number = 0;
    var imageWidth = 150;
    var titles:Array = new Array();
    var container_mc:MovieClip = new MovieClip();
    slider_mc.addChild(container_mc);
    container_mc.mask = slider_mc.mask_mc;
    function loadXML(file:String):void{
    var xmlLoader:URLLoader = new URLLoader();
    xmlLoader.load(new URLRequest(file));
    xmlLoader.addEventListener(Event.COMPLETE, parseXML);
    function parseXML(e:Event):void{
    xml = new XML(e.target.data);
    totalImages = xml.children().length();
    loadImages();
    function loadImages():void{
    for(var i:int = 0; i<totalImages; i++){
      var loader:Loader = new Loader();
      loader.load(new URLRequest("images/"+String(xml.children()[i].@brand)));
      images.push(loader);
    //      loader.contentLoaderInfo.addEventListener(ProgressEvent.PROGRESS,onProgress);
         loader.contentLoaderInfo.addEventListener(Event.COMPLETE,onComplete);
    function onComplete(e:Event):void{
    imagesLoaded++;
    if(imagesLoaded == totalImages){
      createImages();
    function createImages():void{
    for(var i:int = 0; i < images.length; i++){
      var bm:Bitmap = new Bitmap();
      bm = Bitmap(images[i].content);
      bm.smoothing = true;
      bm.x = i*170;
      container_mc.addChild(bm);
          var caption:textfile=new textfile();
          caption.x=i*170; // fix text positions (x,y) here
       caption.y=96;
          caption.tf.text=(xml.children()[i].@brandname)   
          container_mc.addChild(caption);

    yes, sorry i do wish to click on individual images but dont know how to code that
    as i mentioned i have 6 images that load into an array and then into a container and i think that maybe the problem is that i have the listener on the container so when i click on any image it gives the same results.
    what i would like is have code thats says
    if i click on image 1 then do this
    if i click on image 2 then do something different
    etc
    hope that makes sense
    thanks for you help!

  • Need help with navigation within a spark list...

    hey guys, so in my application when you click on a list item, it opens up an image, and along with the image a few buttons are created dynamically...
    the image and the url/labels for the dynamic buttons is provided through an xml/xmlListCollection.
    what i need help with is the url or more specifically when you click on one of these dynamic buttons it needs to navigate me to another part of an list or display a certain set of images that is not in my spark list...
    please let me know if this makes no sence
    the code i have is
    <code>
        [Bindable] private var menuXml:XML;
        [Bindable] private var imgList:XMLListCollection = new XMLListCollection();
        [Bindable] private var navControl:XMLListCollection = new XMLListCollection();
        [Bindable] private var fullList:XMLListCollection = new XMLListCollection();
        private var returnedXml:XMLListCollection = new XMLListCollection();
        private var myXmlSource:XML = new XML();
        //[Bindable] private var xmlReturn:Object;
        private var currImage:int = 0;
        //public var userOpProv:XMLListCollection = new XMLListCollection();
        //private var troubleShootProvider:XMLListCollection = new XMLListCollection();
        private function myXml_resultHandeler(event:ResultEvent):void{
            userOptionProvider.source = event.result.apx32.userOptions.children();
            troubleShootProvider.source = event.result.apx32.troubleShooting.children();
            fullList.source = event.result.apx32.children();
            returnedXml.source = event.result[0].children();
            myXmlSource = event.result[0];
        private function myXml_faultHandler(event:FaultEvent):void{
            Alert.show("Error loading XML");
            Alert.show(event.fault.message);
        private function app_creationComplete(event:FlexEvent):void{
            userOptions.scroller.setStyle("horizontalScrollPolicy", ScrollPolicy.OFF);
            myXml.send();
            //trouble.scroller.setStyle("horizontalScrollPolicy", ScrollPolicy.OFF);
            myXml = new HTTPService();
            myXml.url = "modules/apx32/apx32TroubleshootingXml.xml";
            myXml.resultFormat = "e4x";
            myXml.addEventListener(ResultEvent.RESULT, myXml_resultHandeler);
            myXml.addEventListener(FaultEvent.FAULT, myXml_faultHandler);
            myXml.send();
        private function troubleShootChange(event:IndexChangeEvent):void{
            dynamicButtons.removeAllElements();
            navControl.source = troubleShootProvider[event.newIndex].children();
            currImage = 0;
            imgList.source = troubleShootProvider[event.newIndex].images.children();
            definition.source = imgList[currImage].@url;
            if(imgList[currImage].@details == "true"){
                if(imgList[currImage].buttons.@hasButtons == "true"){
                    for each(var item:XML in imgList[currImage].buttons.children()){
                        var newButton:LinkButton = new LinkButton();
                        newButton.label = item.@name;
                        newButton.x = item.@posX;
                        newButton.y = item.@posY;
                        newButton.setStyle("skin", null);
                        newButton.styleName = "dynamicButtonStyle";
                        dynamicButtons.addElement(newButton);
            //var isMultiPage:String = navControl[2]["multiPages"];
            //trace(isMultiPage);
            //        if(isMultiPage){
            if(currImage >= imgList.length - 1){
                next.visible = false;
                back.visible = false;
            else{
                back.visible = false;
                next.visible = true;
        private function customButtonPressed(event:Event):void{
            if(imgList[currImage].button.@changeTo != ""){
        private function userOptionsChange(event:IndexChangeEvent):void{
            dynamicButtons.removeAllElements();
            navControl.source = userOptionProvider[event.newIndex].children();
            currImage = 0;
            imgList.source = userOptionProvider[event.newIndex].images.children();
            definition.source = imgList[currImage].@url;
            if(imgList[currImage].@details == "true"){
                if(imgList[currImage].buttons.@hasButtons == "true"){
                    for each(var item:XML in imgList[currImage].buttons.children()){
                        var newButton:LinkButton = new LinkButton();
                        newButton.label = item.@name;
                        newButton.x = item.@posX;
                        newButton.y = item.@posY;
                        newButton.setStyle("skin", null);
                        newButton.styleName = "dynamicButtonStyle";
                        newButton.addEventListener(MouseEvent.MOUSE_DOWN, customButtonPressed);
                        dynamicButtons.addElement(newButton);
            var isMultiPage:String = navControl[2]["multiPages"];
            if(isMultiPage == "true"){
                if(navControl[2]["next"] == "NEXT STEP"){
                    navContainer.x = 630;
                else{
                    navContainer.x = 640;
                next.label = navControl[2]["next"];
                back.label = navControl[2]["back"];
            if(currImage >= imgList.length - 1){
                next.visible = false;
                back.visible = false;
            else{
                back.visible = false;
                next.visible = true;
        private function nextClickHandler(event:MouseEvent):void{
            currImage += 1;
            dynamicButtons.removeAllElements();
            if(currImage >= imgList.length-1){
                currImage = imgList.length - 1;
                //next.visible = false;
                next.label = "YOU'RE DONE";
            else
                next.label = navControl[2]["next"];
            back.visible = true;
            if(imgList[currImage].@details == "true"){
                if(imgList[currImage].buttons.@hasButtons == "true"){
                    for each(var item:XML in imgList[currImage].buttons.children()){
                        var newButton:LinkButton = new LinkButton();
                        newButton.label = item.@name;
                        newButton.x = item.@posX;
                        newButton.y = item.@posY;
                        newButton.setStyle("skin", null);
                        newButton.styleName = "dynamicButtonStyle";
                        dynamicButtons.addElement(newButton);
            definition.source = imgList[currImage].@url;
        private function backClickHandler(event:MouseEvent):void{
            currImage -= 1;
            dynamicButtons.removeAllElements();
            if(currImage == 0){
                back.visible = false;
            next.visible = true;
            next.label = navControl[2]["next"];
            if(imgList[currImage].@details == "true"){
                if(imgList[currImage].buttons.@hasButtons == "true"){
                    for each(var item:XML in imgList[currImage].buttons.children()){
                        var newButton:LinkButton = new LinkButton();
                        newButton.label = item.@name;
                        newButton.x = item.@posX;
                        newButton.y = item.@posY;
                        newButton.setStyle("skin", null);
                        newButton.styleName = "dynamicButtonStyle";
                        dynamicButtons.addElement(newButton);
            definition.source = imgList[currImage].@url;
    </code>
    i have attached a copy of the xml that i have right now to this post for reference...
    any help will be greatly appretiated!!! i've been stuck on this problem for the last week and my project is due soon
    again thank you in advance...

    hey david... just nevermind my previous post... I was able to subclass a link button, so i now have two variables that get assigned to a link button,
    one is "tabId" <-- contains the information on which tab to swtich to, and the second is, "changeTo"... this contans the label name which it needs to switch to
    I'm just stuck on how to change my selected item in my tabNavigator/list
    the code i have right now is
        private function customButtonPressed(event:Event):void{
            if(event.currentTarget.tabId == "troubleShooting"){
                for each(var item:Object in troubleShootProvider){
                    if(item.@label == event.currentTarget.changeTo){
        private function userOptionsChange(event:IndexChangeEvent):void{
            dynamicButtons.removeAllElements();
            navControl.source = userOptionProvider[event.newIndex].children();
            currImage = 0;
            imgList.source = userOptionProvider[event.newIndex].images.children();
            definition.source = imgList[currImage].@url;
            if(imgList[currImage].@details == "true"){
                if(imgList[currImage].buttons.@hasButtons == "true"){
                    for each(var item:XML in imgList[currImage].buttons.children()){
                        var newButton:customLinkButton = new customLinkButton();
                        newButton.label = item.@name;
                        newButton.tabId = item.@tab;
                        newButton.changeTo = item.@changeTo;
                        newButton.x = item.@posX;
                        newButton.y = item.@posY;
                        newButton.setStyle("skin", null);
                        newButton.styleName = "dynamicButtonStyle";
                        newButton.addEventListener(MouseEvent.MOUSE_DOWN, customButtonPressed);
                        dynamicButtons.addElement(newButton);
            var isMultiPage:String = navControl[2]["multiPages"];
            var videoPresent:String = navControl[1]["videoPresent"];
            if(videoPresent == "true"){
                if(isMultiPage != "true"){
                    navContainer.x = 825;
            if(isMultiPage == "true"){
                if(navControl[2]["next"] == "NEXT STEP"){
                    navContainer.x = 630;
                else{
                    navContainer.x = 640;
                next.label = navControl[2]["next"];
                back.label = navControl[2]["back"];
            if(currImage >= imgList.length - 1){
                next.visible = false;
                back.visible = false;
            else{
                back.visible = false;
                next.visible = true;
    as you know, my xml gets divided into two saperate xmllistcollections one is the userOptionProvider, and the troubleshootingProvider
    as is in the following xml
    <mx:TabNavigator id="tabNav" width="275" tabStyleName="tabStyle" fontWeight="bold" height="400" paddingTop="0"
                             tabWidth="137.5" creationPolicy="all" borderVisible="false">
                <mx:VBox label="USER OPTIONS" width="100%" height="100%" horizontalScrollPolicy="off" verticalScrollPolicy="off">
                    <s:List id="userOptions" width="100%" height="100%" itemRenderer="modules.apx32.myComponents.listRenderer"
                            borderVisible="false" contentBackgroundColor="#e9e9e9"
                            change="userOptionsChange(event)">
                        <s:dataProvider>
                            <s:XMLListCollection id="userOptionProvider" />
                        </s:dataProvider>
                    </s:List>
                </mx:VBox>
                <mx:VBox label="TROUBLESHOOTING">
                    <s:List id="trouble" width="100%" height="100%" itemRenderer="modules.apx32.myComponents.listRenderer"
                            borderAlpha="0" borderVisible="false" contentBackgroundColor="#e9e9e9"
                            change="troubleShootChange(event)">
                        <s:dataProvider>
                            <s:XMLListCollection id="troubleShootProvider" />
                        </s:dataProvider>
                    </s:List>
                </mx:VBox>
            </mx:TabNavigator>
    Im having some trouble updating my list... basically change to the troubleshooting tab, and then select the one that i need...
    hopefully that makes sence...

  • Help with images.....pliiiizzzzzz

    Im new to java and need help inserting images on a GUI! Does anyone have any programs or snippets of code that've done this successfully - preferrably using the GridBagLayout as well as in swing? If you have anything that works well, feel free to send me the entire java file ([email protected]) or just post it!

    Just create a JLabel with an image icon and you are able to display any JPEG and GIF image. You might take a look at the following:
    http://java.sun.com/docs/books/tutorial/uiswing/components/label.html
    Hope this helps,
    Pierre

  • Help with image viewer

    Would love some help with this one.. I am new so please bare with me. This app just reads contents of a txt file. What I am trying to add is the ability to display an image inside the program frame with scrolls bars.
    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.*;
    import java.io.*;
    public class Viewer extends JFrame
       private JMenuBar menuBar;
       private JMenu fileMenu;
       private JMenu fontMenu;
       private JMenuItem newItem;
       private JMenuItem openItem;
       private JMenuItem saveItem;
       private JMenuItem saveAsItem;
       private JMenuItem exitItem;
       private JRadioButtonMenuItem monoItem;
       private JRadioButtonMenuItem serifItem;
       private JRadioButtonMenuItem sansSerifItem;
       private JCheckBoxMenuItem italicItem;
       private JCheckBoxMenuItem boldItem;
       private String filename;
       private JTextArea editorText;
         private JLabel label;
       private final int NUM_LINES = 20;
       private final int NUM_CHARS = 40;
       public Viewer()
          setTitle("Viewer");
          setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
          editorText = new JTextArea(NUM_LINES, NUM_CHARS);
          editorText.setLineWrap(true);
          editorText.setWrapStyleWord(true);
          JScrollPane scrollPane = new JScrollPane(editorText);
          add(scrollPane);
          buildMenuBar();
          pack();
          setVisible(true);
       private void buildMenuBar()
          buildFileMenu();
          buildFontMenu();
          menuBar = new JMenuBar();
          menuBar.add(fileMenu);
          menuBar.add(fontMenu);
          setJMenuBar(menuBar);
       private void buildFileMenu()
          newItem = new JMenuItem("New");
          newItem.setMnemonic(KeyEvent.VK_N);
          newItem.addActionListener(new NewListener());
          openItem = new JMenuItem("Open");
          openItem.setMnemonic(KeyEvent.VK_O);
          openItem.addActionListener(new OpenListener());
          saveItem = new JMenuItem("Save");
          saveItem.setMnemonic(KeyEvent.VK_S);
          saveItem.addActionListener(new SaveListener());
          saveAsItem = new JMenuItem("Save As");
          saveAsItem.setMnemonic(KeyEvent.VK_A);
          saveAsItem.addActionListener(new SaveListener());
          exitItem = new JMenuItem("Exit");
          exitItem.setMnemonic(KeyEvent.VK_X);
          exitItem.addActionListener(new ExitListener());
          fileMenu = new JMenu("File");
          fileMenu.setMnemonic(KeyEvent.VK_F);
          fileMenu.add(newItem);
          fileMenu.add(openItem);
          fileMenu.addSeparator();
          fileMenu.add(saveItem);
          fileMenu.add(saveAsItem);
          fileMenu.addSeparator();
          fileMenu.add(exitItem);
       private void buildFontMenu()
          monoItem = new JRadioButtonMenuItem("Monospaced");
          monoItem.addActionListener(new FontListener());
          serifItem = new JRadioButtonMenuItem("Serif");
          serifItem.addActionListener(new FontListener());
          sansSerifItem =
                  new JRadioButtonMenuItem("SansSerif", true);
          sansSerifItem.addActionListener(new FontListener());
          ButtonGroup group = new ButtonGroup();
          group.add(monoItem);
          group.add(serifItem);
          group.add(sansSerifItem);
          italicItem = new JCheckBoxMenuItem("Italic");
          italicItem.addActionListener(new FontListener());
          boldItem = new JCheckBoxMenuItem("Bold");
          boldItem.addActionListener(new FontListener());
          fontMenu = new JMenu("Font");
          fontMenu.setMnemonic(KeyEvent.VK_T);
          fontMenu.add(monoItem);
          fontMenu.add(serifItem);
          fontMenu.add(sansSerifItem);
          fontMenu.addSeparator();
          fontMenu.add(italicItem);
          fontMenu.add(boldItem);
       private class NewListener implements ActionListener
          public void actionPerformed(ActionEvent e)
             editorText.setText("");
             filename = null;
       private class OpenListener implements ActionListener
          public void actionPerformed(ActionEvent e)
             int chooserStatus;
             JFileChooser chooser = new JFileChooser();
             chooserStatus = chooser.showOpenDialog(null);
             if (chooserStatus == JFileChooser.APPROVE_OPTION)
                File selectedFile = chooser.getSelectedFile();
                filename = selectedFile.getPath();
                if (!openFile(filename))
                   JOptionPane.showMessageDialog(null,
                                    "Error reading " +
                                    filename, "Error",
                                    JOptionPane.ERROR_MESSAGE);
          private boolean openFile(String filename)
             boolean success;
             String inputLine, editorString = "";
             FileReader freader;
             BufferedReader inputFile;
                   label = new JLabel();
                    add(label);
             try
                freader = new FileReader(filename);
                inputFile = new BufferedReader(freader);
                inputLine = inputFile.readLine();
                while (inputLine != null)
                   editorString = editorString +
                                  inputLine + "\n";
                   inputLine = inputFile.readLine();
                editorText.setText(editorString);
                inputFile.close(); 
                success = true;
             catch (IOException e)
                success = false;
             return success;
       private class SaveListener implements ActionListener
          public void actionPerformed(ActionEvent e)
             int chooserStatus;
             if (e.getActionCommand() == "Save As" ||
                 filename == null)
                JFileChooser chooser = new JFileChooser();
                chooserStatus = chooser.showSaveDialog(null);
                if (chooserStatus == JFileChooser.APPROVE_OPTION)
                   File selectedFile =
                                 chooser.getSelectedFile();
                   filename = selectedFile.getPath();
             if (!saveFile(filename))
                JOptionPane.showMessageDialog(null,
                                   "Error saving " +
                                   filename,
                                   "Error",
                                   JOptionPane.ERROR_MESSAGE);
          private boolean saveFile(String filename)
             boolean success;
             String editorString;
             FileWriter fwriter;
             PrintWriter outputFile;
             try
                fwriter = new FileWriter(filename);
                outputFile = new PrintWriter(fwriter);
                editorString = editorText.getText();
                outputFile.print(editorString);
                outputFile.close();
                success = true;
             catch (IOException e)
                 success = false;
             return success;
       private class ExitListener implements ActionListener
          public void actionPerformed(ActionEvent e)
             System.exit(0);
       private class FontListener implements ActionListener
          public void actionPerformed(ActionEvent e)
             Font textFont = editorText.getFont();
             String fontName = textFont.getName();
             int fontSize = textFont.getSize();
             int fontStyle = Font.PLAIN;
             if (monoItem.isSelected())
                fontName = "Monospaced";
             else if (serifItem.isSelected())
                fontName = "Serif";
             else if (sansSerifItem.isSelected())
                fontName = "SansSerif";
             if (italicItem.isSelected())
                fontStyle += Font.ITALIC;
             if (boldItem.isSelected())
                fontStyle += Font.BOLD;
             editorText.setFont(new Font(fontName,
                                    fontStyle, fontSize));
       public static void main(String[] args)
          Viewer ve = new Viewer();
    }I tried using JLabel() but I cant seem to make it work. Whenever i browse and select a .jpg it displays "�������t���o\�[��+�p��B3�+�p��B3�"                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               

    In the future, Swing related questions should be posted in the Swing forum.
    Whenever i browse and select a .jpg it displays "�������t���o\�[��+�p��B3�+�p��B3�" You can read in a jpg file and treat it like a text file.
    Read the Swing tutorial on [url http://java.sun.com/docs/books/tutorial/uiswing/components/icon.html]How to Use Icons for the proper way to read images.

  • Help with Times Table GUI applet

    Hello,
    I need help with an applet which inputs an integer from the user and displays the appropiate times table up to times 10 eg; user input 5 - display shows
    5 time 1 is 5
    5 times 2 is 10
    5 times 10 is 50.
    I have only managedt o get the display to show one statement eg 5 times 1 - I have tried using a for loop to show the whole table - but unlike a print statement each time the loop goes round it overwrites the data in the display box with the new data - any help would be much appreciated.
    Note: it is for a programming course year 1 exercise - so I can only use basic constructs or loops to achieve this. Thanks in advance! Heres what I have so far:
    import java.applet.* ;
    import java.awt.* ;
    import java.awt.event.* ;
    public class TimesTableApplet extends Applet implements ActionListener
         // Declare the GUI components globally
         Label titleLabel, whichTableLabel ;
         TextField whichTableBox, resultBox ;
         Button showTableButton, clearButton ;
         // Declare integer variables for holdind the number input by the user,
         // the times number, and the result number
         int whichTable, times=1, result ;
         // Declare variables to hold string versions of the three integer variables
         // above, for placing in the TextFields
         String whichTableString, timesString, resultString ;
         public void init ()
              // Create the Labels
              titleLabel = new Label ( "Times Table" ) ;
              whichTableLabel = new Label ( "Which Table?" ) ;
              // Create the TextFields
              whichTableBox = new TextField ( 5 ) ;
              resultBox = new TextField ( 30 ) ;
              // Create the Buttons
              showTableButton = new Button ( "Show Table" ) ;
              clearButton = new Button ( "Clear" ) ;
              // Add the components to the applet window
              add ( titleLabel ) ;
              add ( whichTableLabel ) ;
              add ( whichTableBox ) ;
              whichTableBox.addActionListener ( this ) ;
              add ( resultBox ) ;
              resultBox.setEditable ( false ) ;
              add ( showTableButton ) ;
              showTableButton.addActionListener ( this ) ;
              add ( clearButton ) ;
              clearButton.addActionListener ( this ) ;
         } // End of init method
         public void actionPerformed ( ActionEvent event )
              // Find out which button generated the event
              String arg = event.getActionCommand () ;
              // If the user clicks the clear button, clear the whichTableBox and
              // resultBox
              if ( arg.equals ( "Clear" ) )
                   whichTableBox.setText ( "" ) ;
                   resultBox.setText ( "" ) ;
              else
                   try
                        // Try extracting a string from the whichTableBox ( the users input )
                        // and converting it to an integer
                        whichTableString = whichTableBox.getText () ;
                        whichTable = Integer.parseInt ( whichTableString ) ;
                        // Clear status box
                        showStatus ( "" ) ;
                        // If the user clicks the showTableButton, display the appropiate
                        // times table up to times 10
                        if ( arg.equals ( "Show Table" ) ) ;
                             result = whichTable * times ;
                             timesString = Integer.toString ( times ) ;
                             resultString = Integer.toString ( result ) ;
                             resultBox.setText ( whichTableString + " times " + timesString + " is " + resultString ) ;
                   } // End of try block
                   catch ( NumberFormatException entry )
                        // Display error message and clear whichTableBox
                        showStatus ( "Error: Invalid Input - not an integer!" ) ;
                        whichTableBox.setText ( "" ) ;
                   } // End of catch block
              } // End of else statement
         } // End of actionPerformed method
    } // End of class

    use this code, please arrange your User interface correctly.
    * TimesTableApplet.java
    * Created on March 12, 2007, 12:08 PM
    * @author cc.woon
    import java.applet.* ;
    import java.awt.* ;
    import java.awt.event.* ;
    public class TimesTableApplet extends Applet implements ActionListener
    // Declare the GUI components globally
    Label titleLabel, whichTableLabel ;
    TextField whichTableBox ;
    TextArea resultBox;
    Button showTableButton, clearButton ;
    // Declare integer variables for holdind the number input by the user,
    // the times number, and the result number
    int whichTable, times=1, result ;
    // Declare variables to hold string versions of the three integer variables
    // above, for placing in the TextFields
    String whichTableString, timesString, resultString ;
    public void init ()
    // Create the Labels
    titleLabel = new Label ( "Times Table" ) ;
    whichTableLabel = new Label ( "Which Table?" ) ;
    // Create the TextFields
    whichTableBox = new TextField ( 5 ) ;
    resultBox = new TextArea() ;
    // Create the Buttons
    showTableButton = new Button ( "Show Table" ) ;
    clearButton = new Button ( "Clear" ) ;
    // Add the components to the applet window
    add ( titleLabel ) ;
    add ( whichTableLabel ) ;
    add ( whichTableBox ) ;
    whichTableBox.addActionListener ( this ) ;
    add ( resultBox ) ;
    resultBox.setEditable ( false ) ;
    add ( showTableButton ) ;
    showTableButton.addActionListener ( this ) ;
    add ( clearButton ) ;
    clearButton.addActionListener ( this ) ;
    } // End of init method
    public void actionPerformed ( ActionEvent event )
    // Find out which button generated the event
    String arg = event.getActionCommand () ;
    // If the user clicks the clear button, clear the whichTableBox and
    // resultBox
    if ( arg.equals ( "Clear" ) )
    whichTableBox.setText ( "" ) ;
    resultBox.setText ( "" ) ;
    else
    try
    // Try extracting a string from the whichTableBox ( the users input )
    // and converting it to an integer
    whichTableString = whichTableBox.getText () ;
    whichTable = Integer.parseInt ( whichTableString ) ;
    // Clear status box
    showStatus ( "" ) ;
    // If the user clicks the showTableButton, display the appropiate
    // times table up to times 10
    if ( arg.equals ( "Show Table" ) ) ;
    result = whichTable * times ;
    timesString = Integer.toString ( times ) ;
    String output = "";
    for(int i =1;i<=10;i++){
    output += whichTable +" times "+i + ": "+(i*whichTable)+"\n";
    resultString = Integer.toString ( result ) ;
    //resultBox.setText ( whichTableString + " times " + timesString + " is " + resultString ) ;
    resultBox.setText ( output) ;
    } // End of try block
    catch ( NumberFormatException entry )
    // Display error message and clear whichTableBox
    showStatus ( "Error: Invalid Input - not an integer!" ) ;
    whichTableBox.setText ( "" ) ;
    } // End of catch block
    } // End of else statement
    } // End of actionPerformed method
    } // End of class

  • Help with Images Maps,

    Hi,
    I have an HTML page where an IMG is loaded:
    <img src="images/renders/Main_Image.jpeg" alt="Main Image" name="Main_IMG" width="800" height="600" border="0" usemap="#Main_MAP" id="Main_IMG" />
    Then I have 4 images maps laid on top of the image:
    <map name="Main_MAP" id="Main_MAP">
      <area shape="poly" coords="--some numbers--" href="Area1.html" target="_parent" alt="Area1 Button" />
      <area shape="poly" coords="--some numbers--" href="Area2.html" target="_parent" alt="Area2 Button"  />
      <area shape="poly" coords="--some numbers--" href="Area3.html" target="_parent" alt="Area3 Button" />
      <area shape="poly" coords="--some numbers" href="Area4.html" target="_parent" alt="Area4 Button"/>
    </map>
    See Example:
    Each area is essentially an invisible button. I want to make it so when the mouse hovers over the areas, I want the background image to display something different. On mouse out of the area, I want the image to go back. When the user clicks the Area, the user is moved to another part of the site.
    Area 1 should change Main_Image.jpeg to Main_Image1.jpeg
    Area 2 should change Main_Image.jpeg to Main_Image2.jpeg
    etc.
    I thought I could do this with Images Maps, but I can't figure out how. Is there an easier way? I have Dreamweaver CS4.
    Thank you in advance!

    Hey CF. Thank you very much for the reply! I thought I was losing my mind trying to figure out a way.
    I'll try out the slice and dice approach... where's a turtle when you need one.
    Cheers Dude.
    S

  • Need help with bufferstrategy in a applet

    im getting the following errors that its not public in class component
    but in the api it says it's public heres the error.
    can anyone help ?
    heres the code and error
    import java.awt.*;
    import java.applet.*;
    import java.awt.event.*;
    import java.awt.image.*;
    //implements Runnable,KeyListener,MouseListener,MouseMotionListener
    public class memImgSrcApplet extends Applet
    MemoryImageSource producerobj;
    Image img;
    boolean done = false;
    int w,h,cx,cy;long nofloops =0;
    int [] pixels;
    DirectColorModel colorModel;
    MemoryImageSource source;
    BufferStrategy strategy;
      public void init(){
       System.out.println(" init " );
       GraphicsDevice device = GraphicsEnvironment.getLocalGraphicsEnvironment().getDefaultScreenDevice();
       //setUndecorated(true);// knock out bars and stuff
       setIgnoreRepaint(true);// ignore automatic repaint.
       show();//show fullscreen.
        w = getSize().width;h = getSize().height;
        pixels = new int[w * h];
        colorModel = new DirectColorModel(32, 0x00FF0000, 0x0000FF00, 0x000000FF,0);
        source = new MemoryImageSource(w, h, colorModel, pixels, 0, w);
        source.setAnimated(true);
        Image img = createImage(source);
        createBufferStrategy(2);
        strategy = this.getBufferStrategy();
      public void run(){
       System.out.println(" run " );
       int j =0;
       long t = System.currentTimeMillis();
       while(j < 1000){
       j++;
       for (int n=pixels.length; --n>=0;){ pixels[n] = n+j;}
       source.newPixels();
       Graphics g = strategy.getDrawGraphics();
       g.drawImage(img, 0, 0, null);
       strategy.show();
       System.out.println(" 1000 frames in  milliseconds elapsed "+(System.currentTimeMillis()-t)+" seconds "+(System.currentTimeMillis()-t)/1000f );
       System.out.println(" fps "+( 1000f/ ((System.currentTimeMillis()-t) /1000f )) );
      public void start(){
      System.out.println(" start " );
      public void stop(){
      System.out.println(" stop " );
         //public void paint(Graphics g){System.out.println(" paint " );}
    }     C:\myjava\documents downloaded\fullscreen\memImgSrcApplet.java:30: createBufferStrategy(int) is not public in java.awt.Component; cannot be accessed from outside package
    createBufferStrategy(2);
    ^
    C:\myjava\documents downloaded\fullscreen\memImgSrcApplet.java:31: getBufferStrategy() is not public in java.awt.Component; cannot be accessed from outside package
    strategy = this.getBufferStrategy();
    ^
    Note: C:\myjava\documents downloaded\fullscreen\memImgSrcApplet.java uses or overrides a deprecated API.
    Note: Recompile with -deprecation for details.
    2 errors
    Exit code: 1
    There were errors
    and i have no idea why im geting the depreciation note

    I think if you use BufferStrategy in an Applet, you have to do it on a Canvas and add the Canvas to the Applet. I'll have to check to make sure.

  • Help with Captions, within Slideshows

    I'm struggling with trying to figure out how to customize the size and location of caption boxes, within each image of a slideshow. It seems that, once an initial caption box has been set in the first image, it appears in all consecutive images at the same location and size, with no means of individually controlling them. Am I overlooking something? Is there a way to customize the size and location of all captions within one slideshow? Your help/advise would be greatly appreciated.  ~Thank you

    hi DubuqueIA,
    what do you mean by "Follow the same steps given under "Slideshow with thumbnail" tu updated captions" ?? where are these steps?
    i btw have the same problem: edit together active or not - it always changes the size of all my captions. i just want one of my captions to be wider.

Maybe you are looking for

  • When on family sharing how can I use the credit on my account instead of the family credit card?

    I have a credit of $5.90 that already existed before being added to family sharing. The only pay option is the family credit card, and not my existing credit. I want to finish up my credit first. How can I do this? I've tried on my iPad, my iPhone, a

  • Error while posting asset acquisition

    hai while posting asset acquisition in f-90 iam getting error that "asset is incomplete' when analysed using RAUNVA00 , it is asking to update field group-22 i.e scrap value, but this field is not found in asset master, pls help me. thank u shivaji.a

  • Synchronising calendar on Lumia 520 with iPad

    I can synchronise from my phone to PC but not the other way around i.e. From my PC to phone. What I really want to do though is synchronise between my iPad and phone. Can anyone help ?

  • Maintainance Duration of BW 3.1 and BW3.5

    Hello, i'm just searching for the maintaince Duration of the BW Releases 3.1 and 3.5. Is there a site on the marketplace,where I can find the excact an reliable information. Thanx

  • Change status of workitem in his method (ABAP OO)

    Hello! I have class Z_TTT with implementation IF_WORKFLOW. And I have method DISPLAY of this class. This method executing in task. How can I change status of this task inside method DISPLAY thus task not to be completed after executing. (In BOR I cou