LightbulbLearning Java

Posts 19 of 9 · Page 1 of 1
Learning Java
hey guys i just started learning java due to hosting a rsps and no coder

so i have 2 codes that ive been studying out of a book i need to know if this code could relate to RSPS coding or rsbot scripting

here is the first code.
Code:
import javax.swing.*;

public class TheBasics {
public static void main( String[] args ){
JFrame frame = new JFrame( "Hello Basics!");
JLabel label = new JLabel("Hello, Basics!", JLabel.CENTER);
frame.add( label );
frame.setSize( 300, 300);
frame.setVisible( true );
   }
}
here is the second witch has a error that i cant figure out.
Code:
import java.awt.*;
import javax.swing.*;

class HelloComponent extends JComponent {
	public void paintComponent( Graphics g ) {
		g.drawString( "Hello, Component!", 125, 95);
		HelloComponent hello = new HelloComponent();
		frame.add( hello ); // im pretty sure this is the error havnt double checked tho
	}
}
plz no flaming im here to learn
-Thanks
-RebelCoder
Quote Originally Posted by RebelCoder View Post
hey guys i just started learning java due to hosting a rsps and no coder

so i have 2 codes that ive been studying out of a book i need to know if this code could relate to RSPS coding or rsbot scripting

here is the first code.
Code:
import javax.swing.*;

public class TheBasics {
public static void main( String[] args ){
JFrame frame = new JFrame( "Hello Basics!");
JLabel label = new JLabel("Hello, Basics!", JLabel.CENTER);
frame.add( label );
frame.setSize( 300, 300);
frame.setVisible( true );
   }
}
here is the second witch has a error that i cant figure out.
Code:
import java.awt.*;
import javax.swing.*;

class HelloComponent extends JComponent {
	public void paintComponent( Graphics g ) {
		g.drawString( "Hello, Component!", 125, 95);
		HelloComponent hello = new HelloComponent();
		frame.add( hello ); // im pretty sure this is the error havnt double checked tho
	}
}
plz no flaming im here to learn
-Thanks
-RebelCoder
They could definitely relate. A JFrame is simply the swing component which represents a window. This would be necessary to create an RSPS. I would need to see the error specifications to solve the problem with the second snippet.
Code:
warning 1:
Build path specifies execution environment JavaSE-1.6. There are no JREs installed in the workspace that are strictly compatible with this environment. 	Learning Java		Build path	JRE System Library Problem
but cause of this error it wont let me compile
Quote Originally Posted by RebelCoder View Post
Code:
warning 1:
Build path specifies execution environment JavaSE-1.6. There are no JREs installed in the workspace that are strictly compatible with this environment. 	Learning Java		Build path	JRE System Library Problem
but cause of this error it wont let me compile
I would recommend using an IDE as opposed to performing command line compilation. This is much easier. Simple IDE's include Eclipse, or JCreator. A more advanced one is Netbeans. I would recommend using JCreator, as it requires you to learn correct syntax.
Download it here:
JCreator — Java IDE
Quote Originally Posted by Saltine View Post

I would recommend using an IDE as opposed to performing command line compilation. This is much easier. Simple IDE's include Eclipse, or JCreator. A more advanced one is Netbeans. I would recommend using JCreator, as it requires you to learn correct syntax.
Download it here:
JCreator — Java IDE
Tbh Eclipse is the easiest one to develop in for newcomers.

Quote Originally Posted by RebelCoder View Post
Code:
warning 1:
Build path specifies execution environment JavaSE-1.6. There are no JREs installed in the workspace that are strictly compatible with this environment. 	Learning Java		Build path	JRE System Library Problem
but cause of this error it wont let me compile
> Download Eclipse
> Switch JavaSE to 1.6

If not look to install 1.6
Quote Originally Posted by Saltine View Post

I would recommend using an IDE as opposed to performing command line compilation. This is much easier. Simple IDE's include Eclipse, or JCreator. A more advanced one is Netbeans. I would recommend using JCreator, as it requires you to learn correct syntax.
Download it here:
JCreator — Java IDE
Im being taught Java with NetBeans, Hardly Advanced...Its quite simple
Quote Originally Posted by Decieved- View Post
Im being taught Java with NetBeans, Hardly Advanced...Its quite simple
I simply meant it has a much larger amount of features. For small projects, all you need is JCreator. To manage a large project with hundreds of files and millions of lines of code, Netbeans ftw.
I use Netbeans for everything...Regardless of size. xD
We use JCreator in school .
I believe that the first piece of code is one of the basic codes .
You're making sort of a window.

You can use something like this too :
class FirstProgram {

public static void main (String args[]) {
System.out.println("Hello World");
}
}
Posts 19 of 9 · Page 1 of 1

Post a Reply

Similar Threads

Tags for this Thread

None

Need help?