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.
Similar Messages
-
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. -
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.
-
I need help with the Quote applet.
Hey all,
I need help with the Quote applet. I downloaded it and encoded it in the following html code:
<html>
<head>
<title>Part 2</title>
</head>
<body>
<applet codebase="/demo/quote/classes" code="/demo/quote/JavaQuote.class"
width="300" height="125" >
<param name="bgcolor" value="ffffff">
<param name="bheight" value="10">
<param name="bwidth" value="10">
<param name="delay" value="1000">
<param name="fontname" value="TimesRoman">
<param name="fontsize" value="14">
<param name="link" value="http://java.sun.com/events/jibe/index.html">
<param name="number" value="3">
<param name="quote0" value="Living next to you is in some ways like sleeping with an elephant. No matter how friendly and even-tempered is the beast, one is affected by every twitch and grunt.|- Pierre Elliot Trudeau|000000|ffffff|7">
<param name="quote1" value="Simplicity is key. Our customers need no special technology to enjoy our services. Because of Java, just about the entire world can come to PlayStar.|- PlayStar Corporation|000000|ffffff|7">
<param name="quote2" value="The ubiquity of the Internet is virtually wasted without a platform which allows applications to utilize the reach of Internet to write ubiquitous applications! That's where Java comes into the picture for us.|- NetAccent|000000|ffffff|7">
<param name="space" value="20">
</applet>
</body>
</html>When I previewed it in Netscape Navigator, a box with a red X appeared, and this appeared in the console when I opened it:
load: class /demo/quote/JavaQuote.class not found.
java.lang.ClassNotFoundException: .demo.quote.JavaQuote.class
at sun.applet.AppletClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.applet.AppletClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.applet.AppletClassLoader.loadCode(Unknown Source)
at sun.applet.AppletPanel.createApplet(Unknown Source)
at sun.plugin.AppletViewer.createApplet(Unknown Source)
at sun.applet.AppletPanel.runLoader(Unknown Source)
at sun.applet.AppletPanel.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
Caused by: java.io.FileNotFoundException: \demo\quote\JavaQuote\class.class (The system cannot find the path specified)
at java.io.FileInputStream.open(Native Method)
at java.io.FileInputStream.<init>(Unknown Source)
at java.io.FileInputStream.<init>(Unknown Source)
at sun.net.www.protocol.file.FileURLConnection.connect(Unknown Source)
at sun.net.www.protocol.file.FileURLConnection.getInputStream(Unknown Source)
at sun.applet.AppletClassLoader.getBytes(Unknown Source)
at sun.applet.AppletClassLoader.access$100(Unknown Source)
at sun.applet.AppletClassLoader$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
... 10 more
Exception in thread "Thread-4" java.lang.NullPointerException
at sun.plugin.util.GrayBoxPainter.showLoadingError(Unknown Source)
at sun.plugin.AppletViewer.showAppletException(Unknown Source)
at sun.applet.AppletPanel.runLoader(Unknown Source)
at sun.applet.AppletPanel.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
java.lang.NullPointerException
at sun.plugin.util.GrayBoxPainter.showLoadingError(Unknown Source)
at sun.plugin.AppletViewer.showAppletStatus(Unknown Source)
at sun.applet.AppletPanel.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)What went wrong? and how can I make it run correct?
Thanks,
Nathan PinnoJavaQuote.class is not where your HTML says it is. That is at the relative URL "/demo/quote/".
-
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?
amwell...........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.
> -
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... -
Need HELP with Stick Figure Applet
I need help with this java program for college....we need to make a applet which displays a stick figure or some type of person using appleviewer..please can someone help me......
email: [email protected]import java.awt.*;
import java.applet.*;
public class StickMan extends Applet {
public void init() {
public void paint(Graphics g) {
g.drawOval(....);
g.drawLine(....);
g.drawLine(....);
g.drawLine(....);
g.drawLine(....); -
So im just starting java, about 12 weeks in.
So in my class we are getting started with objects. What i want to do is create a class called car, and have it create a new car and draw images loaded, and then have the tires rotate, there are 2 images,
the car base and the tires.
I know how to display images in applets, but i dont know how to define the images in the objects class and then draw them from the class.I get errors with this code from my car class
import java.applet.*;
public class car extends Applet{
* @param args
private String model;
private int passangers;
private double gas,speed;
private Image tire;
private MediaTracker tr;
tr = new MediaTracker(this);
tire = getImage(getCodeBase(), "tire.png");
tr.addImage(tire,0);
public car(String id, int pass, double tank)
model=id;
passangers=pass;
gas=tank;
public car()
model="";
passangers=0;
gas=0;
}I get errors on these lines
private Image tire;
private MediaTracker tr;
tr = new MediaTracker(this);
tire = getImage(getCodeBase(), "tire.png");
tr.addImage(tire,0);errors
Severity and Description Path Resource Location Creation Time Id
Image cannot be resolved to a type Car Game car.java line 13 1197077768237 1745
MediaTracker cannot be resolved to a type Car Game car.java line 14 1197077768238 1746
Return type for the method is missing Car Game car.java line 16 1197077768239 1750
Syntax error on token ";", { expected after this token Car Game car.java line 14 1197077768238 1747
Syntax error on token "(", delete this token Car Game car.java line 17 1197077768239 1752
Syntax error on token "0", invalid FormalParameter Car Game car.java line 17 1197077768239 1753
Syntax error on token(s), misplaced construct(s) Car Game car.java line 15 1197077768238 1748
Syntax error on token(s), misplaced construct(s) Car Game car.java line 16 1197077768239 1749
Syntax error on tokens, delete these tokens Car Game car.java line 16 1197077768239 1751
The serializable class car does not declare a static final serialVersionUID field of type long Car Game car.java line 4 1197077768237 1744
The serializable class main does not declare a static final serialVersionUID field of type long Applet main.java line 5 1196990860997 1682
The serializable class main does not declare a static final serialVersionUID field of type long Car Game main.java line 5 1197077768196 1743
The serializable class ShowImage does not declare a static final serialVersionUID field of type long Display JPEG/src ShowImage.java line 4 1196488911896 1393Edited by: jasonpeinko on Dec 7, 2007 5:42 PM -
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 -
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. -
Can anyone help with the java applet issue
Hello everyone,
This is my first thread in this forum,
I need a little help with the form developer...
I have oracle 9i db , 9i form developer
I don't want to run the form i created as a java applet
HOW IS THAT DONE i.e NOT IN THE INTERNET EXPLORER?????????
***IF ITS POSSIBLEHello,
I don't want to run the form i created as a java applet
No chance, because the Web Forms client is an applet and cannot be anything else.
Francois -
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
Maybe you are looking for
-
This has been a problem for a while now, but it wasn't always like this. One day, it just happened! Everything else seems to work okay, and I can still read and write mail, but accessing account settings for any of them is broken. I already followed
-
Physical Inventory vs. Cycle Counting
Hi Experts - In the absence of the Cycle counting indicator and ABC Analysis is it safe to say that Cycle Counting is not a relevant scenario? Physical inventory is different PI doc > Count > Recount > Clear differences. What is the standard function
-
Dreamweaver 8.0, Won't Start Up At All
What do I do about my Dreamweaver 8.0 suddenly getting stuck during start-up, and just freezing until I get a "not responding" message and have to shut it down? It goes along for a little while, then freezes at the "Initializing Css. sign on the star
-
Flash player shows "Movie not loaded" on Firefox 7; would 32 bit version or mode solve?
Flash Player 11.0.1.152 is loaded on my machine. Firefox 7.0.1 is my browser. Running Windows 7 Home Premium. Flash content which worked before now does not. When I visit Flash enabled sites, the display area for the Flash content remains blank. When
-
Hi, please advise. I have two business processes, one old process and another new - optimized process. Question is how to measure the system load (total) for realization of the first - old process and new process to measure difference of how the proc