Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon.

Pages: 1-

CS HW DUE IN AN HOUR

Name: Anonymous 2010-10-15 11:06

Well I'm a little stuck and I don't have time to search for answers at this point. Could /prog/ help me out?

We basically have a grid game that we have to edit. It has different images as the pieces of the grid. The pieces are stored in a matrix. Pretty standard stuff. I've done most of it, but I need helping this:

Draw Cell Grid Lines on the Map - Outline all the grid lines on the map but do not change the original map image. You must do this by rendering on top of the map inside your Java program. Note that you'll have to do some investigating in the Java API, Java Tutorials, and/or our textbook to figure out how to do this. Make sure the lines are thick enough (more than two pixels wide) such that they are clearly visible.

Name: Anonymous 2010-10-15 11:08

forgot to say that this is in Java and that we're using swing for everything.

Also I don't need full implementation, just need to be pointed in the right direction.

THanks.

Name: Anonymous 2010-10-15 11:16

Name: Anonymous 2010-10-15 11:22

I understand basic programming. I'm just not familiar with swing's library. After a google search, this question turns out to be easier than I thought it would be (at least so it seems).

Thanks though.

Name: Anonymous 2010-10-15 14:28

Wait... Are you saying that you don't know how to draw simple lines in java?

Name: Anonymous 2010-10-15 16:26

>>5
Nothing in java is simple

Name: Anonymous 2010-10-15 16:57

>>6
public class DrawSimpleLines
{
   public static void main(String[] args)
   {
      javax.swing.JFrame main = new javax.swing.JFrame();
      main.add(new SimpleLines());
   }
}

class SimpleLines extends javax.swing.JPanel
{
   public SimpleLines()
   {
      super();
   }

   @Override
   public void paintComponent(java.awt.Graphics g)
   {
      super.paintComponent(g);
      /* g.drawLine(x1,y1, x2,y2); */
   }
}

It's not that hard.

Name: Anonymous 2010-10-15 17:12

>>7
You made that much harder than it has to be, and managed to leave the relevant bit commented out.

Name: Anonymous 2010-10-15 17:23

>>8
>>6
there's nothing hard about java

Name: Anonymous 2010-10-15 17:34

>>9
Difficulty and simplicity are different concepts.

Name: Anonymous 2010-10-15 17:59

>>8
I knew I could have just made class SimpleLines into public class SimpleLines extend javax.swing.JFrame and toss an appropriate main into it.  As a preference, I don't like drawing directly onto a Frame object if I can avoid it.

And it's still easy.

Name: Anonymous 2010-10-15 18:59

>>11
DRAW ON MY ANUS

Name: Anonymous 2010-10-16 0:34

ATOMIC DNUS

Name: Anonymous 2010-10-16 17:15

DTOMIC ANUS

Don't change these.
Name: Email:
Entire Thread Thread List