Change Class problems

hi,i have 4 files :
satu.java
import java.awt.BorderLayout;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
import javax.swing.JFrame;
public class satu {
      * @param args
     public static void main(String[] args) {
          // TODO Auto-generated method stub
          JFrame.setDefaultLookAndFeelDecorated(true);
          final JFrame appp = new JFrame("TEST ");
          appp.setSize(150,180);
          appp.setUndecorated(true);
          appp.setResizable(false);
          //testmenunew m = new testmenunew();
          //m.start();
          //m.init();
          appp.setSize(540,430);
          dua m = new dua(appp);
        m.init();
          //TestHeaderRenderer m = new TestHeaderRenderer();
          appp.add(m,BorderLayout.CENTER);   
         appp.setVisible(true);
         //appp.setLocationRelativeTo(null);
          appp.addWindowListener(new WindowAdapter() {
                       public void windowClosing(WindowEvent evt) {
                      appp.setVisible(false);
                      appp.dispose();
}dua.java
import java.applet.Applet;
import java.awt.Color;
import java.awt.Dimension;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JPanel;
public class dua extends Applet implements ActionListener {
      * @param args
     JFrame myframe;
     JPanel test;
     public dua(JFrame sat){
          myframe = sat;
     public void init(){
          this.setLayout(null);
          JButton x = new JButton("Big");
          x.setBounds(0,0,100,20);
          x.addActionListener(this);
          add(x);
          test = new JPanel();
          test.setBounds(5,35,500,200);
          test.setBackground(Color.black);
          tiga s = new tiga();
          s.init();
          s.setSize(new Dimension(400,100));
          test.add(s);
          add(test);
     public void actionPerformed(ActionEvent arg0) {
          // TODO Auto-generated method stub
          int newx = myframe.getWidth()+10;
          int newy = myframe.getHeight()+10;
          //myframe.removeNotify();
          //myframe.setUndecorated(true);
          System.out.println(myframe.isDisplayable());
          myframe.setTitle("X = "+newx+" Y = "+newy);
          myframe.setSize(newx,newy);
          myframe.validate();
          //myframe.addNotify();
}tiga.java
import java.applet.Applet;
import java.awt.Color;
import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;
import javax.swing.JLabel;
public class tiga extends Applet {
     public tiga(){
     public void init(){
          this.setLayout(null);
          setBackground(Color.red);
          JLabel testlab = new JLabel("Click Here");
          testlab.setBounds(10,0,200,50);
          testlab.addMouseListener(new MouseListener(){
               public void mouseClicked(MouseEvent arg0) {
                    // TODO Auto-generated method stub
                    pindah();
               public void mousePressed(MouseEvent arg0) {
                    // TODO Auto-generated method stub
               public void mouseReleased(MouseEvent arg0) {
                    // TODO Auto-generated method stub
               public void mouseEntered(MouseEvent arg0) {
                    // TODO Auto-generated method stub
               public void mouseExited(MouseEvent arg0) {
                    // TODO Auto-generated method stub
          add(testlab);
     public void pindah(){
          empat xx= new empat();
          xx.init();
          add(xx);
}empat.java
import java.applet.Applet;
import java.awt.Color;
import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;
import javax.swing.JLabel;
public class empat extends Applet {
     public empat(){
     public void init(){
          this.setLayout(null);
          setBackground(Color.YELLOW);
          JLabel testlab = new JLabel("This is 4our");
          testlab.setBounds(10,0,200,50);
          add(testlab);
}the problem is when i run satu.java,then there is a JLabel "Click Here" inside JPanel "test",and when i click on Click Here,i want call emapt.java to be viewed at "test" JPanel,and remove "tiga.java" from "test" JPanel.
but my code doesn't work...please help me.
thanks.

thanks pravinth..
now i got another problems..
i try ti change dua.java to :
import java.applet.Applet;
import java.awt.Color;
import java.awt.Dimension;
import java.awt.Font;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;
import javax.swing.BorderFactory;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;
public class dua extends Applet implements ActionListener {
      * @param args
     JFrame myframe;
     JPanel test;
     JPanel contentPane;
     public dua(JFrame sat){
          myframe = sat;
     public void init(){
          Font f  = new Font("Arial",Font.BOLD,10);
          /*this.setLayout(null);
          JButton x = new JButton("Big");
          x.setBounds(0,0,100,20);
          x.addActionListener(this);
          add(x);
          test = new JPanel();
          test.setBounds(5,35,500,200);
          test.setBackground(Color.black);
          tiga s = new tiga(test);
          s.init();
          s.setSize(new Dimension(400,100));
          test.add(s);
          add(test);
          JLabel ex = new JLabel("xxxxxxx");
          ex.setBounds(110,0,100,20);
          add(ex);*/
          this.setLayout(null);
        setBackground(new Color(0,0,130));
        final JLabel keluar =  new JLabel("Logout", JLabel.CENTER);
        final JLabel pilih =  new JLabel("Choose Room", JLabel.CENTER);
        keluar.setBorder(BorderFactory.createLineBorder(new Color(215,215,215)));
        keluar.setBounds(80,20,80,15);
        keluar.setForeground(Color.white);
        keluar.setFont(f);
        keluar.setVisible(false);
        keluar.addMouseListener(new MouseListener(){
            public void mouseClicked(MouseEvent e) {
            public void mousePressed(MouseEvent e) {
            public void mouseReleased(MouseEvent e) {
            public void mouseEntered(MouseEvent e) {
                pilih.setVisible(true);
                keluar.setVisible(true);
            public void mouseExited(MouseEvent e) {
                pilih.setVisible(false);
                keluar.setVisible(false);
        add(keluar);
        pilih.setBorder(BorderFactory.createLineBorder(new Color(215,215,215)));
        pilih.setBounds(0,20,80,15);
        pilih.setForeground(Color.white);
        pilih.setFont(f);
        pilih.setVisible(false);
        pilih.addMouseListener(new MouseListener(){
            public void mouseClicked(MouseEvent e) {
                pilihruang();
            public void mousePressed(MouseEvent e) {
            public void mouseReleased(MouseEvent e) {
            public void mouseEntered(MouseEvent e) {
                pilih.setVisible(true);
                keluar.setVisible(true);
            public void mouseExited(MouseEvent e) {
                pilih.setVisible(false);
                keluar.setVisible(false);
        add(pilih);
        JLabel start =  new JLabel("Start", JLabel.CENTER);
        start.setBorder(BorderFactory.createLineBorder(Color.white));
        start.setBounds(0,5,80,15);
        start.setForeground(Color.white);
        start.setFont(f);
        start.addMouseListener(new MouseListener(){
            public void mouseClicked(MouseEvent e) {
            public void mousePressed(MouseEvent e) {
            public void mouseReleased(MouseEvent e) {
            public void mouseEntered(MouseEvent e) {
                pilih.setVisible(true);
                keluar.setVisible(true);
            public void mouseExited(MouseEvent e) {
                pilih.setVisible(false);
                keluar.setVisible(false);
        add(start);
        contentPane = new JPanel();
        contentPane.setBackground(Color.black);
        contentPane.setBounds(0,40,530,380);
        add(contentPane);
     public void actionPerformed(ActionEvent arg0) {
          // TODO Auto-generated method stub
          int newx = myframe.getWidth()+10;
          int newy = myframe.getHeight()+10;
          //myframe.removeNotify();
          //myframe.setUndecorated(true);
          System.out.println(myframe.isDisplayable());
          myframe.setTitle("X = "+newx+" Y = "+newy);
          myframe.setSize(newx,newy);
          myframe.validate();
          //myframe.addNotify();
     public void pilihruang(){
        contentPane.setVisible(false);
        remove(contentPane);
        contentPane = new JPanel();
        contentPane.setBackground(Color.black);
        contentPane.setBounds(0,40,530,380);
        tiga m = new tiga();
         m.init();
        m.setSize(new Dimension(520,370));
        contentPane.add(m);
        add(contentPane);
}then when i click "Click here",rmpat.java is appeared,but when i move my mouse above START,the four.java changed to center..why it's happened ?thanks..

Similar Messages

  • Hello, Trousseau session asks the password many times in a day.  What to do to change this problem? Mfrance iMac, Mac OS X (10.7.3)

    Hello,
    Trousseau session asks the password many times in a day.
    What to do to change this problem? Mfrance
    iMac, Mac OS X (10.7.3)

    ...I wonder how your question solved their question.

  • My iPhone 5 says unable to connect to network. I have tried all the trouble shooting...resetting phone, router... No change. Problem occurs everywhere not just at home. Any suggestions?

    My iPhone 5 says unable to connect to network. I have tried all the trouble shooting...resetting phone, router... No change. Problem occurs everywhere not just at home. Any suggestions?

    AmishCake wrote:
    Have you tried restoring your softwareyes
    yes I have

  • Need HELP with objects and classes problem (program compiles)

    Alright guys, it is a homework problem but I have definitely put in the work. I believe I have everything right except for the toString method in my Line class. The program compiles and runs but I am not getting the right outcome and I am missing parts. I will post my problems after the code. I will post the assignment (sorry, its long) also. If anyone could help I would appreciate it. It is due on Monday so I am strapped for time.
    Assignment:
    -There are two ways to uniquely determine a line represented by the equation y=ax+b, where a is the slope and b is the yIntercept.
    a)two diffrent points
    b)a point and a slope
    !!!write a program that consists of three classes:
    1)Point class: all data MUST be private
    a)MUST contain the following methods:
    a1)public Point(double x, double y)
    a2)public double x ()
    a3public double y ()
    a4)public String toString () : that returns the point in the format "(x,y)"
    2)Line class: all data MUST be private
    b)MUST contain the following methods:
    b1)public Line (Point point1, Point point2)
    b2)public Line (Point point1, double slope)
    b3)public String toString() : that returns the a text description for the line is y=ax+b format
    3)Point2Line class
    c1)reads the coordinates of a point and a slope and displays the line equation
    c2)reads the coordinates of another point (if the same points, prompt the user to change points) and displays the line equation
    ***I will worry about the user input later, right now I am using set coordinates
    What is expected when the program is ran: example
    please input x coordinate of the 1st point: 5
    please input y coordinate of the 1st point: -4
    please input slope: -2
    the equation of the 1st line is: y = -2.0x+6.0
    please input x coordinate of the 2nd point: 5
    please input y coordinate of the 2nd point: -4
    it needs to be a diffrent point from (5.0,-4.0)
    please input x coordinate of the 2nd point: -1
    please input y coordinate of the 2nd point: 2
    the equation of the 2nd line is: y = -1.0x +1.0
    CODE::
    public class Point{
         private double x = 0;
         private double y = 0;
         public Point(){
         public Point(double x, double y){
              this.x = x;
              this.y = y;
         public double getX(){
              return x;
         public double setX(){
              return this.x;
         public double getY(){
              return y;
         public double setY(){
              return this.y;
         public String toString(){
              return "The point is " + this.x + ", " + this.y;
    public class Line
         private double x = 0;
         private double y = 0;
         private double m = 0;
         private double x2 = 0;
         private double y2 = 0;
         public Line()
         public Line (Point point1, Point point2)
              this.x = point1.getX();
              this.y = point1.getY();
              this.x2 = point2.getX();
              this.y2 = point2.getY();
              this.m = slope(point1, point2);
         public Line (Point point1, double slope)
              this.x = point1.getX();
              this.y = point1.getY();
         public double slope(Point point1, Point point2)//finds slope
              double m1 = (point1.getY() - point2.getY())/(point1.getX() - point2.getX());
              return m1;
         public String toString()
              double temp = this.x- this.x2;
              return this.y + " = " +temp + "" + "(" + this.m + ")" + " " + "+ " + this.y2;
              //y-y1=m(x-x1)
    public class Point2Line
         public static void main(String[]args)
              Point p = new Point(3, -3);
              Point x = new Point(10, 7);
              Line l = new Line(p, x);
              System.out.println(l.toString());
    }My problems:
    I dont have the right outcome due to I don't know how to set up the toString in the Line class.
    I don't know where to put if statements for if the points are the same and you need to prompt the user to put in a different 2nd point
    I don't know where to put in if statements for the special cases such as if the line the user puts in is a horizontal or vertical line (such as x=4.7 or y=3.4)
    Edited by: ta.barber on Apr 20, 2008 9:44 AM
    Edited by: ta.barber on Apr 20, 2008 9:46 AM
    Edited by: ta.barber on Apr 20, 2008 10:04 AM

    Sorry guys, I was just trying to be thorough with the assignment. Its not that if the number is valid, its that you cannot put in the same coordinated twice.
    public class Line
         private double x = 0;
         private double y = 0;
         private double m = 0;
         private double x2 = 0;
         private double y2 = 0;
         public Line()
         public Line (Point point1, Point point2)
              this.x = point1.getX();
              this.y = point1.getY();
              this.x2 = point2.getX();
              this.y2 = point2.getY();
              this.m = slope(point1, point2);
         public Line (Point point1, double slope)
              this.x = point1.getX();
              this.y = point1.getY();
         public double slope(Point point1, Point point2)//finds slope
              double m1 = (point1.getY() - point2.getY())/(point1.getX() - point2.getX());
              return m1;
         public String toString()
              double temp = this.x- this.x2;
              return this.y + " = " +temp + "" + "(" + this.m + ")" + " " + "+ " + this.y2;
              //y-y1=m(x-x1)
    public class Point2Line
         public static void main(String[]args)
              Point p = new Point(3, -3);
              Point x = new Point(10, 7);
              Line l = new Line(p, x);
              System.out.println(l.toString());
    }The problem is in these lines of code.
    public double slope(Point point1, Point point2) //if this method finds the slope than how would i use the the two coordinates plus "m1" to
              double m1 = (point1.getY() - point2.getY())/(point1.getX() - point2.getX());
              return m1;
         public String toString()
              double temp = this.x- this.x2;
              return this.y + " = " +temp + "" + "(" + this.m + ")" + " " + "+ " + this.y2;
              //y-y1=m(x-x1)
         }if slope method finds the slope than how would i use the the two coordinates + "m1" to create a the line in toString?

  • Inner Class Problem - I think...

    Ok here's my problem. I have two classes, one is a servlet, the other implements Runnable. The first class called Job starts a new thread with using the second class, JobItem.
    I created a simple object in the Job classes called lineItem. This is just a collection of Strings that make up a record of the Job run. I created in Job when I need to do things at the record level, and it works great. However, I want to use the same object in JobItem. I thought I could just create another a new instance of lineItem like this:
         Job.listItem list = new Job.listItem();But I get an error: java.lang.NoSuchMethodError: com.jobconsole.web.Job$listItem: method <init>()V not foundI'm sure I am violating some OO rule, or am I really missing an init function? If so what do I put in said init function? Thanks.
    Ross

    The method name <init> is a special method name that is used to refer to the a constructor for a class. If this is a runtime error (which it looks like it is) then what is happening is that some code is trying to call a constructor that doesn't exist. This generally happens when you make a change in one class and don't recompile classes that depend upon it. Try recompiling all of your source, and make sure there are no old copies of class files lying around.

  • Document class problem

    I'm working out of Colin Moock's Essential ActionScript 3.0
    and I get this message when I try to save my file: "A definition
    for the document class could not be found in the classpath, so one
    will be automatically generated in the SWF file upon export." The
    document class is set to zoo.VirtualZoo
    My .fla file sits on the desktop. Also on the desktop, there
    is a folder named zoo. Within this folder named zoo there are
    several .as files, one of the is named VirtualZoo.as
    Even when I try to run the completed file that he provides I
    get this same message. I'm running MacOS10.4.11, using Flash CS3,
    and have already reset all of my ActionScript settings within my
    preferences.
    Here's the link to the files:
    http://moock.org/eas3/examples/moock_eas3_examples/virtualzoo_Flash_authoring/
    Any help would be much appreciated,
    Joe

    I tried it from you're link and it still gave me the same
    problem. Do you think that I've changed some setting? Is there a
    way to completely reset all the defaults in flash? This sucks.
    Joe

  • Open my project and everythings blank? I changed class name.. But everythings gone? Heres a link to my project.

    I broke my project! I made a lil christmas tree with labled presents under it for my friends to click on and it will take them to a link where they can get a gift card code i got for them.
    Anwyas.. I swear.. everything was fine.. All i remember doing last was changing the composition class name and the changing the untittled bit at the top to the same. Also, I did accidently open it in an older version of edge since i have 2 copies on my machine but i do that all the time and never broke a project before.. so i donno..
    I zipped up my files. I am kinda desperate to get this fixed.. Its christmas! Iv been working on this forever.. It needs to be done today.. It was perfect.. I just want my files back? Is there anyway?
    Heres my project if anyone wants to take a look... Everything i did is just gone/blank.. D:   http://portalpacific.net/AussieChristmasParty.rar
    Any help REALLY appreciated!!!
    Happy Holidays!

    Hey Redesign. You still online? I managed to re-create the page I lost.. Took a few hours.. I am having a slight problem though. I centered the composition using the stage preferences to the left, I also added a preloader. These worked fine. I must of done something to break both the centering and the preloader. Its not even letting me edit it. Do you see anything abnormal? (It says it should be centered in the settings in the html file too but its not also same issue with http://portalpacific.net/AussieChristmasParty2.rar

  • Finding class problem

    Hi All,
    I have some problems to load a class dynamically...
    I'm using this command :
    Class.forName("mypackage/myClassName")It returns me a ClassNotFoundException, but it's normal because myckage is not in my classpath...
    So you must think Why he doesn't add the pakage in the classpath ???
    I can't do this because at startup of my application, I don't know yet the package's name, it's stored in a .properties file, and this .properties can change before I have to retrieve the Class...
    So my question is : how to add dynamically the package name to the classPath ? or how to retrieve the class withe the full path ?
    I need your help !!
    Thx in advance,
    Steve

    I think you need to define your own class loader -
    take a look at java.net.URLClassLoaderI try now to use the URLClassLoader, and now I have a
    ClassNotFoundException.
    This is my code :
    String myClassToFind = new String("Hello");
    File file = new File("C:\\folder1\\" +
    myClassToFind.toString() + ".class");               
    URL myUrl = file.toURL();                    
    URL[] arrayURL = new URL[1];
    arrayURL[0] = urlll;
    URLClassLoader classLoader = new
    URLClassLoader(arrayURL);
    Class myClass = Class.forName(myClassToFind, true,
    classLoader);Any idea ?I find the solution :
    Replace :
    File file = new File("C:\\folder1\\" + myClassToFind.toString() + ".class");By :
    File file = new File("C:\\folder1\\")Thx for your help

  • Creating a triangle using polygon class problem, URGENT??

    Hi i am creating a triangle using polygon class which will eventually be used in a game where by a user clicks on the screen and triangles appear.
    class MainWindow extends Frame
         private Polygon[] m_polyTriangleArr;
                       MainWindow()
                              m_nTrianglesToDraw = 0;
             m_nTrianglesDrawn = 0;
                             m_polyTriangleArr = new Polygon[15];
                             addMouseListener(new MouseCatcher() );
            setVisible(true);
                         class MouseCatcher extends MouseAdapter
                             public void mousePressed(MouseEvent evt)
                  Point ptMouse = new Point();
                  ptMouse = evt.getPoint();
                if(m_nTrianglesDrawn < m_nTrianglesToDraw)
                                int npoints = 3;
                        m_polyTriangleArr[m_nTrianglesDrawn]
                      = new Polygon( ptMouse[].x, ptMouse[].y, npoints);
    }When i compile my code i get the following error message:
    Class Expected
    ')' expectedThe two error messages are refering to the section new Polygon(....)
    line. Please help

    Cannot find symbol constructor Polygon(int, int, int)
    Can some one tell me where this needs to go and what i should generally
    look like pleaseI don't think it is a good idea to try and add the constructor that the compiler
    can't find. Instead you should use the constructor that already exists
    in the Polygon class: ie the one that looks like Polygon(int[], int[], int).
    But this requires you to pass two int arrays and not two ints as you
    are doing at the moment. As you have seen, evt.getPoint() only supplies
    you with a single pair of ints: the x- and y-coordinates of where the mouse
    button was pressed.
    And this is the root of the problem. To draw a triangle you need three
    points. From these three points you can build up two arrays: one containing
    the x-coordinates and one containing the y-coordinates. It is these two
    arrays that will be used as the first two arguments to the Polygon constructor.
    So your task is to figure out how you can respond to mouse presses
    correctly, and only try and add a new triangle when you have all three of its
    vertices.
    [Edit] This assumes that you expect the user to specify all three vertices of the
    triangle. If this isn't the case, say what you do expect.

  • Creating a triangle using polygon class problem?

    Hi i am trying to create a triangle with the polygon class. If successful, the user should be able to click on the screen and triangles should appear.
    private Polygon[] m_polyTriangleArr;
    MainWindow()
      m_polyTriangleArr = new Polygon[15];
    class MouseCatcher extends MouseAdapter
          public void mousePressed(MouseEvent evt)
                    Point ptMouse = new Point();
                    ptMouse = evt.getPoint();
                              if(m_nTrianglesDrawn < m_nTrianglesToDraw)
                         int npoints = 3;
                                               m_polyTriangleArr[m_nTrianglesDrawn]
                    = new Polygon( ptMouse.x, ptMouse.y, npoints);
                            m_nTrianglesDrawn++;
                        m_bMouse = true;
                        repaint();
            }Paint section
    public void paint(Graphics gc)
                  if(m_bMouse)
              gc.setColor(Color.green);
              for( int i = 0; i < m_nTrianglesDrawn; i++)
              gc.fillPolygon(m_polyTriangleArr.x, m_polyTriangleArr[i].y, npoints);
    When i try to compile my code i get the following error message:
    Cannot find symbol constructor Polygon(int, int, int)
    --- find symbol variable x
    --- find symbol variable y
    --- find symbol variable npoints.
    Can som1 tell me why i have these error messages when i have already declared a Polygon object array and what i need to change please??

    Check out the API
    http://java.sun.com/j2se/1.4.2/docs/api/java/awt/Polygon.html
    there's no constructor that receives 3 integers
    cheers,
    Manuel Leiria

  • Calling method from another class problem

    hi,
    i am having problem with my code. When i call the method from the other class, it does not function correctly?
    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.*;
    import javax.swing.event.*;
    public class Dice extends JComponent
        private static final int SPOT_DIAM = 9; 
        private int faceValue;   
        public Dice()
            setPreferredSize(new Dimension(60,60));
            roll(); 
        public int roll()
            int val = (int)(6*Math.random() + 1);  
            setValue(val);
            return val;
        public int getValue()
            return faceValue;
        public void setValue(int spots)
            faceValue = spots;
            repaint();   
        @Override public void paintComponent(Graphics g) {
            int w = getWidth(); 
            int h = getHeight();
            Graphics2D g2 = (Graphics2D)g;
            g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
            g2.setColor(Color.WHITE);
            g2.fillRect(0, 0, w, h);
            g2.setColor(Color.BLACK);
            g2.drawRect(0, 0, w-1, h-1); 
            switch (faceValue)
                case 1:
                    drawSpot(g2, w/2, h/2);
                    break;
                case 3:
                    drawSpot(g2, w/2, h/2);
                case 2:
                    drawSpot(g2, w/4, h/4);
                    drawSpot(g2, 3*w/4, 3*h/4);
                    break;
                case 5:
                    drawSpot(g2, w/2, h/2);
                case 4:
                    drawSpot(g2, w/4, h/4);
                    drawSpot(g2, 3*w/4, 3*h/4);
                    drawSpot(g2, 3*w/4, h/4);
                    drawSpot(g2, w/4, 3*h/4);
                    break;
                case 6:
                    drawSpot(g2, w/4, h/4);
                    drawSpot(g2, 3*w/4, 3*h/4);
                    drawSpot(g2, 3*w/4, h/4);
                    drawSpot(g2, w/4, 3*h/4);
                    drawSpot(g2, w/4, h/2);
                    drawSpot(g2, 3*w/4, h/2);
                    break;
        private void drawSpot(Graphics2D g2, int x, int y)
            g2.fillOval(x-SPOT_DIAM/2, y-SPOT_DIAM/2, SPOT_DIAM, SPOT_DIAM);
    }in another class A (the main class where i run everything) i created a new instance of dice and added it onto a JPanel.Also a JButton is created called roll, which i added a actionListener.........rollButton.addActionListener(B); (B is instance of class B)
    In Class B in implements actionlistener and when the roll button is clicked it should call "roll()" from Dice class
    Dice d = new Dice();
    d.roll();
    it works but it does not repaint the graphics for the dice? the roll method will get a random number but then it will call the method to repaint()???
    Edited by: AceOfSpades on Mar 5, 2008 2:41 PM
    Edited by: AceOfSpades on Mar 5, 2008 2:42 PM

    One way:
    class Flintstone
        private String name;
        public Flintstone(String name)
            this.name = name;
        public String toString()
            return name;
        public static void useFlintstoneWithReference(Flintstone fu2)
            System.out.println(fu2);
        public static void useFlintstoneWithOutReference()
            Flintstone barney = new Flintstone("Barney");
            System.out.println(barney);
        public static void main(String[] args)
            Flintstone fred = new Flintstone("Fred");
            useFlintstoneWithReference(fred); // fred's the reference I"m passing to the method
            useFlintstoneWithOutReference();
    {code}
    can also be done with action listener
    {code}    private class MyActionListener implements ActionListener
            private Flintstone flintstone;
            public MyActionListener(Flintstone flintstone)
                this.flintstone = flintstone;
            public void actionPerformed(ActionEvent arg0)
                //do whatever using flinstone
                System.out.println(flintstone);
        }{code}
    Edited by: Encephalopathic on Mar 5, 2008 3:06 PM                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   

  • Accessing MS Sql Server with Java classes - problem connecting to socket

    I found an example at this location which uses java classes to connected to MS Sql Server.
    http://search400.techtarget.com/tip/1,289483,sid3_gci1065992,00.html
    --bummer - it is a login location - so I will include the article
    Anyway, the example is using Websphere, but I am still on Jbuilder (will get wsad soon). So I planted the classes from the example in
    C:\Borland\JBuilder\jkd1.4\jre\lib\ext\...the classes
    Then I copied the code from the example to my jpx project and got an error that it could not connect to the socket. The only thing I changed in the code was the connection string:
    --original string from example:
    Connection connection = DriverManager.getConnection("jdbc:microsoft:sqlserver://1433", "");
    I was getting an error with the 2 argument version of DriverManager - and the second argument here was empty (properties argument). Here was my connection string:
    Connection connection = DriverManager.getConnection("jdbc:microsoft:sqlserver://Myserver:1433;User=sa;Password=");
    I am only using the 1 argument version of DriverManager. Note that the password=" is blank because my RnD workstation is standalone - no one accesses the sql server except me - so no password. I also left out the last semicolon I noticed. Any suggestions appreciated how I could fix this.
    Thanks
    source of article:
    http://search400.techtarget.com/tip/1,289483,sid3_gci1065992,00.html
    iSeries 400 Tips:
    TIPS & NEWSLETTERS TOPICS SUBMIT A TIP HALL OF FAME
    Search for: in All Tips All search400 Full TargetSearch with Google
    PROGRAMMER
    Sample code: Accessing MS SQL Server database from the iSeries
    Eitan Rosenberg
    09 Mar 2005
    Rating: --- (out of 5)
    Nowadays with the help of Java the iSeries can be integrated with other databases quite easy. This tip shows you how. The code included here uses the free Microsoft driver that can be downloaded from here. (SQL Server 2000 Driver for JDBC Service Pack 3)
    If your SQL server does not include the Northwind Sample Database you can find it here.
    http://www.microsoft.com/downloads/details.aspx?familyid=07287b11-0502-461a-b138-2aa54bfdc03a&displaylang=en
    The download contains the following files:
    msbase.jar
    mssqlserver.jar
    msutil.jar
    Those files needs to be copied to the iSeries directories (/home/r_eitan/ExternalJARs).
    Here's the directory structure (on the iSeries) for this sample:
    /home/r_eitan/ExternalJARs - Microsoft files (msbase.jar,mssqlserver.jar,msutil.jar)
    /home/r_eitan/JdbcTest02 - My code (Main.java,Main.class)
    The Java code
    import java.sql.*;
    import java.io.*;
    class Main {
    * Connect to Microsoft SQL server and download file northWind.products as tab
    * seperated file. (products.txt)
    public static void main(String args[]) {
    try {
    PrintStream outPut = new PrintStream(new BufferedOutputStream(new FileOutputStream("products.txt")));
    Class.forName("com.microsoft.jdbc.sqlserver.SQLServerDriver");
    //Connection connection = DriverManager.getConnection("jdbc:microsoft:sqlserver://1433", "");
    Connection connection = DriverManager.getConnection("jdbc:microsoft:sqlserver://Myserver:1433;User=sa;Password=");
    System.out.println("Connection Done");
    connection.setCatalog("northWind");
    String sqlCmdString = "select * from products";
    Statement statement = connection.createStatement();
    ResultSet resultSet = statement.executeQuery(sqlCmdString);
    ResultSetMetaData resultSetMetaData = resultSet.getMetaData();
    int columnCount = resultSetMetaData.getColumnCount();
    // Iterate throught the rows in resultSet and
    // output the columns for each row.
    while (resultSet.next()) {
    for (int index = 1; index <=columnCount; ++index)
    String value;
    switch(resultSetMetaData.getColumnType(index))
    case 2 :
    case 3 :
    value = resultSet.getString(index);
    break;
    default :
    value = """ + resultSet.getString(index) + """;
    break;
    outPut.print(value + (index < columnCount ? "t" : ""));
    outPut.println();
    outPut.close();
    resultSet.close();
    connection.close();
    System.out.println("Done");
    catch (SQLException exception)
    exception.printStackTrace();
    catch (Exception exception)
    exception.printStackTrace();
    --------------------------------------------------------------------------------------------------

    My guess is that the server's host name isn't right. It necessarily (or even usually) the "windows name" of the computer. Try with the numeric IP address instead (type "ipconfig" to see it).
    First aid check list for "connection refused":
    - Check host name in connect string.
    - Check port number in connect string.
    - Try numeric IP address of server host in connect string, in case name server is hosed.
    - Are there any firewalls between client and server blocking the port.
    - Check that the db server is running.
    - Check that the db server is listening to the port. On the server, try: "telnet localhost the-port-number". Or "netstat -an", there should be a listening entry for the port.
    - Try "telnet serverhost the-port-number" from the client, to see if firewalls are blocking it.
    - If "telnet" fails: try it with the numeric ip address.
    - If "telnet" fails: does it fail immediately or after an obvious timeout? How long is the timeout?
    - Does the server respond to "ping serverhost" or "telnet serverhost" or "ssh serverhost"?

  • Macbook pro 13" late 2011 stuck up at apple logo and spinning wheel, changed HDD problem still exists

    i have a macbook pro 13' late 2011 unit and its not starting up, found out that the HDD was defective, but when i changed the HDD the problem still exists, what may be the problem?
    thanks

    Have you tried booting into the Recovery HD and running Disk Utility and checking to see if the HD needs repairs?
    Restart holding Command + r and at the recovery screen select Disk Utility. Then select Macintosh HD and click  on 'repair disk'. If anything gets altered click on repair disk again until you get a clean pass. Restart as normal from the Apple menu. More info here about the Recovery HD:
    http://support.apple.com/kb/HT4718

  • Vendor Master change pointers problem

    Hi ,
    We have a custom program that will read change pointers for Vendor master .
    we use these change pointers to trigger our custom idoc . But we need to select only change pointers of vendors whose changes are confirmed in transaction FK08 or Fk09
    Please let me know how we can check the changpointers for particular vendor is confirmed or not
    Regards,
    Ramesh

    Just as a follow up on this.  I think that within the setup of the classification system you need to configure the tracking of changes.  If you take a look at table TCLA you'll notice that there is a field which indicates if change document are turned on.  I belive that this then relates back to the "virtual" change document objects that I refered to in my previous post.
    It looks like during update tasks that fucntion CLVF_VB_INSERT_CLASSIFICATION and that this checks the TCLA table and then writes the change documents as part of the updates.
    The description of this field in TCLA is:
    Change Documents for Classification
    Indicator: for this class type, a change document is generated for all changes to classification data.
    For technical reasons, this indicator can only be set if the class type is defined for classifying different object types.
    looks like there is some more research needed but this should hoepfully get you on the right track.
    ~Ian
    Edited by: Ian Maxwell on Sep 29, 2008 1:37 PM

  • [CS3 JS] Find/Change Object Problem

    app.changeObjectPreferences = NothingEnum.nothing does not seem to clear the change object preferences for me.
    app.findObjectPreferences = NothingEnum.nothing works as expected, as do both app.findTextPreferences = NothingEnum.nothing and app.changeTextPreferences = NothingEnum.nothing.
    Does anyone else use the new Find/Change Object?

    Hello. I'm new here but it seems to be the only place where I can post this question to.
    I'm working in a C# application that uses InDesign CS3 scripting. I'm trying to create an index automatically from a tabbed list of words in a text file.
    As C# is a strongly typed language, I have to cast all objects to the right type. I'm having problems when I try to add the page numbers to the created index entries using the following code (I've used the CreateIndexEntry.jsx scrip as a starting point).
    //Find all occurrences of the word or set of words (the topic name)
    ((InDesign.FindTextPreference) app.FindTextPreferences).FindWhat = topic.Name;
    InDesign.Objects foundTexts = doc.FindText(System.Reflection.Missing.Value);
    It's supposed to be an Array of Text objects (InDesign.Text) but when I try to cast each object using this
    //Code is forced because I've tried everything here
    //Loop through each finding and add page numbers to topic
    IEnumerator textEnum = foundTexts.GetEnumerator();
    while (textEnum.MoveNext())
    object text = textEnum.Current;
    topic.PageReferences.Add((InDesign.Text)text, InDesign.idPageReferenceType.idCurrentPage, System.Reflection.Missing.Value, System.Reflection.Missing.Value);
    I got the following exception (translated).
    text is not an InDesign.Text object (Interfaces doesn't match)
    So the question is what object type should I use to cast each object resulting by calling the Document's FindText method.
    Every suggestion will ve very welcome.
    Thank You very much.

Maybe you are looking for

  • 10.7.5 Update - now Safari crashes

    Help! I have an early 2008 MacBook and am running Lion. I downloaded the 10.7.5 security update (which took over an hour), and my iPhoto 11 suddenly stated it could not run on OSX 10.7.4!  I checked Software Updates and it still displayed 10.7.5 as b

  • Pricing condition - How to Determine/Calculate price excl. VAT

    Hi, We've the following configured: ZPMC - payment costs - 1 euro (price incl. VAT) MWSI caculates VAT over all items and posts them to the appropriate G/L account. The payment costs excl. VAT needs to be posted to a G/L account aswell. However in ou

  • Problem in ref cursor

    Experts, Any idea to fix the below error? " not all variables bound" Below procedure is successfully created, but thrown above error msg while executing. When I run the 'stmt1' separately, it runs perfect. But as a procedure throwing error. create or

  • Drag and Drop for File Uploads

    Hey, Is it possible to do this in Flex? Drag and Drop files into a flex app - to upload them later (say on a button click). I did some searching and found that it is possible to do this in AIR - drag files from the file system and drop it in the app.

  • In-coming Audio Requests on MBA result in iChat quitting...

    Recently the iChat application began quitting when I accept in-coming audio requests on my MBA. I do not run many applications at any one time and there does not seem to be a pattern between a particular application being open and the application sto