Using two versions of the one class together?? (I think)

Hi, see the following small program, where the user can enter an int, and the program draws that amount of lines, joined together at a centre point. The user can then move these lines around the centre by dragging the red dot at the end of the lines.
Anyway, what I want to be able to do, is have two different versions of this program running side by side, independently of each other. (ie one might have 4 lines, the other have 3). Each one, would also be able to read data from each other.
Is this possible?
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
public class Lines4 extends JFrame implements MouseListener, MouseMotionListener {
private int startx = 200;
private int starty = 200;
private JLabel statusBar;
private Road roads[];
private static final int roadLength = 100;
private static final int circleRadius = 4;
private Road movingRoad;
public Lines4() {
super("Lines4");
String ret = JOptionPane.showInputDialog("How many roads are there?");
int numPoints = Integer.parseInt( ret );
double factor = 2.0 * Math.PI / ( numPoints ) ;
roads = new Road[numPoints];
for (int i=0; i<numPoints; i++){
int x = (int)( roadLength * Math.cos( factor * i ) );
int y = (int)( roadLength * Math.sin( factor * i ) );
roads[i] = new Road( i, startx, starty, circleRadius, startx+x, starty+y );
addMouseListener(this);
addMouseMotionListener(this);
statusBar = new JLabel();
getContentPane().add(statusBar, BorderLayout.SOUTH);
public void paint( Graphics g ) {
g.clearRect( 0, 0, getWidth(), getHeight() );
for (int i=0; i<roads.length; i++) {
roads.draw( g );
// MouseListener Event Handlers
public void mouseClicked( MouseEvent e ){
statusBar.setText( "Clicked at [" + e.getX() +
", " + e.getY() + "]" );
public void mousePressed( MouseEvent e ){
statusBar.setText( "Pressed at [" + e.getX() +
", " + e.getY() + "]" );
for (int i=0; i<roads.length; i++) {
if ( roads[i].onCircle( e.getX(), e.getY() ) ) {
movingRoad = roads[i];
public void mouseReleased( MouseEvent e ){
statusBar.setText( "Released at [" + e.getX() + ", " + e.getY() + "]" );
movingRoad = null;
public void mouseEntered( MouseEvent e ){
statusBar.setText( "Mouse in window" );
public void mouseExited( MouseEvent e ){
statusBar.setText( "Mouse outside window" );
// MouseMotionListener event handlers
public void mouseDragged( MouseEvent e ){
statusBar.setText( "Dragged at [" + e.getX() +
", " + e.getY() + "]" );
if ( movingRoad != null ) {
movingRoad.x = e.getX();
movingRoad.y = e.getY();
repaint();
public void mouseMoved( MouseEvent e ) {
statusBar.setText( "Moved at [" + e.getX() +
", " + e.getY() + "]" );
public static void main( String args[] ) {
Lines4 app = new Lines4();
app.setDefaultCloseOperation( JFrame.EXIT_ON_CLOSE );
app.setSize( 400, 400 );
app.setVisible( true );

You need to be very careful which project you open in which version.
For 2014 make sure its on 2014.1 build 81.

Similar Messages

  • Two threads in the same class ? Is that possible ?

    Hello, I am trying to use threads to move two images around the frame. And I am wondering if it is possible if it is possible to create two separate threads that act differently in the same class, for each of the image.
    Is just that so far I can't see a way since, by implementing Runnable, I'll need to overwrite the run() method. Which in a way just allows me to manage one image.
    Of course I can do two separate classes (each implementing Runnable) for each of the image, but since I think it may be an overkill, I rather to do it in just one.
    So, is that possible ?
    Thank you in advance.

    Of course I can do two separate classes (each implementing Runnable) for each of the image,Use two instances of the same class. Something like this example:
    http://forum.java.sun.com/thread.jspa?forumID=57&threadID=631379

  • I downloaded two versions of the same album by mistake can I get a refund on one?

    I downloaded two versions of the same album, one staight after the other, I've been charged for both, can I get one removed and a refund?

    Carol,
    William Lloyd said it all, but perhaps Kirby Krieger's User Tip will explain a bit more the different uses of albums and projects:
                       The Well-Trod Path: a Beginner's Guide to how Aperture's major parts inter-relate
    Then I imported into Aperature, created new versions, one for each snapshot, then cropped each snapshot, so each snapshot is seperate in Aperature.
    You want to find each snapshot separately in Aperture? Perhaps you could explain more, how you want to organize your photos. William pointed out albums to group versions of an image. You could also assign keywords to mark special occasions like birthdays, weddings, etc.  You could assign faces to find photos of persons by name. You can use the search field in the browser to search for photos by face, date, keyword, etc.  Aperture is really great for accessing images in many different ways. There must be a way to access the images in your Aperture library just like you want to.
    Then, I tried to organize the ton of photos into projects and it won't let multiple versions of the same original photo be in separate projects.
    That is, how Aperture works. All versions of an image need to be in the same project, because they are sharing the same imported original image file. Aperture tries to save your disk space, by by not creating image files for the edited versions. Versions are just a set of instructions how to produce the rendered image, when you want to edit it or to export it. Unless you are working with the version, it will live in limbo and it will not exist as an image file. So all versions are kept together in the same project with the original image file that is necessary to render them as an image.
    Léonie

  • How can I use two single-dimensional arrays-one for the titles and array

    I want to Use two single-dimensional arrays-one for the titles and one for the ID
    Could everyone help me how can i write the code for it?
    Flower
    public class Video
    public static void main(String[] args) throws Exception
    int[][] ID =
    { {145,147,148},
    {146,149, 150} };
    String[][] Titles=
    { {"Barney","True Grit","The night before Christmas"},
    {"Lalla", "Jacke Chan", "Metal"} };
    int x, y;
    int r, c;
    System.out.println("List before Sort");
    for(c =0; c< 3; ++c)
    for(r=0; r< 3; ++ r)
    System.out.println("ID:" + ID[c][r]+ "\tTitle: " + Titles[c][r]);
    System.out.println("\nAfter Sort:");
    for(c =0; c< 3; ++c)
    for(r=0; r< 3; ++ r)
    System.out.println("ID:" + ID[c][r]+ "\tTitle: " + Titles[c][r]);

    This is one of the most bizarre questions I have seen here:
    public class Video
    public static void main(String[] args) throws Exception
    int[] ID = {145,147,148, 146,149, 150};
    String[] Titles= {"Barney","True Grit","The night before Christmas", "Lalla", "Jacke Chan", "Metal"};
    System.out.println("List before Sort");
    for(int i = 0; i < Titles.length; i++)
       System.out.println("ID:" + ID[i]+ "\tTitle: " + Titles);
    System.out.println("\nAfter Sort:");
    for(int i = 0; c < Titles.length; i++)
    System.out.println("ID:" + ID[i]+ "\tTitle: " + Titles[i]);
    Generally you don't use prefix (++c) operators in you for loop. Use postfix (c++).
    Prefix means that it will increment the variable before the loop body is executed. Postfix will cause it to increment after.

  • I have two versions of Pr, one is the latest 2014 and when trying to open a Pr2014 session, I get an error message saying the project was saved in a newer version and cannot be opened. Help

    I have two versions of Pr, one is the latest 2014 and when trying to open a Pr2014 session, I get an error message saying the project was saved in a newer version and cannot be opened. Could there be an issue with an older Pr application on the computer? Please help!

    You need to be very careful which project you open in which version.
    For 2014 make sure its on 2014.1 build 81.

  • Can I use two Time Capsules? one as an extension of my laptop (for music and video storage) and the other one to back up everything from the laptop and  Time Capsule (for music and videos)

    Can I use two Time Capsules? one as an extension of my laptop (for music and video storage) and the other one to back up everything from the laptop and  Time Capsule (for music and videos)

    Not via Time Machine.   It cannot back up from a network location.
    The 3rd-party apps CarbonCopyCloner and ChronoSync may be workable alternatives.
    EDIT:  And, if you're going to do that, you could back up from the Time Capsule to a USB drive connected to the TC's USB port.  Second TC not required.
    Message was edited by: Pondini

  • HT204053 I have two apple ID's.  One is an old one I no longer wish to use, but it is the one associated with my iPhone.  How do I change to my newer apple ID on my iPhone?

    I have two apple ID's.  One is an old one I no longer wish to use, but it is the one associated with my iPhone.  How do I change to my newer apple ID on my iPhone?

    In order to change your Apple ID or password for your iCloud account on your iOS device, you need to delete the account from your iOS device first, then add it back using your updated details. (Settings > iCloud, scroll down and hit "Delete Account")
    If you have used your old ID to purchase content from iTunes or the App store, you may want to continue to use this ID for iTunes only to avoid losing your content.

  • HT4972 Can you have two iPhones to the one iTunes account? I am overseas and using the old iPhone 4 here, but also have a current iPhone 5.

    I have two iPhones, a 5 which I currently use and an old 4 which I use as a second phone as I am overseas. I have connected both to iTunes. Does this cause any problems have two phones on the one iTune account, as far as updates, etc goes?

    Welcome to Apple Support Communities
    It won't cause any problem. Moreover, you will be able to share the purchases between both phones and have the same information by using iCloud, so you don't lose anything

  • I wish to use the previous version not the one that has today been automatically installed. My settings were to let me know and I decide to install when I'm ready

    I wish to use the previous version not the one that has today been automatically installed. My settings were to let me know and I decide to install when I'm ready, how do I go back. This because one of the previous Plugins does not work with this version, and they have no fix for it yet!

    FOR ASSISTANCE WITH ORDERS - iTUNES STORE CUSTOMER SERVICE
    For assistance with billing questions or other order inquiries, please refer to our online support page by clicking here: http://www.apple.com/support/itunes/store/. If you cannot find the answers you are seeking in our robust knowledge base, you can contact us by visiting the following URL http://www.apple.com/support/itunes/store/, clicking on the appropriate Customer Service topic, then using the contact button or email form at the bottom of the page. Responses to emails will be provided as soon as possible.
    Phone: 800-275-2273 How to reach a live person: Press 0 four times
    Hours of Operation: Mon-Fri: 9am-5pm ET
    Email: [email protected]
    How to report an issue with Your iTunes Store purchase
    http://support.apple.com/kb/HT1933
    How to Get a Refund from the App Store
    http://gizmodo.com/5886683/how-to-get-a-refund-from-the-app-store
    Canceling a Digital Subscription
    http://gadgetwise.blogs.nytimes.com/2011/10/14/qa-canceling-a-digital-subscripti on/
     Cheers, Tom

  • Hi, I use two email addresses within one account with gmx.  I created one account with the first email address now. How do I add the second one to this account? Now it looks like this. One account was opened with address A. I receive in this account email

    Hi, I use two email addresses within one account with gmx.
    I created one account with the first email address now. How do I add the second one to this account?
    Now it looks like this.
    One account was opened with address A.
    I receive in this account emails for address A and B.
    But I can only write and answer with address A.

    Hi Rudegar,
    Sorry for my late reply.
    It s not the amount of accounts I'm struggling with.
    When I create now for both email addresses one account, then I receive the same emails two times.
    That is not what I want.
    Because on gmx the two email addresses have the same inbox and outbox.
    E.g. I can login to my gmx account either with email A or B. It doesn't matter.
    Now I want to have the same on my ipad.
    One account with both email addresses.

  • Will using two versions of dreamweaver trash my code??

    Our company is currently building a new website and we keep running into problems.  Currently we have one main web desginer and another person who helps input text and pictures.  Because we have two people working on this project the file bounces between two computers at the office and then is taken home and used on a third computer.  In the midst of the multi-use of computers there are two versions of Macromedia, studio 8 and MX.  We had our code completely trashed and now all versions on each computer are not working.  We think that it was due to a code that was pulled off of a blog for a "print this page" option that was input into the template, but now just realized that using two versions of dreamweaver also may have caused the problem.  If anyone has suggestions as to what may have caused this please respond!
    Thank you!

    Thank you David! We will stop worrying about that and try to back track the tainted code  

  • When I OCR two versions of the same document and then compare th documents in Acrobat Pro XI, I usually get the message that there are no changes to mark.  However, I know there a quite a few number of changes.  I raised this question more than a year ago

    When I OCR two versions of the same document and then compare the documents in Acrobat Pro XI, I usually get the message that there are no changes to mark.  However, I know there a quite a few number of changes.  I raised this question more than a year ago, and the response I received had to do with the quality of the OCR and the scans of the documents.  However, if I use Acrobat Pro XI to save the same documents in Word and then run a comparison in Word all of the changes are marked.  When a PDF is saved as a Word document in Acrobat Pro XI, is a different OCR module being used than the one used in Acrobat Pro XI for text recognition?

    OCR is only for recoginition of the image / picture of text provided by an scanner.
    Content typed into a Word file which is converted to a PDF is (in Word and in PDF) *not* an image  or picture of text - it is the digital text. So, no OCR involved.
    When the "digital" (renderable) text of a PDF's page content is exported to Word no OCR is involved.
    When a PDF's content is from the image output of a scanner and this is a picture of text then OCR comes into play.
    If this content is exported to Word before doing OCR then it is the image that is exported to the Word file.
    Once OCR is performed it is the OCR output that is exported.
    OCR output is (always will be) impacted by "the quality of the OCR and the scans of the documents". 
    Regardless "Compare" is based on a Word file output to PDF1 then edits to the Word file followed by an output to PDF2. You use Acrobat Pro to do a compare of PDF1 & PDF2.
    Paper 1 scanned to image 1 to image 1 in PDF1 that gets OCR 1 and
    Paper 2 scanned to image 2 to image 2 in PDF2 that gets OCR 2
    being processed with Acrobat Pro's Compare can certainly be done.
    But - well you've described what can be observed.
    Be well...

  • HELP! How to install two versions of the same driver???

    Hello,
    Here is my scenario... I am a video chat host on different sites. I recently purchased two of the same Creative Live! Ultra webcams. When I try to broadcast on the 2nd site with the 2nd camera the other goes fuzzy and starts freaking out.
    Is there a way to install two versions of the driver and run both cameras at once without conflict? Please advise what to do since I would like to use these cams.
    Thank you for your help.
    Tara

    tara2nz wrote:
    Hello, Here is my scenario... I am a video chat host on different sites. I recently purchased two of the same Creative Live! Ultra webcams. When I try to broadcast on the 2nd site with the 2nd camera the other goes fuzzy and starts freaking out. Is there a way to install two versions of the driver and run both cameras at once without conflict? Please advise what to do since I would like to use these cams. Thank you for your help. Tara
    Hi, i don't know the aswer but i've the same question. I'm about to get 4 webcams, I think live! Ultra is the best model in market but i've to be sure if there's a way to plug 4 webcams together.
    Thank's for all.

  • Does the Airport Extreme support HP cp1025?  There are two versions of the printer the cp1025 and cp1025nw.  I have the cp1025, and can't set it up. Is there a list of AE/bonjour supported printers?

    Does the Airport Extreme support HP cp1025?  There are two versions of the printer the cp1025 and cp1025nw.  I have the cp1025, and can't set it up.
    Is there a list of AE/bonjour supported printers?

    Bonjour is a transport protocol. It also provides a means of advertising a printer on a network.
    Any list that shows printers that support Bonjour is generally an indication that the printer itself supports this protocol, meaning that when it is connected to the network, you can see it in your default Add Printer browser. In the case of the Airport, it also supports the Bonjour protocol and will advertise any printer that is connected to its USB port. The printer itself does not have to support Bonjour. The Airport performs this function. And like many lists, they are not kept up to date because each vendor releases several new models every quarter or half year.
    There are definitely printers that don't work when connected to the USB port of the Airport. And this is more that the printer driver does not support this type of connection, mainly due to the port not supporting bidirectional communications which some printer drivers require. The Canon UFR2 and CAPT drivers are a good example of this limitation. But this is only the Mac drivers. The Windows equivalent drivers work fine when the printer is connected to the USB port.
    So with you having an issue with the Windows drivers then I don't think it is a case of them not supporting Bonjour but more to do with some other component not functioning when the printer is shared by the Airport. The error message appears to have more to do with local user rights which is probably driver related. I've seen some printers that you cannot use the Windows Add Printer wizard to add them. Instead you have to use the vendors utility because of some proprietary protocol being used. Maybe this is one of those?
    Now that you seen how it should work based on when you used the C3188, if you still get that error message at point 6 of adding the C1025 then it would suggest a driver compatibility issue with the Airport - which is not necessarily a Bonjour compatibility issue. So unless there was another model of HP printer driver that you could use to this C1025 and that was also compatible with the USB port of the Airport Extreme, then I would suggest your best action is to replace the printer with a model that does work. Maybe even one that has builtin wireless so you don't have to use the USB port of the Airport.

  • Can i use two apple tvs with one itunes account?

    can i use two apple tvs with one itunes account?

    yes and you can use more then 2
    just don't give them the same name

Maybe you are looking for

  • No keyboard/mouse in LXDE

    I've setup archlinux for the first time and everything seems to be working but when I launch LXDE I have no keyboard/mouse. Although I can ctrl+alt+F1/2 to get back to console and then kill it w/ ctrl+c. There were 2 Xorg tests in the wiki the first

  • BADI-User exit required for updating Purchase order header field -IHREZ

    Hello All, We have requirement in our business to update the purchase order header field "our reference" EKKO-IHREZ with some text field. We need a BADI/user exit that can be used for updating this field . We have checked the BADI ME_PROCESS_PO_CUST

  • IPhoto 6.0.6 Upgrade Regret

    Hello, I recently did a system update update, (10.5.7) which updated my iPhoto to 6.0.6. Ok, for the record, I like some of the new features, but I HATE what it has done to my image managing, etc. Previously, I was able to view all my images in the c

  • I downloaded the itunes and when i try to click on the icon, it wont go to the itunes

    i downloaded the itunes and when i try to click on the icon, it wont go to the itunes..

  • Webcam icon missing from desktop on windows 7

    hi i no longer see the desktop icon. i use the webcam frequently to click images. the device manager shows the driver installed. how do i get the icon back on my desktop ?? pl help