Results 1 to 4 of 4
  1. #1
    TOAA is offline Member
    Join Date
    Jun 2015
    Posts
    8
    Rep Power
    0

    Default multiple classess in Java

    Using Eclipse, i have a package called 'gui'.
    within this package i have 1 class which has a lot of code, can i split this into multiple classes that when i build the program they all combine as one?

  2. #2
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    Eastern Florida
    Posts
    20,003
    Rep Power
    33

    Default Re: multiple classess in Java

    combine as one
    Please explain what you mean by "combined".
    Each class file will be separate from other class files. The class files can be packaged together in a single jar file.
    If you don't understand my response, don't ignore it, ask a question.

  3. #3
    TOAA is offline Member
    Join Date
    Jun 2015
    Posts
    8
    Rep Power
    0

    Default Re: multiple classess in Java

    This is what im using, the class 'FxxxxOff' has it's own lines, im wondering if i can create a class file 'FxxxxOff'



    package gui;

    import java.applet.Applet;
    import java.awt.Color;
    import java.awt.Graphics;

    public class pixelanimation extends Applet{

    /**
    *
    */

    FxxxxOff your = new FxxxxOff();

    private static final long serialVersionUID = 6129193079852489739L;

    public void paint(Graphics g) {




    try {
    Thread.sleep(500); //1000 milliseconds is one second.
    } catch(InterruptedException ex) {
    Thread.currentThread().interrupt();
    }
    g.setColor(Color.BLUE);
    g.drawRect(11, 10, 1, 1);

    try {
    Thread.sleep(500); //1000 milliseconds is one second.
    } catch(InterruptedException ex) {
    Thread.currentThread().interrupt();
    }

    g.drawRect(10, 11, 1, 1);

    try {
    Thread.sleep(500); //1000 milliseconds is one second.
    } catch(InterruptedException ex) {
    Thread.currentThread().interrupt();
    }

    g.drawRect(11, 11, 1, 1);

    try {
    Thread.sleep(500); //1000 milliseconds is one second.
    } catch(InterruptedException ex) {
    Thread.currentThread().interrupt();
    }

    g.drawRect(12, 10, 1, 1);

    try {
    Thread.sleep(500); //1000 milliseconds is one second.
    } catch(InterruptedException ex) {
    Thread.currentThread().interrupt();
    }

    g.drawRect(10, 12, 1, 1);

    try {
    Thread.sleep(500); //1000 milliseconds is one second.
    } catch(InterruptedException ex) {
    Thread.currentThread().interrupt();
    }

    g.drawRect(12, 11, 1, 1);


    try {
    Thread.sleep(500); //1000 milliseconds is one second.
    } catch(InterruptedException ex) {
    Thread.currentThread().interrupt();
    }




    g.setColor(Color.RED);
    g.drawRect(13, 13, 1, 1);
    g.drawRect(12, 13, 1, 1);
    g.drawRect(13, 12, 1, 1);
    g.drawRect(14, 14, 1, 1);
    g.drawRect(13, 14, 1, 1);
    g.drawRect(14, 13, 1, 1);
    g.drawRect(15, 15, 1, 1);
    g.drawRect(15, 14, 1, 1);
    g.drawRect(14, 15, 1, 1);
    g.drawRect(16, 16, 1, 1);
    g.drawRect(16, 15, 1, 1);
    g.drawRect(15, 16, 1, 1);
    g.drawRect(17, 17, 1, 1);

    }




    }

    class FxxxxOff {
    FxxxxOff() {
    System.out.println("99");
    }
    }
    Last edited by Norm; 06-21-2015 at 03:37 AM. Reason: Removed bad language

  4. #4
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    Eastern Florida
    Posts
    20,003
    Rep Power
    33

    Default Re: multiple classess in Java

    Please edit your post and wrap your code with code tags
    to get highlighting and preserve formatting.

    Yes you could move the inner class to a file by itself
    If you don't understand my response, don't ignore it, ask a question.

Similar Threads

  1. One process open multiple threads on multiple CPUs
    By kfcnhl in forum Threads and Synchronization
    Replies: 2
    Last Post: 12-12-2011, 08:27 AM
  2. multiple Data from Jsp that having same name of multiple input tage to servlet
    By rahul9323.2007@gmail.com in forum Advanced Java
    Replies: 0
    Last Post: 07-29-2011, 01:00 PM
  3. Running multiple threads on multiple CPU cores?
    By Dosta in forum Threads and Synchronization
    Replies: 2
    Last Post: 09-19-2010, 03:48 PM
  4. Replies: 1
    Last Post: 02-04-2010, 11:12 AM
  5. How Add new classess to the System Classs loader.
    By echarish in forum Advanced Java
    Replies: 0
    Last Post: 02-02-2010, 10:54 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •