Results 1 to 18 of 18
Thread: Can someone explain...
- 01-13-2012, 02:07 AM #1
Senior Member
- Join Date
- Jan 2012
- Posts
- 146
- Rep Power
- 0
- 01-13-2012, 02:12 AM #2
Senior Member
- Join Date
- Jan 2012
- Posts
- 146
- Rep Power
- 0
Re: Can someone explain...
I'm new to this forum, no one has instructed me about how to post headers on this forum.
With all due respect, if you would have liked to address me about it, it would've been more efficient to Private Message me, than to spam my post and not give me an answer to the original post.
- 01-13-2012, 02:21 AM #3
Moderator
- Join Date
- Feb 2009
- Location
- New Zealand
- Posts
- 4,547
- Rep Power
- 11
Re: Can someone explain...
Be specific from esr's smart question faq.
(which - I have just noticed is also linked to from the faq on this site: Forum Rules)
- 01-13-2012, 02:21 AM #4
Senior Member
- Join Date
- Jan 2012
- Posts
- 146
- Rep Power
- 0
Re: Can someone explain...
I've read that super has something to do with superclasses, but, that is where it gets confusing. I'm guessing it overrides the use of using either, a) a object for the class it corresponds with, or a b) private class/protected class it corresponds with.
-
Re: Can someone explain...
First off, a super class is the immediate parent class of the child class (in an inheritance hierarchy), and the term "super" can be used in a child's constructor to call the super class's constructor of your choice. So if the super class has one constructor that takes no parameters and another that takes an int, you can tell the child's constructor to call the one that takes the int if you call super(myInt). Otherwise the parameterless constructor will be called by default. This has to be on the first line of the child's constructor to work.
The super key word can also be used to call any of the super class's methods.
As for casting -- you will find much on this (and on the super key word) in tutorials via Google.
- 01-13-2012, 02:29 AM #6
Senior Member
- Join Date
- Jan 2012
- Posts
- 146
- Rep Power
- 0
Re: Can someone explain...
Java Code:import javax.swing.JFrame; public class Main{ public static void main( String [] args) { JFrame frame = new JFrame("Star Blasters II"); frame.setSize(800, 600); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.setResizable(false); frame.add(new GameFrame()); frame.setVisible(true); } }When using these two classes, and I try to compile the GameFrame class, I get this error.Java Code:import javax.swing.JFrame; import java.awt.Graphics; import java.awt.Graphics2D; public class GameFrame extends JPanel { public GameFrame() { setFocusable(true); } public void paint(Graphics g) { super.paint(g); Graphics2D g2d = (Graphics2D) g; g2d.drawString("test", 100 , 100); } }
-
Re: Can someone explain...
You've got an import problem. Can you figure out what is missing based on this hint? :)
- 01-13-2012, 02:34 AM #8
Senior Member
- Join Date
- Jan 2012
- Posts
- 146
- Rep Power
- 0
Re: Can someone explain...
I imported JPanel, and it compiles that correctly, but in my mainclass, I get this error when I compile, this tut is turning out worse and worse every time!Java Code:import javax.swing.JFrame; import javax.swing.JPanel; import java.awt.Graphics; import java.awt.Graphics2D; public class GameFrame extends JPanel { public GameFrame() { setFocusable(true); } public void paint(Graphics g) { super.paint(g); Graphics2D g2d = (Graphics2D) g; g2d.drawString("test", 100 , 100); } }
-
Re: Can someone explain...
Did you try to compile Main before successfully compiling GameFrame? Are they in the same directory/package?
I don't think that the tutorial is at fault, but rather that you're new to the language, and it will take many little steps to get things started, but once over the hump things will go much better. Expect to be thrown more speed bumps on this journey, but don't give up yet....this tut is turning out worse and worse every time!
- 01-13-2012, 02:44 AM #10
Senior Member
- Join Date
- Jan 2012
- Posts
- 146
- Rep Power
- 0
Re: Can someone explain...
I'm not sure I know how to make a package on Notepad++. Am I ready to use an IDE, Fubarable-Sensai?
-
Re: Can someone explain...
No stay with Notepad++ for now Army-san.
- 01-13-2012, 03:09 AM #12
Senior Member
- Join Date
- Jan 2012
- Posts
- 146
- Rep Power
- 0
Re: Can someone explain...
How do you make a package on Notepad++ then, sensai?
-
Re: Can someone explain...
For my money, I go to the source:
The Java Tutorials
What Is a Package?
Lesson: Packages
- 01-13-2012, 03:19 AM #14
Senior Member
- Join Date
- Jan 2012
- Posts
- 146
- Rep Power
- 0
Re: Can someone explain...
Wow, I am facepalming right now. I looked at what is a interface, and the class I'm taking now basically copied and pasted all that stuff to their online course.
In other news, I'm guessing you can... "declare" (excuse my terminology) a package by saying - package Something; at the top?
-
Re: Can someone explain...
- 01-13-2012, 03:26 AM #16
Senior Member
- Join Date
- Jan 2012
- Posts
- 146
- Rep Power
- 0
-
Re: Can someone explain...
Here is some more detailed information on how to do command line compilation and running of java files:
javac - Java programming language compiler
java - the Java application launcher
- 01-13-2012, 05:14 AM #18
Senior Member
- Join Date
- Jan 2012
- Posts
- 146
- Rep Power
- 0
Re: Can someone explain...
Thanks for being so patient, you should see my tabs.
Anyway, even if import everything right on this step, the tutorial does not give me enough information later on, for he is using an IDE and he basically is clicking to make methods and imports. I cannot follow everything he is doing :/.
Similar Threads
-
can someone explain what this exactly does?
By liluma in forum New To JavaReplies: 4Last Post: 08-21-2011, 07:58 PM -
Please Explain me how i got this output.. I am new to java .. so please Explain me...
By vicky82 in forum New To JavaReplies: 2Last Post: 12-13-2010, 01:34 PM -
Please Explain me how i got this output.. I am new to java .. so please Explain me...
By vicky82 in forum New To JavaReplies: 3Last Post: 12-13-2010, 07:22 AM -
Can somebody explain me this plz
By ccie007 in forum New To JavaReplies: 4Last Post: 05-20-2010, 07:47 PM -
Can someone explain why...
By Krooger in forum AWT / SwingReplies: 1Last Post: 11-19-2009, 06:59 AM


LinkBack URL
About LinkBacks
Reply With Quote

Bookmarks