Results 1 to 16 of 16
- 11-30-2011, 05:22 PM #1
Member
- Join Date
- Nov 2011
- Posts
- 50
- Rep Power
- 0
How to make image invisible and visible in applet
hey guys my question is basic.
How to make image invisible and visible in applet?
here is the code of image
Java Code:public void paint(Graphics g) { super.paint(g); try {base = getDocumentBase(); images[0]=getImage(base,"Hangman.gif"); } catch(Exception e){} g.drawImage(images[0],650,20,this); }
- 11-30-2011, 06:25 PM #2
Senior Member
- Join Date
- Oct 2010
- Location
- Germany
- Posts
- 780
- Rep Power
- 4
Re: How to make image invisible and visible in applet
Insert an if-statement?
if(shouldPaint) {...draw your image...}
in your "control" code you can change the variable shouldPaint and after that --> call repaint()
btw: i would only draw the image at the paint method. I would load the image outside and only once!
- 11-30-2011, 06:45 PM #3
Member
- Join Date
- Nov 2011
- Posts
- 50
- Rep Power
- 0
Re: How to make image invisible and visible in applet
i did hangman homework with gui now im doing it with applet
everything are okey excepts images.
i have 12 images. so i need to command which do invisible image.
isnt there a commond like that ?
- 11-30-2011, 06:50 PM #4
Re: How to make image invisible and visible in applet
Is an invisible image, an image that is not shown?
In your paint method, if you return after the call to super.paint() no image will be shown. It will be invisible.
- 12-01-2011, 05:46 PM #5
Member
- Join Date
- Nov 2011
- Posts
- 50
- Rep Power
- 0
Re: How to make image invisible and visible in applet
hey guys,finnally i convert my gui hangman code to applet hangman code.
i put it on website here is the link:
http://users9.jabry.com/ksbeyaz/
sometimes pictures is reload slowly.
i want your feedbacks.
note(All text you must find is on "Turkish Words")
- 12-04-2011, 01:46 AM #6
Member
- Join Date
- Nov 2011
- Posts
- 50
- Rep Power
- 0
Re: How to make image invisible and visible in applet
Although i upload all neccassary files ,if i dont enter website from my computer ,some part of this java homework dont be seen from different computers.
why this problem occur?
any suggestions?
- 12-04-2011, 01:49 AM #7
Re: How to make image invisible and visible in applet
Please explain.some part of this java homework dont be seen from different computers.
Also can you add a language choice and add English, I spent one winter in Izmir but did not learn much Turkish.
- 12-04-2011, 01:56 AM #8
Member
- Join Date
- Nov 2011
- Posts
- 50
- Rep Power
- 0
Re: How to make image invisible and visible in applet
yeah i will do it.but homework was for Turkish.
i have entered url with different computer and there should be ___ ___ ___ ___ on the center for length of size. and if player find correct letter ,for example A in text on the first there should be __A__ ____ ____ ____ but on diffferent computer it isnt appear like that it was ____ _____ _____ _____ after click "Sonraki" which mean "next" all of _____ gone.Moreover pictures reload slowly
any suggestion?
- 12-04-2011, 02:04 AM #9
Re: How to make image invisible and visible in applet
Hard to know what the problem with your code is without seeing it.
I've downloaded all the class files and images and will take a look.Last edited by Norm; 12-04-2011 at 02:13 AM.
- 12-04-2011, 12:58 PM #10
Member
- Join Date
- Nov 2011
- Posts
- 50
- Rep Power
- 0
Re: How to make image invisible and visible in applet
thank you,waiting for your post
- 12-04-2011, 02:27 PM #11
Re: How to make image invisible and visible in applet
Can you post the code for your inner classes that are listeners for the buttons? My decompiler did not do a good job of creating the source for them.
- 12-04-2011, 02:59 PM #12
Member
- Join Date
- Nov 2011
- Posts
- 50
- Rep Power
- 0
Re: How to make image invisible and visible in applet
i have sent you with private msg.
i think problem is occur because MyPanel class isnt working good on html websides.MyPanel class draw _____ and Letter which is found by player like that ___A___
must i include html to MyPanel class ? it extend by deneme class?Last edited by KSBeyaz; 12-04-2011 at 03:21 PM.
- 12-04-2011, 04:58 PM #13
Re: How to make image invisible and visible in applet
You should not load the images every time in the paint method. Move the code to the init() method and do it only once.
I tried many different method calls to cause the JVM to display the components that you had setVisible(false) and then later tried to setVisible(true). I found that if I called the validate() method for the container that was holding the panel that was holding the component that was just set visible, that they would be shown.
Java Code:panels[zt] = new MyPanel(txt.charAt(zt)); pnl1.add(panels[zt]); panels[zt].setVisible(false);Java Code:panels[tt].setVisible(true); pnl1.validate(); // THIS WORKS <<<Last edited by Norm; 12-04-2011 at 05:01 PM.
- 12-04-2011, 05:42 PM #14
Member
- Join Date
- Nov 2011
- Posts
- 50
- Rep Power
- 0
- 12-04-2011, 05:48 PM #15
Re: How to make image invisible and visible in applet
Try it and see what happens.it will work?
Read the API doc for the Component class.what is validate() for
- 12-04-2011, 05:58 PM #16
Member
- Join Date
- Nov 2011
- Posts
- 50
- Rep Power
- 0
Re: How to make image invisible and visible in applet
it is said that Request that the component and its affected containers be laid out again. You should not generally need to invoke this method unless you explicitly change a component's size/alignment hints after it's visible or change a containment hierarchy after it is visible. Always invoke repaint after revalidate. okey ty for your help will try
Similar Threads
-
How can I make the graphics visible?
By AcousticBruce in forum New To JavaReplies: 9Last Post: 03-01-2011, 03:53 AM -
how to make the circle visible clearly, which is drawn by using Graphics object
By prasad.vara in forum AWT / SwingReplies: 3Last Post: 10-20-2010, 06:24 AM -
how to make graphic 'painted' on a button visible after disabling??
By nit_go in forum AWT / SwingReplies: 2Last Post: 01-30-2010, 05:14 AM -
Nodes and edges..making visible and invisible based on distance
By sfaiz in forum Java AppletsReplies: 2Last Post: 04-14-2009, 10:01 PM -
How to make the JTextArea background invisible
By bradder in forum AWT / SwingReplies: 1Last Post: 12-05-2007, 06:30 PM


LinkBack URL
About LinkBacks
Reply With Quote

Bookmarks