How to keep all lines drawn already??

Dear friends:
I have following code, it is runnable one, and each time, I can draw Only ONE line between any TWO buttons, and if I draw another line between another pair of buttons, the First line dispear,
But I hope all line I drwa before will be kept and until I delete or remove them,
How to do it??
package com.lib;
import java.awt.*;
import java.awt.event.*;
import java.awt.geom.*;
import javax.swing.*;
public class PaintTest
    public PaintTest()
        Parent parent = new Parent();
        TargetSelector selector = new TargetSelector(parent);
        parent.setLayout(new BorderLayout());
        parent.add(getPanel(selector), "West");
        parent.add(getPanel(selector), "East");
        JFrame f = new JFrame();
        f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        f.getContentPane().add(parent);
        f.setSize(500,400);
        f.setLocation(200,200);
        f.setVisible(true);
    private JPanel getPanel(TargetSelector selector)
        JPanel panel = new JPanel(new GridBagLayout());
        Dimension d = panel.getPreferredSize();
        d.width = 240;
        panel.setPreferredSize(d);
        GridBagConstraints gbc = new GridBagConstraints();
        gbc.insets = new Insets(5,5,5,5);
        gbc.weighty = 1.0;
        gbc.weightx = 1.0;
        gbc.fill = gbc.BOTH;
        gbc.gridwidth = gbc.REMAINDER;
        for(int j = 0; j < 4; j++)
            JPanel p = new JPanel();
            p.setBackground(new Color(220,240,240));
            p.setBorder(BorderFactory.createEtchedBorder());
            p.addMouseListener(selector);
            panel.add(p, gbc);
        return panel;
    public static void main(String[] args)
        new PaintTest();
class Parent extends JPanel
    Line2D line;
    public Parent()
        line = new Line2D.Double();
    public void paint(Graphics g)  // paint will draw over the child components
        super.paint(g);
        Graphics2D g2 = (Graphics2D)g;
        g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING,
                            RenderingHints.VALUE_ANTIALIAS_ON);
        g2.setPaint(Color.red);
        g2.draw(line);
    public void setLine(Point[] points)
        line.setLine(points[0], points[1]);
        repaint();
class TargetSelector extends MouseAdapter
    Parent parent;
    JPanel selectedPanel;
    final int
        NORTH =  2,
        NW    =  3,
        WEST  =  1,
        SW    =  9,
        SOUTH =  8,
        SE    = 12,
        EAST  =  4,
        NE    =  6;
    public TargetSelector(Parent parent)
        this.parent = parent;
    public void mousePressed(MouseEvent e)
        JPanel panel = (JPanel)e.getSource();
        Point p = e.getPoint();
        Point pParent = SwingUtilities.convertPoint(panel, p, parent);
        if(selectedPanel == null)
            selectedPanel = panel;
        else
            parent.setLine(getClosestPoints(selectedPanel, panel));
            selectedPanel = null;
    private Point[] getClosestPoints(Component c1, Component c2)
        Point p1 = getClosestPoint(c1, c2);
        Point p2 = getClosestPoint(c2, c1);
        return new Point[] {p1, p2};
    private Point getClosestPoint(Component c1, Component c2)
        Rectangle r1 = SwingUtilities.convertRectangle(c1.getParent(),
                                                       c1.getBounds(), parent);
        Rectangle r2 = SwingUtilities.convertRectangle(c2.getParent(),
                                                       c2.getBounds(), parent);
        int outcode = r1.outcode(r2.getCenterX(), r2.getCenterY());
        Point p = new Point();
        switch(outcode)
            case NORTH:
                p.x = r1.x + r1.width/2;
                p.y = r1.y;
                break;
            case NW:
                p.x = r1.x;
                p.y = r1.y;
                break;
            case WEST:
                p.x = r1.x;
                p.y = r1.y + r1.height/2;
                break;
            case SW:
                p.x = r1.x;
                p.y = r1.y + r1.height -1;
                break;
            case SOUTH:
                p.x = r1.x + r1.width/2;
                p.y = r1.y + r1.height -1;
                break;
            case SE:
                p.x = r1.x + r1.width -1;
                p.y = r1.y + r1.height -1;
                break;
            case EAST:
                p.x = r1.x + r1.width -1;
                p.y = r1.y + r1.height/2;
                break;
            case NE:
                p.x = r1.x + r1.width -1;
                p.y = r1.y;
                break;
            case 0 /* INSIDE */:
                System.out.println("selectedPanel == panel");
                break;
            default:
                throw new IllegalArgumentException("illegal outcode: " + outcode);
        return p;
}Thanks so much in advance
Sunny

Dear friends:
I have following code, it is runnable one, and each
time, I can draw Only ONE line between any TWO
buttons, and if I draw another line between another
pair of buttons, the First line dispear,
But I hope all line I drwa before will be kept and
until I delete or remove them,
How to do it??As itchyscratchy said, store all the information and paint it each time. Also, read this article:
http://java.sun.com/products/jfc/tsc/articles/painting/index.html

Similar Messages

  • Does anyone know how to keep all songs in the same album when they say featuring someone?

    Each time I load a CD onto Itunes that has an artist who features another artist on that particular song, it puts it in my library as a separate CD even though it will have the same album listed.  For instance Lady Gaga's song just dance features Colby O'Donnis that song is in its own spot while the rest of the cd is together that one song is separate and I don't know how to keep them all together.  Someone help.

    Get the Informations for that song and have a look in the "Sorting" area if there is something different. The data inserted there is just for how iTunes will order the songs.
    If the Interpret in the general informations is "Lady Gaga" and in the sorting area is "Lady Gaga feat. xxxx" than you'll see Lady Gaga as the interpret but it's sort to a second entry "Lady Gaga feat. xxxx".

  • How to keep all developments in one package

    Hi
    I have a requirement
    In my company one new training server was installed for which all developments should be copied from other servers client.
    For this i have to keep all developments in one package.
    Can anyone suggest me how to do this
    urgent plz
    thanks in advance
    sateesh

    Hello Sateesh
    In the transport organizer (<b>SE10</b>) you can create a workbench request of the following type: <b>Relocation of objects with package change</b>
    That's the documentation of this request type:
    Select relocation of objects with package change
        Relocations of objects with a package change are transports with which
        o   you change the original location of the objects entered and
        o   reassign the objects to an appropriate new package.
    Use
        The package change means that you can automatically adjust the transport
        attributes of the objects to the new development system. This means that
        you edit the objects immediately after they have been imported into the
        target system.
    I have not yet used this kind of request but with some playing around you should easily find out how it works. I am sure this is (one of the possible) solutions to your problem.
    Regards
      Uwe

  • How to keep all my itunes after install of leopard?

    Assume I am not all that when it comes to macs. Not new but rusty.
    I have tiger with itunes and it has loads of podcasts/albums(rips) etc, and also on my ipod touch. I would like some help as to how do I keep all this after I install leopard. I think I am going for a full install rather than an upgrade.
    The mac is an imac with pre-installed tiger. I am sure there is some way of keeping my itunes folder after i wipe the drive but have never done anything beyond fill up ipods with stuff.
    I thank you in advance for any pointers.

    Hi,
    I would suggest backing up your entire iTunes Music folder to an external hard drive or disk if the folder size is practical. To retain your playlists for reimport later on, open iTunes, select the Music Library and choose File->Export Library then save it off system along with the back up.
    I recommend using Terminal to back up your iTunes Music folder because Finder's drag and drop can sometimes corrupt copied files, particularly when the directory is large. Suppose you've connected a firewire or usb external hard drive and you can see it mounted on your Desktop, here's what I would do using Terminal (/Applications/Utilities):
    Open the directory ~/Music/iTunes/
    Open Terminal and type the command scp -r. Now drag in the folder iTunes Music (your copy source). Next drag in the external drive mounted on your Desktop (your copy destination). The Terminal window should now read something similar to this, press Return to start the copy process:
    scp -r ~/Music/iTunes/iTunes\ Music /Volumes/External HD
    When the process is complete the command prompt will return back to you. If you want to see the copy in progress change scp -r for scp -v -r. The -v makes the process verbose.
    I'm with you on choosing a clean install, i choose this method every time for upgrades. Archive and Install presents the possibility of dragging old conflicts back into a clean system.

  • How to keep all files in differents browsers

    I use differents browsers how to keep the bookmarks organised in all of them ?
    Is better url manager or Bookit ?
    Thanks

    What del.icio.us would do is make all bookmarks you create there available to any browser on any computer you happen to be using. It will not give you the same set of bookmarks in each of your browsers. I mentioned it because it has become a popular way of keeping bookmarks which is not dependant on any one browser and is available even when you are not on your own computer.
    The bookmark/url managers would be the better way to go to actually manage the bookmarks in your various managers. With them being shareware, you can try them out to see it they fit your needs before you would have to pay for them. The two I mentioned both got high user ratings on VersionTracker. You might be able to find other url managers there as well. It has been a while since I tried any url managers myself, so I cannot give a personal recommendation on any of these programs.

  • How to keep all text and formats the same on multiple computers?

    I'm creating a file in InDesign CS6 on my Windows computer. I keep everything on my flash drive. When I go to school, I bring my flash drive with me and open it up on the Mac computer, but then there are are compatibility issues. There seems to be missing fonts and formats but the school uses the same version of InDesign I do. Now I was told a lot of things of how to keep the fonts and formats the same (embed the links, package the files, outline the text, save as IDML). However, it is not clear to me what each of those options do, so I don't know when or why to use them. So I just want to make sure that when I bring in my file in next Monday, I won't have any missing fonts or formats. What would you suggest is the proper things to do to keep everything the same on multiple computers? And could you please explain why?

    If you want cross-paltform comaptibility limit the fonts to OpenType or Windows TrueType formats, both of which work on both Mac and PC. To avoid missing font warnings the fonts must either be installed on each computer, or they must be in a folder named Document Fonts in the same location as the .indd file they are to work with. Packaging the file will build taht folder for you.
    the rest of the stuff in your list won't help you. .idml would allow you to open on an older version, but does nothing for your situation. Embedding the links will keep you from having missing links, but so will packaging, and embedded links will make the file much larger and harder to work with.
    For goodness sake, don't even think about outlining the text. It stops being text when you do that and you can no longer edit it.
    And finally. do yourself a big favor and don't attempt to actually work on your file directly from the flash drive. Copy the whole package folder to the hard drive, work on it, then copy back. You don't want to know how many files are fatally damaged by write errors on flash drives.

  • How to Keep all the Portal report menu's are "open" when the user logs on?

    Hi
    I have a question about the BI Portalu2019s configuration.  Does anyone know how to keep the Web Portal (i-vew) report menu's are "open" when the user logs on?
    Thanks.
    For example:
    Web Report Panel
    Report  Folder A 
                  i-view  a1
                  i-view  a2
                  i-view  a3
                  i-view  a4
                  i-view  a5
                  i-view  a6
    Report  Folder B 
                  i-view  b1
                  i-view  b2
                  i-view  b3
                  i-view  b4
                  i-view  b5
                  i-view  b6

    Hi,
    Thank you very much.  The problem is the Folder didn't 'open when the user logs on.  Yes, the iview can be openned.  Does anyone know how to set the default Open for the Folder.  My question is about the folder in BI portal.  Yes, the ivew we can set the defaul Open but we have Folder in the portal and our user wants to be able to see the report lists when they log on to the Portal.
    For example:
    Our Current situation
        Navigation Panel
       .>Act vs Plan report Folder_
       .>Year to Day report Folder_
    Hope To Be (When user logs on the BI Portal)
       Navigation Panel
        .>Act vs. Plan report Folder
            (i-view) Report A
            (i-view) Report B
            (i-view) Report C
            (i-view) Report D
            (i-view) Report E
    .>Year to Day report Folder
           (i-view)  Budget by Cost Element report
           (i-view)  Actual by Cost Center report
           (i-view)  Income statement report
           (i-view)  Balance Sheet report

  • HOW TO KEEP 3 LINES IN SELECTION-SCREEN

    hi all,
    i have a requirement.
    i have to keep one field in selection-screen say v_text whose length is 70 characters .
    and i have to display text as follows
    <System Date> ': EST STATUS:HUNGARY PROJECT:'
    in form of 3 lines by default.
    any one can send me the sample code how to do this.
    Thanks,
    Maheedhar.T

    Maheedhar,
    try this code..
    data: v_text(80).
    SELECTION-SCREEN BEGIN OF LINE.
    SELECTION-SCREEN COMMENT 01(30) v1 FOR FIELD p_monat.
    SELECTION-SCREEN END OF LINE.
    SELECTION-SCREEN BEGIN OF LINE.
    SELECTION-SCREEN COMMENT 01(30) v2 FOR FIELD p_monat.
    SELECTION-SCREEN END OF LINE.
    SELECTION-SCREEN BEGIN OF LINE.
    SELECTION-SCREEN COMMENT 01(10) v3 FOR FIELD p_monat.
    PARAMETERS p_monat LIKE bkpf-monat.
    SELECTION-SCREEN END OF LINE.
    INITIALIZATION.
      v_text = 'aaaaaaaaaaaaaaaaaaaaaaBBBBBBBBBBBBBB'.
      CONCATENATE sy-datum v_text INTO v_text SEPARATED BY space.
      v1 = v_text+0(30).
      v2 = v_text+31(30).
      v3 = v_text+62(10).
    -Anu
    Message was edited by:
            Anupama Reddy
    Message was edited by:
            Anupama Reddy

  • I am copying audiobooks on CD to the iTunes, so that I can send them to my iPod, however I do not know how to keep all the disks that comprise a book ( sometimes up to 18 disks ) organized so that they are recognized as part of abook and played in sequenc

    I guess I asked the question in the title, anyway one more time:I am copying audiobooks on multiple CDs to Itunes so that I can sync them to an Ipod and listen to them, how do I keep the multiple disks inone folder under one book title and how do I keep the tracks from intermingling with the tracks from another disk?  EXAMPLE: I just downloaded one book, consisting of three CDs and I see the Track o1 information from each CD in sequence followed by three Track 02, instead of all tarcks from the first CD followed by the tracks of the next CD etc.

    Thank you, I read that lengthy procedure before I asked the question.
    I have no way of following all of those steps successfully since I am about butterfingered a sthe last dinosaur and will make every  mistake in the world and get frustrated with  something that SHOULD be simple.
    I have the three disk autobook showing in iTunes library as one title , I had to  enter the dat amyself since it was not listed on the internet data base, All entries for all tracks match and I have indicated  the disk number  as  one, two or three of three as indicated.
    Yet when I sync the iTunes to the iPod I am being presented with each individual track listed in the Audiobook Menu.
    I am using the latest version of iTunes and a iPod Classic 160G-- that I purchased three days ago purposefully for the converting of the audiobooks to a portable device since the Library of Congress  ( NLS BARD ) books are formatted differently and the player is bulky.
    Does anybody hav eany other ideas?
    Does anybody have an e-mail address for Apple,  preferably iTunes folks?
    This is a handicap accessability problem since my wife cannot see and depends on these audio books.
    Obviously I will try that link to that Chapter and Verse site and see what I can do.
    Thank you for your quick response

  • How to keep last line together with table?

    Hi guys,
    I am new to Reports , so please excuse me for probably primitive question.
    I am creating consolidated invoices report consisting of invoice date + 2 last lines of company signature like Yours, XXYYY Ltd.
    Depending on number of lines in invoice data it is possible that only these 2 signature lines are printed on last page.
    How to force keeping them together with invoice data?
    Thanks in advance,
    Asnate

    Hi,
    If you have repeating Invoice lines, and they are filling up your page, then there is no other option but to orphan the "Yours, XXYYY Ltd" onto another page.
    Somethings you can do increase the amount of space on your page is decrease the size of your top and bottom margins, and also make sure you have no excess whitespace either in your template or within your placeholders.
    Unfortunately, anything that is displayed after a table of repeating lines, where there is no limit to the number of lines, is susceptable to being orphaned, as there is no guarantee that it will fit onto the page.
    Hope this helps,
    Cj

  • NAS server with mp3s and Itunes for Mac & Windows. How to keep all running?

    a)I have mp3s on the server (a NAS Hard Drive) when I run I-tunes even after selecting a a folder in the network hard drive tries to move the music on my local macbook under the i-tunes music folder location, this happens usually when I get I-tunes updates and re-installation. Is any way to stop I-Tunes to move files? I have no space in my Mac for all the mp3s.
    b) what is the best way to share the music files between two computers with I-Tunes, one being a Mac and the other a Windows? This, without screwing the files.
    c) I-Tunes generated a lot of duplicates. My guess is the same song may apply to different albums. Any way to correct this problem, so no more duplicates?
    Thank You
    Macbook   Mac OS X (10.4.10)  

    If you want cross-paltform comaptibility limit the fonts to OpenType or Windows TrueType formats, both of which work on both Mac and PC. To avoid missing font warnings the fonts must either be installed on each computer, or they must be in a folder named Document Fonts in the same location as the .indd file they are to work with. Packaging the file will build taht folder for you.
    the rest of the stuff in your list won't help you. .idml would allow you to open on an older version, but does nothing for your situation. Embedding the links will keep you from having missing links, but so will packaging, and embedded links will make the file much larger and harder to work with.
    For goodness sake, don't even think about outlining the text. It stops being text when you do that and you can no longer edit it.
    And finally. do yourself a big favor and don't attempt to actually work on your file directly from the flash drive. Copy the whole package folder to the hard drive, work on it, then copy back. You don't want to know how many files are fatally damaged by write errors on flash drives.

  • How to get all lines in a paragraph?

    Hey all,
    I've got a confusing question, see the codes below:
    tell application "Adobe InDesign CS4"
              set doc to open orphan_check
              tell doc
                        set myPage to page 4
                        set myTextFrame to first text frame in myPage
                        set myParagraph to third paragraph in myTextFrame
                        set lineList to lines in myParagraph
                        if (length of lineList is greater than 1) then
                                  set hasMultipleLine to true
                        else
                                  set hasMultipleLine to false
                        end if
              end tell
    end tell
    I'm trying to get all the lines from one paragraph by using "set lineList to lines in myParagraph", and it returns an error. Also, if try "count of lines of myParagraph", it returns 0 all the time. But it works well for the text fame. For example, if I tried "set lineList to lines in myTextFrame", it can break the line correctly. So any suggestions? I am trying to do the orphan check, that is see if the last line in each paragraph contains enough characters.
    Thanks~

    Well,
    '                    set myParagraph to third paragraph in myTextFrame'
    returns the content fo the paragraph ...
    try to set:
    'set myParagraph to object reference of third paragraph of myTextFrame'
    or just:
    count lines of paragraph 1 of first text frame
    Hope it'll be of some help

  • How to keep all visited sites from opening a new tab

    No matter what I do, everything I click opens in a new tab., even if I am already on a tab I want it to replace. I can't find the setting to change this. I'd like to be able to do a CTRL--click if I want a new tab. It's annoying ending up with 30 tabs open when I'm browsing.
    I have a couple of tab add-ons, Multiple tab handler and Bar Tab LiteX. Could these be causing this problem?

    The Reset Firefox feature can fix many issues by restoring Firefox to its factory default state while saving your essential information.
    Note: ''This will cause you to lose any Extensions, Open websites, and some Preferences.''
    To Reset Firefox do the following:
    #Go to Firefox > Help > Troubleshooting Information.
    #Click the "Reset Firefox" button.
    #Firefox will close and reset. After Firefox is done, it will show a window with the information that is imported. Click Finish.
    #Firefox will open with all factory defaults applied.
    Further information can be found in the [[Reset Firefox – easily fix most problems]] article.
    Did this fix your problems? Please report back to us!

  • Query Designer: how to keep all char. in one vertical column when running?

    In query designer, if dragging char. one by one from the left to the row section, when running the query, these row characteristics all show in different columns.  How to show them in one column?  Just give you an example, usually the query result format would like the following:
    Salesman--Sales Office-Sales Org----Quantity
    John--Office1Org1--
    50
    Mark--Office2Org2--
    100
    Kevin--Office3Org3--
    30
    Now, we would like the query result looks like the following format:
    Salesman------Quantity
    John----
    50
    Mark----
    100
    Kevin----
    30
    Salesman Total------180
    Sales Office------Quantity
    Office1----
    xx
    Office2----
    xx
    Office3----
    xx
    Sales Office Total------xx
    Sales Org-------Quantity
    Org1----
    xx
    Org2----
    xx
    Org3----
    xx
    Sales Org Total------xx
    How to generate the above query?
    Thanks and we will give you reward points!

    Hi,
    What you want to do is 3 different views of the same report
    If you publish the information in Excel (workbook) you have to call 3 times the query in three different sheets, and manually do a summary....
    If you publish in the web, then you can have 3 times the same query but with different views on the same page. you can then control the three tables with the same navigation block...
    But your request is not the way Bex works...
    PYG

  • Re: How to keep all the chat message forever?

    I want to keep my past messages but they keep slowly disappearing I av no access to computor only ipad nd phone nd cant see a way of keeping history of conversations im gutted that i am loseing them slowly PLEASE SOMEONE HELP

    On your laptop go to Windows Start and in the Search/Run box type %appdata%\skype and then press Enter or OK button. In the File Explorer that will pop-up locate a folder named as your Skype name. Open this folder. You should see there a file named main.db. May only be shown as "main" but with description "Data base file" in the Type column. This is the file that contains all your chats. What is the size of this file? Can you also se a file named main.corrupt or main.iscorrupt?

Maybe you are looking for

  • How do i create this an executable jar???

    I have the following package structure, could anybodt tell me what i have to type into my manifest file to get it to work? thanks com/anoobis/userInterface/UserInterface.class <-- main class com/anoobis/xml/Generate.class com/anoobis/panels/StatusBar

  • Query on Unit of issue

    Hi, In the material master (warehouse mgmt1 view), we have two unit of measures defined. One is base unit of measure and the other is Unit of issue. 1. What is unit of issue and what it's used for? 2. Is it applicable only for materials issued from w

  • Updated to FireFox 11 and I keep getting "checking compatibility of add-on" when I start the browser.

    I just updated to FireFox 11 and whenever I start the browser, I get that annoying window that checks for the compatibility of add-ons. I have looked around for solutions and have tried the following: 1. Deleting several extension files from the prof

  • CCM 5.1: How to re-send the CDR to Billing Server

    Dear Sir, When the SFTP is broken and re-connected, the CDR manager does not re-send the CDR records that generated during the connection broken time. How can I or CCM re-send these records to Billing Server again to keep the Billing Report Coorect?

  • Acrobat trial will not install

    Acrobat trial will not install