<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0">
  <channel>
    <title>'how do i call on a class with (graphics g)' Thread RSS Feed</title>
    <link>http://www.programmersheaven.com/</link>
    <description>Contains the latest posts from the thread 'how do i call on a class with (graphics g)' posted on the 'Java' forum at Programmer's Heaven.</description>
    <language>en</language>
    <copyright>Copyright 2013 Programmers Heaven</copyright>
    <pubDate>Tue, 18 Jun 2013 14:59:27 -0700</pubDate>
    <lastBuildDate>Tue, 18 Jun 2013 14:59:27 -0700</lastBuildDate>
    <generator>Argotic Syndication Framework 2007.3.0.1, http://www.codeplex.com/Argotic</generator>
    <docs>http://www.rssboard.org/rss-specification</docs>
    <ttl>360</ttl>
    <image>
      <url>http://www.programmersheaven.com/images/ph.gif</url>
      <title>Programmers Heaven</title>
      <link>http://www.programmersheaven.com/</link>
      <width>88</width>
      <height>31</height>
    </image>
    <item>
      <title>how do i call on a class with (graphics g)</title>
      <link>http://www.programmersheaven.com/mb/java/415916/415916/how-do-i-call-on-a-class-with-graphics-g/</link>
      <description>im trying to create the game mastermind and in my version, i split the many parts of my code into separate classes so it would be a &lt;br /&gt;
little easier to work with, several of my classes use g.drawstring  for animation and positioning purposes,(got the idea from c++ gotoxy) but when i try to call some of these classes it gives me an (java.awt.Graphics) can not be applied to () error. what should i do?. &lt;br /&gt;
&lt;br /&gt;
below is the mainmenu class i am trying to call and the mastermind class that is calling it.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
~~~~~~~~~~~~~~~~~~~MAINMENU~~~~~~~~~~~~~~~~~~~~~~~
~~~~~~~~&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
import java.awt.Graphics;&lt;br /&gt;
import javax.swing.*;&lt;br /&gt;
import java.awt.*;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
public class mainmenu&lt;br /&gt;
{&lt;br /&gt;
   public void mainmenu(Graphics g)&lt;br /&gt;
      &lt;br /&gt;
   {&lt;br /&gt;
      int Position=0;int row=0;&lt;br /&gt;
     &lt;br /&gt;
      for(row=30;row&amp;gt;=0 ;row=row-1)&lt;br /&gt;
       {&lt;br /&gt;
      for( Position=20;Position&amp;gt;=0;Position=Position-57)&lt;br /&gt;
       {    g.drawString("************************************
*********************",row+0,0);&lt;br /&gt;
    &lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
~~~~~~~~~~~~~~~~~~~~~~~~~~MASTERMIND~~~~~~~~~~~~~~
~~~~~~~~~~~~~~~~~~&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
import java.awt.Graphics;&lt;br /&gt;
import java.util.Scanner;&lt;br /&gt;
import javax.swing.*;&lt;br /&gt;
import java.awt.*;&lt;br /&gt;
import java.util.Random;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
 public class  MASTERMIND { &lt;br /&gt;
   &lt;br /&gt;
     &lt;br /&gt;
 &lt;br /&gt;
   &lt;br /&gt;
    public static void mastermind ( String [] args){&lt;br /&gt;
    Scanner reader = new Scanner(System.in);     &lt;br /&gt;
    &lt;br /&gt;
  /* like i said there are alot of parts to it */&lt;br /&gt;
&lt;br /&gt;
starter                  s = new starter();&lt;br /&gt;
mainmenu                 m = new mainmenu();&lt;br /&gt;
window                   w = new window();&lt;br /&gt;
endscreen                e = new endscreen();&lt;br /&gt;
endscreen2               q = new endscreen2();&lt;br /&gt;
easy                     x = new easy();&lt;br /&gt;
Easy_game_instructions   k = new Easy_game_instructions();&lt;br /&gt;
Hard_game_instructions   h = new Hard_game_instructions();&lt;br /&gt;
endcreditz               p = new endcreditz();&lt;br /&gt;
instructionscreen        i = new instructionscreen();&lt;br /&gt;
winningscreen            b = new winningscreen();&lt;br /&gt;
easy_game                y = new easy_game();&lt;br /&gt;
hard_game                u = new hard_game(); &lt;br /&gt;
quitpfz                  a = new quitpfz();&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
  int userselection=0;&lt;br /&gt;
 &lt;br /&gt;
    s.starter();&lt;br /&gt;
    &lt;br /&gt;
      while ((userselection!=5))&lt;br /&gt;
        {&lt;br /&gt;
          m.mainmenu(); /*&amp;lt;=&amp;lt; THIS IS WHERE THE ERROR IS */&lt;br /&gt;
 &lt;br /&gt;
        switch(userselection)&lt;br /&gt;
        {&lt;br /&gt;
                case 1:i.instructionscreen();break;&lt;br /&gt;
                case 2:y.easy_game();break;&lt;br /&gt;
                case 3:u.hard_game();break;&lt;br /&gt;
                case 4:p.endcreditz();break;&lt;br /&gt;
                case 5:b.winningscreen();&lt;br /&gt;
        }&lt;br /&gt;
&lt;br /&gt;
        }&lt;br /&gt;
&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
~~~~~~ any help would be greatly appreciated, thank you ~~~~~~~&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;</description>
      <guid isPermaLink="true">http://www.programmersheaven.com/mb/java/415916/415916/how-do-i-call-on-a-class-with-graphics-g/</guid>
      <pubDate>Mon, 26 Apr 2010 16:52:45 -0700</pubDate>
      <category>Java</category>
    </item>
    <item>
      <title>Re:   how do i call on a class with (graphics g)</title>
      <link>http://www.programmersheaven.com/mb/java/415916/415920/re---how-do-i-call-on-a-class-with-graphics-g/#415920</link>
      <description>huh,great job. thanks&lt;br /&gt;</description>
      <guid isPermaLink="true">http://www.programmersheaven.com/mb/java/415916/415920/re---how-do-i-call-on-a-class-with-graphics-g/#415920</guid>
      <pubDate>Mon, 26 Apr 2010 20:50:43 -0700</pubDate>
      <category>Java</category>
    </item>
    <item>
      <title>Re:   how do i call on a class with (graphics g)</title>
      <link>http://www.programmersheaven.com/mb/java/415916/415937/re---how-do-i-call-on-a-class-with-graphics-g/#415937</link>
      <description>Hey,&lt;br /&gt;
You have outlined an ambitious endeavor. My recommendations are not use the draw functions because their information is not preserved when a window component is automatically redrawn by the "system".&lt;br /&gt;
&lt;br /&gt;
I altered your program to show a simple window frame. However the program is not meant to be a template. GUI programming is pretty involved.&lt;br /&gt;
&lt;br /&gt;
My personal suggestion is to view a &lt;a href="http://forum.codecall.net/classes-code-snippets/10764-java-source-code-tic-tac-toe-game.html"&gt;TicTacToe program &lt;/a&gt;(click on the link) that could provide many insights. I tried the version in the second post, it looked good just need to fix 1 line: public &lt;span style="color: Red;"&gt;cl*** &lt;/span&gt;TicTacToe implements ActionListener	{&lt;br /&gt;
needs to be: public &lt;span style="color: Red;"&gt;class&lt;/span&gt; TicTacToe implements ActionListener	{&lt;br /&gt;
&lt;br /&gt;
A modified version of your original program is attached for download.&lt;br /&gt;
&lt;br /&gt;
regards, se52&lt;br&gt;&lt;br&gt;&lt;strong&gt;Attachment:&lt;/strong&gt; &lt;a href="http://www.programmersheaven.com/mb/DownloadAttachment.aspx?AttachmentID=1738"&gt;MASTERMIND.java&lt;/a&gt; (3483 bytes | downloaded 166 times)</description>
      <guid isPermaLink="true">http://www.programmersheaven.com/mb/java/415916/415937/re---how-do-i-call-on-a-class-with-graphics-g/#415937</guid>
      <pubDate>Tue, 27 Apr 2010 08:55:32 -0700</pubDate>
      <category>Java</category>
    </item>
  </channel>
</rss>