java - How would I let my main method access the paint method I created inside Applet? -
Hello Paint Class is how I would like to use the main variable. How do I do this? I would like to move the variable so that I can make conditional to draw strings when estimating correct or false characters.
Import static java.lang.System. *; Import javax.swing *; Import java.util. *; Import java.io * *; Import java.awt. *; Import java.applet. *; Import static java.lang.System. *; Public class testing applet {public static expands Zero main (string [] args) throws IOException {JFrame jp1 = new JFrame ()); A test = new test (); Jp1.getContentPane (). Add (a, BorderLayout.CENTER); Jp1.setSize (new dimension (500,500)); Jp1.setVisible (wrong); Random random = new random (); Scanner Scanner = New Scanner (New File ("C: \\ User \\ s612153 \\ Documents \\ Java Files \ words.");); ArrayList & lt; String & gt; Array list = new arreelist & lt; String & gt; (); ArrayList & lt; String & gt; Array = new arreelist & lt; String & gt; (); ArrayList & lt; String & gt; Arrival = new arreelist & lt; String & gt; (); Int c = scanner.nextInt (); Int variable = random.nextInt (c) + 1; For (int x = 0; x & lt; c; x ++) {string string = scanner.xt (); Arraylist.add (string); } String word = arraylist.get (variable); Word = word.toUpperCase (); Out.println (terms); Int length = words. Length (); ArrayList & lt; String & gt; Sarandu = new arreelist & lt; String & gt; (); {Arrayundr.add ("_") for (int x = 0; x & lt; length; x ++); } Out.println (border); Int try = 7; Int var = 0; For (int x = var; x & lt; attempt; x = x) {string estimate = optionpane.showsput dialog ("enter a letter:"); Four four = estimate.Chart (0); Four = character. Upper (four); If (word.indexOf (char)> = 0) {string let = character Trostling (four); Int gerb = word.indexOf (four); Int kirby = word.indexOf (four, gerb + 1); Out.println ("this is correct"); Arraycorr.add (go); Sarandar .Set (Gerb, let's); Out.println ("WORD:" + border); Effort = effort + 1; } And if (word.indexOf (variable)! = 0) {string string = character .string (four); Out.println ("wrong!"); Arrayinco.add (condition); X = x + 1; }} Out.println (Sarinco); }
I want to use my main variable in the paint class !!!
Public Zero Color (Graphics G) {g.drawString ("Hello", 40,30); }}
A better method is to create the property of the test class, which Then the handle on the applet can be set using, for example:
public class testing extension extends {personal string message = ""; Public static zero main (string [] args throws IOException {JFrame jp1 = new JFrame (); A test = new test (); // .. a.message = "hello"; // ..} Public Zero Color (Graphics G) {g.drawString (Message, 40, 30); }}
Comments
Post a Comment