Need some help...:P - Printable Version +- BP Forums (https://bpforums.info) +-- Forum: Archived Forums (https://bpforums.info/forumdisplay.php?fid=55) +--- Forum: Archived Forums (https://bpforums.info/forumdisplay.php?fid=56) +---- Forum: Java (https://bpforums.info/forumdisplay.php?fid=19) +---- Thread: Need some help...:P (/showthread.php?tid=422) |
Need some help...:P - Jake - 11-10-2011 Hey Brandonio, started you're tutorials, finished them already, can't wait for you to come out with more, I tried developing an "applet" that uses JOptionPanes, but am failing, so do you think you can help me, if you know how? D: Here is what I have: Code: import javax.swing.*; What this does is open up and ask for the base, I enter it and it just disappears and does nothing, so I suspect I did something wrong. You can't use a scanner with JOptionPanes, can you? I'm so confused <!-- s:lol: --><img src="{SMILIES_PATH}/icon_lol.gif" alt=":lol:" title="Laughing" /><!-- s:lol: --> Can you help me out man? Re: Need some help...:P - brandonio21 - 11-10-2011 Hey Jake! Welcome to the forums, and I am glad that you are enjoying my tutorials! Well, your first assumption was correct.. You cannot use Scanners in applets, only in console applications. So you can simply get rid of any scanner code here. Also: When creating an applet you need to tell Java that you are actually making an applet, you can do that by ending extends Applet onto the end of your class name. For example, Code: public class TriangleArea extends Applet Also, since you are not using a scanner, you no longer need to import the java.util.* libraries. Now: When creating an applet, the applet does not automatically run the MAIN method, instead it automatically runs the PAINT method. Therefore, you simply need to take everything in the main method, and put it into a new public void paint() method. Also: You have alot of variables here, so I edited them a little bit. Here is your new functional code: feel free to ask any questions about it! Code: import javax.swing.*; Re: Need some help...:P - Jake - 11-10-2011 Wow man! Thanks!! <!-- s --><img src="{SMILIES_PATH}/icon_e_biggrin.gif" alt="" title="Very Happy" /><!-- s --> Re: Need some help...:P - brandonio21 - 11-11-2011 Jake Wrote:Wow man! Thanks!! <!-- s --><img src="{SMILIES_PATH}/icon_e_biggrin.gif" alt="" title="Very Happy" /><!-- s -->But of course! <!-- s --><img src="{SMILIES_PATH}/icon_e_biggrin.gif" alt="" title="Very Happy" /><!-- s --> |