View Poll Results: Was the Tutorial Helpful?

Voters
13. You may not vote on this poll
  • Yes!

    3 23.08%
  • No!

    4 30.77%
  • Delete It!

    6 46.15%

Thread: Java Programming: Learning the roots

Page 1 of 2 12 LastLast
Results 1 to 10 of 14
  1. #1 Java Programming: Learning the roots 
    Java Programmer


    Join Date
    Feb 2012
    Posts
    478
    Thanks
    36
    Thanked 35 Times in 32 Posts
    Rep Power
    125


    Books:

    Free:
    Java PDF Book

    Not Free:
    Hard Copy
    Another Hard Copy
    eBook


    Tutorials/Snippets:


    Tuts For JAVA SE


    Resources:

    Tools by oracle

    Programs Built For Coding Purposes:
    Eclipse
    IntelliJ
    NetBeans
    NotePad++


    Java Programming Help Forums:

    DreamInCode(DIC for Short)
    Java Programming Forums



    Some Basic Coding And Understanding:
    (Using the 2 Class Method)



    Class1.java
    Code:
    import javax.swing.JFrame;
    
    public class Class1 {
    
    	public static void main(String[] args) {
    		
    		Class2 mainframe = new Class2();
    		mainframe.setSize(420,315);
    		mainframe.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    		mainframe.setResizable(false);
    		mainframe.setVisible(true);
    
    		
    	}
    
    }
    Spoiler for Explaining Class1.java:


    import javax.swing.JFrame;
    Calling Form Java's Api Rather Than Writing 20+ Lines of Code, Import are time savers.

    public class Class1 {
    Name of the class: The Class is Public.

    public static void main(String[] args) {

    The method is public because it be accessible to the JVM to begin execution of the program.

    It is Static because it be available for execution without an object instance. you may know that you need an object instance to invoke any method. So you cannot begin execution of a class without its object if the main method was not static.

    It returns only a void because, once the main method execution is over, the program terminates. So there can be no data that can be returned by the Main method

    The last parameter is String args[]. This is used to signify that the user may opt to enter parameters to the java program at command line. We can use both String[] args or String args[]. The Java compiler would accept both forms.


    Class2 mainframe = new Class2();
    The information that you will be putting onto the jframe will come from class2.java.

    mainframe.setSize(420,315);
    JFrame Size.

    mainframe.setDefaultCloseOperation(JFrame.EXIT_ON_ CLOSE);
    Closes The Jframe When you exit, Rather than leaving it running in the background.

    mainframe.setResizable(false);
    JFrame cannot be pulled to be resized.

    mainframe.setVisible(true);
    The JFrame is Visible.


    }
    ends public static void main(String[] args).

    }
    ends public class Class1




    Class2.java
    Code:
    import java.awt.FlowLayout;
    import javax.swing.JFrame;
    
    
    
    public class Class2 extends JFrame {
    	
    	
    	public Class2(){
    
    		super("");
    		setLayout( new FlowLayout());
    		
            
    	}
    }
    Spoiler for Explaining Class2.java:

    import java.awt.FlowLayout;
    import javax.swing.JFrame;
    Calling Form Java's Api Rather Than Writing 20+ Lines of Code, Import are time savers.


    public class Class2 extends JFrame {

    The Class is public: The Class name is Class2, It extends JFrame (As in: It is like saying "Hey, Put this crap on the Jframe that It wants you to do in class1.java")


    public Class2(){
    Class is public: The Class name is Class2, You will begin coding after her, For the line above is the add the imports that you want to be on the Jframe.

    super("");
    The JFrames Title, The title has to be the the quotation marks. Ex. super("Rune-Server");
    setLayout( new FlowLayout());
    Send the title Left to right.


    }
    ends public Class2().
    }
    ends public class Class2 extends JFrame.





    Assuming You have a basic knowledge Of Java, Lets Get to a little programming, In This Part of The tutorial i will be teaching you how to make a simple Calculator that the problem displays into a jframe.

    Class1.java Will Stay The Same: Don't Edit it threw out this part of the tutorial



    Class2.java
    Code:
    import java.awt.FlowLayout;
    import java.util.*;
    import javax.swing.JFrame;
    import javax.swing.JLabel;
    
    
    
    public class Class2 extends JFrame {
    	
    	private JLabel sum2;
    	Scanner input = new Scanner (System.in);
    	
        int num1 = 0;
        int num2 = 0;
    	  int sum = num1 + num2;
    	
    	public Class2(){
    
    		super("");
    		setLayout( new FlowLayout());
    		
    		System.out.printf("First Number:");
    		num1 = input.nextInt();
    		System.out.printf("Second Number:");
    		num2 = input.nextInt();
    		sum = num1 + num2;
    		
    		sum2 = new JLabel(""+num1+" + "+num2+" = "+sum);
    		add(sum2);
    		
            
            
    	}
    }

    Spoiler for Explaining Class2.java Update:

    Code:
    import java.util.*;
    Imports Everything for the API For Util.
    
    import javax.swing.JLabel;
    Imports JLabel, So words can be Printed Onto A JFrame.
    
    
    
    	
    	private JLabel sum2;
    This JLabel can only be used in class2.java, The JLabel's name is sum2.
    
    	Scanner input = new Scanner (System.in);
    Scans for the number they will be put in to add up your sum.
    	
        int num1 = 0;
    Number 1.
        int num2 = 0;
    Number 2.
    
    	  int sum = num1 + num2;
    Number 1 + Number 2 = Sum.
    		
                    System.out.printf("First Number:");
    Displays "First Number:"
    
    		num1 = input.nextInt();
    Adds the 1st Number To The int num1.
    
    		System.out.printf("Second Number:");
    Displays "Second Number:"
    
    		num2 = input.nextInt();
    Adds the 2ed Number To The int num2.
    
    		sum = num1 + num2;
    Combines/Adds Number 1 with number 2. 
    (Final Product, Adds the number that have been recently added in, if this is not here the sum will be 0.)
    		
    		sum2 = new JLabel(""+num1+" + "+num2+" = "+sum);
    Tells the JLabel to print Number 1 + Number 2 = Sum.
    
    		add(sum2);
    Add the JLabel To The Jframe.




    Class1.java
    Code:
    import javax.swing.JFrame;
    public class Class1 {
    
    	public static void main(String[] args) {
    	Class2 mainframe = new Class2();
    	mainframe.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    	mainframe.setSize(250,120);
    	mainframe.setVisible(true);
    	mainframe.setResizable(false);
    
    	}
    
    }

    Class2.java
    Code:
    import java.awt.FlowLayout;
    import java.awt.event.ActionEvent;
    import java.awt.event.ActionListener;
    import javax.swing.JButton;
    import javax.swing.JFrame;
    import javax.swing.JLabel;
    import javax.swing.JTextField;
    
    
    public class Class2 extends JFrame {
    	
    	private JLabel username;
    	private JTextField username2;
    	private JLabel password;
    	private JTextField password2;
    	private JButton login;
    	
    	public Class2(){
    		super("Dashboard");
    		setLayout( new FlowLayout());
    		
    		
    		username = new JLabel ("Username: ");
    		add(username);
    		
    		username2 = new JTextField("",12);
    		add(username2);
    		
    		password = new JLabel ("Password: ");
    		add(password);
    		
    		password2 = new JTextField("",12);
    		add(password2);
    		
    		login = new JButton (" Login ");
    		add(login, FlowLayout.TRAILING);
    		
    		login.addActionListener(new ActionListener() {
    			public void actionPerformed(ActionEvent event) {
    		
    		if(username2.getText().equals("Kevin") && password2.getText().equals("IDK"))
    		System.out.println("Welcome Kevin!");
    		
    		else if(username2.getText().equals("Rune-Server") && password2.getText().equals("Baws"))
    		System.out.println("Well isnt that just Baws.");
    		
    		else{
    		System.out.println("Username or password incorrect.");
    		
    	}
    		}
    		});
    }
    }


    Hope you can learn something from this, If you have any questions: Reply Below or send me a Pm. Thanks.
     

  2. Thankful user:


  3. #2  
    Registered Member

    Join Date
    Jan 2012
    Posts
    137
    Thanks
    64
    Thanked 68 Times in 33 Posts
    Rep Power
    116
    JPasswordField (Java 2 Platform SE v1.4.2)

    Also a lot of the indentation is horrible.

    Code:
    private JLabel sum2;
    	Scanner input = new Scanner (System.in);
    	
        int num1 = 0;
        int num2 = 0;
    	  int sum = num1 + num2;
    These can all be made local, however if you wanted to keep them all there I'd recommend making them private being that they aren't used outside of their own class (I assume, I didn't read the whole thread).
     

  4. #3  
    Ваша мать имеет рак
    Koâk's Avatar
    Join Date
    Dec 2010
    Posts
    626
    Thanks
    472
    Thanked 208 Times in 145 Posts
    Rep Power
    502
    Do you really think people who know nothing of java or any programming for that matter will understand this?

    No.

    Also, I wouldn't call swing the roots exactly.
    Strč prst skrz krk
     

  5. #4  
    Dan +dan's Avatar
    Join Date
    Nov 2011
    Age
    12
    Posts
    471
    Thanks
    13
    Thanked 25 Times in 24 Posts
    Rep Power
    74
    good job.
     

  6. #5  
    Evervation Developer

    Jason's Avatar
    Join Date
    Aug 2009
    Age
    19
    Posts
    3,338
    Thanks
    517
    Thanked 606 Times in 343 Posts
    Rep Power
    594
    You think learning Swing will help anyone here? The only people who don't know Swing and do Client edits are the ones who barely know how to change the IP address in a client. This will help nobody. /Constructive criticism


    Do you need skills, minigames or unique content implemented? Do you need a bug fixed? Check out my service thread

    Service Thread







     

  7. #6  
    Java Programmer


    Join Date
    Feb 2012
    Posts
    478
    Thanks
    36
    Thanked 35 Times in 32 Posts
    Rep Power
    125
    Quote Originally Posted by Jason View Post
    You think learning Swing will help anyone here? The only people who don't know Swing and do Client edits are the ones who barely know how to change the IP address in a client. This will help nobody. /Constructive criticism

    Rune-Server > Programming > Application Development > Tutorials
    This has nothing to do with Runescape Private servers.


    Rune-Server > Programming > Application Development > Tutorials > Java Programming: Learning the roots
    What the fuck did you expect to find here a gold mine? Learn to read before posting rubbish on my thread.
     

  8. #7  
    Registered Member
    Tenzin's Avatar
    Join Date
    Sep 2011
    Posts
    1,105
    Thanks
    381
    Thanked 393 Times in 225 Posts
    Rep Power
    470
    Quote Originally Posted by Captain Price View Post
    Rune-Server > Programming > Application Development > Tutorials
    This has nothing to do with Runescape Private servers.


    Rune-Server > Programming > Application Development > Tutorials > Java Programming: Learning the roots
    What the fuck did you expect to find here a gold mine? Learn to read before posting rubbish on my thread.
    I don't think swing is java's "roots".

    EDIT: Your conventions suck.
     

  9. #8  
    Java Programmer


    Join Date
    Feb 2012
    Posts
    478
    Thanks
    36
    Thanked 35 Times in 32 Posts
    Rep Power
    125
    To all the haters;

    I don't care what you say about 'roots' if you don't know what roots are then gtfo my thread.
    (Roots: The Basics)

    Enough hate, I will not revisit this thread, Starting to act like Scum because i showed some basic programming, Grow the fuck up and act your age for a change. Sad, I have to deal with you kid Crying every time i login.
     

  10. #9  
    Evervation Developer

    Jason's Avatar
    Join Date
    Aug 2009
    Age
    19
    Posts
    3,338
    Thanks
    517
    Thanked 606 Times in 343 Posts
    Rep Power
    594
    Quote Originally Posted by Captain Price View Post
    To all the haters;

    I don't care what you say about 'roots' if you don't know what roots are then gtfo my thread.
    (Roots: The Basics)

    Enough hate, I will not revisit this thread, Starting to act like Scum because i showed some basic programming, Grow the fuck up and act your age for a change. Sad, I have to deal with you kid Crying every time i login.
    As Null said, Swing is obviously not "The roots" to Java Programming. Maybe you could have taught class structure or inheritance before jumping right into GUI. I believe the reason why everyone is giving your such poor feedback is because of your negligence to realize the obvious issue with the thread, THE TITLE.


    Do you need skills, minigames or unique content implemented? Do you need a bug fixed? Check out my service thread

    Service Thread







     

  11. #10  
    Registered Member
    Tenzin's Avatar
    Join Date
    Sep 2011
    Posts
    1,105
    Thanks
    381
    Thanked 393 Times in 225 Posts
    Rep Power
    470
    Quote Originally Posted by Captain Price View Post
    To all the haters;

    I don't care what you say about 'roots' if you don't know what roots are then gtfo my thread.
    (Roots: The Basics)

    Enough hate, I will not revisit this thread, Starting to act like Scum because i showed some basic programming, Grow the fuck up and act your age for a change. Sad, I have to deal with you kid Crying every time i login.
    If you can't take constructive criticism, why the fuck are you releasing a tutorial?
     

  12. Thankful users:



Page 1 of 2 12 LastLast
Thread Information
Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Replies: 25
    Last Post: 12-28-2012, 06:34 AM
  2. Java: Learn The Roots
    By Albert Einstein in forum Tutorials
    Replies: 0
    Last Post: 03-19-2012, 03:02 PM
  3. Replies: 1
    Last Post: 04-21-2011, 06:07 AM
  4. Replies: 18
    Last Post: 01-06-2010, 09:14 PM
Posting Permissions
  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •