Find out number of components between 2 points

Hello al,
I want to get all the components between 2 points in a container.Is rthere any way or method w hich will help me out ???

import java.awt.*;
import java.awt.event.*;
import java.awt.geom.*;
import javax.swing.*;
public class FindingComponents
    public FindingComponents()
        LinePanel linePanel = new LinePanel();
        JPanel buttonPanel = getButtonPanel();
        JLabel label = getLabel();
        PointLocator pointer = new PointLocator(linePanel, buttonPanel, label);
        linePanel.addMouseListener(pointer);
        JPanel panel = new JPanel();
        OverlayLayout overlay = new OverlayLayout(panel);
        panel.setLayout(overlay);
        panel.add(linePanel);        // upper panel
        panel.add(buttonPanel);      // lower panel
        JFrame f = new JFrame();
        f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        f.getContentPane().add(panel);
        f.getContentPane().add(label, "South");
        f.setSize(400,400);
        f.setLocation(200,200);
        f.setVisible(true);
    private JPanel getButtonPanel()
        JPanel panel = new JPanel(new GridBagLayout());
        GridBagConstraints gbc = new GridBagConstraints();
        gbc.weighty = 1.0;
        gbc.weightx = 1.0;
        for(int j = 0; j < 16; j++)
            String id = "button " + (j + 1);
            JButton button = new JButton(id);
            button.setActionCommand(id);
            if((j + 1) % 4 == 0)
                gbc.gridwidth = gbc.REMAINDER;
            panel.add(button, gbc);
            if((j + 1) % 4 == 0)
                gbc.gridwidth = 1;
        return panel;
    private JLabel getLabel()
        JLabel label = new JLabel("none", JLabel.CENTER);
        label.setBorder(BorderFactory.createTitledBorder("components intersecting line"));
        Dimension d = label.getPreferredSize();
        d.height = 45;
        label.setPreferredSize(d);
        return label;
    public static void main(String[] args)
        new FindingComponents();
class LinePanel extends JPanel
    Line2D line;
    public LinePanel()
        line = new Line2D.Double();
        setOpaque(false);
    protected void paintComponent(Graphics g)
        super.paintComponent(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 start, Point end)
        line.setLine(end, start);
        repaint();
class PointLocator extends MouseAdapter
    LinePanel linePanel;
    JPanel buttonPanel;
    JLabel label;
    Point start;
    boolean startSet;
    public PointLocator(LinePanel lp, JPanel bp, JLabel label)
        linePanel = lp;
        buttonPanel = bp;
        this.label = label;
        start = new Point();
        startSet = false;
    public void mousePressed(MouseEvent e)
        Point p = e.getPoint();
        if(!startSet)
            start = p;
            linePanel.setLine(start, p);
            startSet = true;
        else
            linePanel.setLine(start, p);
            start = p;
            startSet = false;
    public void mouseReleased(MouseEvent e)
        if(!startSet)
            Component[] c = buttonPanel.getComponents();
            Rectangle rv = new Rectangle();
            String s = "";
            for(int j = 0; j < c.length; j++)
                c[j].getBounds(rv);
                if(linePanel.line.intersects(rv))
                    s += ((JButton)c[j]).getActionCommand() + ", ";
            if(s.indexOf(",") != -1)
                s = s.substring(0, s.lastIndexOf(","));
            else
                s = "none";
            label.setText(s);
            label.repaint();
}

Similar Messages

  • How to find out the rows inserted between a time period.

    Hi,
    Please help me to solve this.
    Table - emp.
    Colmns - empno(Primary Key),ename, mgr
    How to find out the rows inserted between a time period.
    For eg:- Between 02-Oct-2006 1 PM and 03-Oct-2006 2 PM.
    regards,
    Mathew.

    Hi,
    Maybe work:
    For each row, ORA_ROWSCN returns the conservative upper bound system change number (SCN) of the most recent change to the row. This pseudocolumn is useful for determining approximately when a row was last updated. It is not absolutely precise, because Oracle tracks SCNs by transaction committed for the block in which the row resides
    e.g.:
    SGMS@ORACLE10> create table test(cod number);
    Table created.
    SGMS@ORACLE10> insert into test values (1);
    1 row created.
    SGMS@ORACLE10> insert into test values (2);
    1 row created.
    SGMS@ORACLE10> commit;
    Commit complete.
    SGMS@ORACLE10> insert into test values (3);
    1 row created.
    SGMS@ORACLE10> commit;
    Commit complete.
    SGMS@ORACLE10> select SCN_TO_TIMESTAMP(ora_rowscn),ora_rowscn,cod from test;
    SCN_TO_TIMESTAMP(ORA_ROWSCN)       ORA_ROWSCN        COD
    06/11/06 08:56:56,000000000         727707205          1
    06/11/06 08:56:56,000000000         727707205          2
    06/11/06 08:57:05,000000000         727707210          3Cheers

  • How to find out  number of includes for a given program dynamically

    Hi all
    I have a requirement in which, I have to find out  number of includes and their names for a given  user defined program dynamically
    if u know the answer pls let me know
    Thanks in advance
    Devi

    Hi rama,
    1. use this FM - RS_GET_ALL_INCLUDES_FOR_PRTAB
    regards,
    amit m .

  • How to find out Number of entries in a Huge Table?

    Hi,
    I would like to know Number of entries in table DFKKOP. when i try to get it through se16, it takes more than 10 minutes in dialogue process so a time out occurs. is there any way to find out number of entries in the table Apart from creating a program for that?
    Please guide me to the solution.
    Thanks,
    Lijo Joseph
    Message was edited by: Lijo Joseph Vazhappilly

    REPORT  YCHATEST                                .
    Data : begin of itab occurs 0.
            include structure tab512.
    data:end of itab.
    data : v_count like sy-index,
           tabname like X030L-TABNAME value 'DFKKOP'.
    CALL FUNCTION 'RFC_GET_TABLE_ENTRIES'
      EXPORTING
        table_name              = tabname
    IMPORTING
       NUMBER_OF_ENTRIES       = v_count
    tables
       entries                 = itab.
    write : v_count.
    Message was edited by: Sekhar

  • How to find out the common things between two rpds?

    How to find out the common things between two rpds? And place the common things in a common RPD.

    I thought of one solution.
    Original RPD = A
    Modified RPD = B
    XML Patch created for A-B = X
    Now open the XML Patch in IE or Mozilla and delete the columns/tables/variable/etc,. from the Original RPD A.
    But its a cumbersome process, if the XML file is of very less size its Ok. If its 10-20 MB then going line by line and deleting the change is not the process to be followed.
    I have to check whether its just the delete or modify or drop.
    Let me know your thoughts.

  • How i can find out number of transaction code created in last 6 month

    Dear Friends,
    How i can find out number of transaction code created in last 6 month and last used date for each transaction code.
    System - ECC 5.0
    Plz help.
    Thanks,
    Regards,
    Sachin

    Hi,
    As per your query you can find out the list of t-code not to use in last time details in suim t-code.
    Anil

  • How to find out number of concurrent users  connectd to a site?

    I would like to find out the number of concurrent users on my site. What is the best way to do it?
    This is how I implement it currently:
    I have a HashSet object in the session. whenever a user visits the page, i added the user's sessionID to the HashSet. But when a user leaves my page, it won't inform my jsp pages. The only thing I can do now is whenever I add a new sessionID, I loop through the HashSet and check to see which sessionID is invalid or inactive, then remove the it. Does a user session becomes invalid immediately when the user leaves the page, or it has to wait till it times out?
    Are there any other more efficient ways of doing it?

    Look at HttpSessionBindingListener. That will let you do what you want to, correctly.
    User session will time not. If it were to become invalid immediately, it won't be called a "session" would it?

  • How can I work out the Total Uptime between two points?

    I need to find the TOTAL uptime between a certain date and now (need to separate for an electricity bill). Can someone help me with a script or something?
    Thanks

    I'm confused as to what you are looking for if uptime is not it. 
    I need to find out how long it has been powered on from the 6th August 2014 to now. Any ideas?
    If the system has been rebooted in that time then you might be able to go back into the log files and as Mark Jalbert wrote look for the times the system was shutdown and then booted and get a rough figure that way. But of course this requires that the log files since August are still available.
    Of course what the system was booted there is no guarantee all external peripherals were also on and when the system was shutdown there is no guarantee that all the peripherals were turned off so at best you are getting a rough estimate.

  • How to find out number of bookmarks created?

    Is there any way to find out how many bookmarks have been created by users? I can see a list of all bookmarks under RSA1, Reporting Agent, Bookmarks, but I can't see a way to export that list or show a total.

    Thanks, that table has a list of all bookmarks.
    It seems like it only stores the last time a bookmark was accessed though...for example, if someone opens a bookmark 10 times, there would still just be one record for that bookmark.

  • How to find out number of background work processe available in the system?

    Hi All,
    I have a FM that triggers a background job using JOB_OPEN, ABAP_SUBMIT and JOB_CLOSE. But the problem is if there are no background work processes available at that moment, it does not return error. Not sure whether the job is even scheduled!
    Is there a way to find out if there are any background work processes available in the system? I know a FM SPBT_INITIALIZE which gives info about dialog work processes. Is there any other FM similar to this which gives info about background wp??
    Regards,
    Shailesh

    your Job will remain in a queue by message handler. once workprocess is free, your job gets scheduled
    by the way, you can use the functionality used in FM TH_DISPLAY_WORKPROCESS_LIST to read the workprocesses
    the command which gets you the workprocess is:
    CALL 'ThWpInfo' ID 'OPCODE' FIELD OPCODE_WP_LIST
                      ID 'TAB' FIELD LIST_STATE_WPLST-TABL
                      ID 'CPU' FIELD LIST_STATE_WPLST-CPU.
    check how its written in include LSDEBF01, form SET_LIST_WPLST
    Edited by: Soumyaprakash Mishra on Dec 12, 2011 12:17 PM

  • Find Exact number of days between two dates

    How can get the exact number of days between two dates?

    An example of business days calculation in SQL */
    /* The algorythm is: */
    /* 1) Take the absolute difference between the dates */
    /* to_date('&todate') - to_date('&frdate') */
    /* 2) Subtract the weekends (number of weeks in the range */
    /* TRUNC(to_date('&todate'),'D') = 1st day of week that */
    /* end of period is in */
    /* TRUNC(to_date('&frdate'),'D') = Last day of week that */
    /* start of period is in */
    /* So subtracting these two gives the number of days */
    /* between the two dates but including all of the days in */
    /* the weeks that the dates start and end in. When this */
    /* number is divided by 7 it gives the number of weeks. */
    /* Multiplying by 2 gives the number of weekend days.     */
    /* 3) Subtract 1 day if the ending date is on a saturday */
    /* DECODE(to_char(to_date('&todate'),'D'),7,-1,0) */
    /* --> If the day of the week is saturday (7), returns -1 */
    /* 4) Subtract 1 day if the start date is on a sunday */
    /* DECODE(to_char(to_date('&frdate'),'D'),1,-1) */
    /* --> If the day of the week is sunday (1), returns 1 */
    /* 5) Add one day to make the range inclusive (The '1 + ' ) */
    /* Author: Kenneth Atkins ([email protected]) */
    /* http://www.olywa.net/katkins/oratip */
    define frdate = '&1'
    define todate = '&2'
    set verify off
    select      
         '&frdate' From_Date
         ,'&todate' To_Date,
         1 + to_date('&todate') - to_date('&frdate') -
         ((TRUNC(to_date('&todate'),'D') - TRUNC(to_date('&frdate'),'D'))/7)*2
         + DECODE(to_char(to_date('&todate'),'D'),7,-1,0)
    + DECODE(to_char(to_date('&frdate'),'D'),1,-1,0) Business_Days
    from dual
    Here is an example of running the script:
    SQL> @busdays 01-AUG-96 15-AUG-96
    FROM_DATE TO_DATE BUSINESS_DAYS
    01-AUG-96 15-AUG-96 11

  • How to find out number of connections to database?

    Hi,
    How can I find number of connections connected to the database 4 hours ago. For examply, if current time is 5PM and I want to see total number of connections connected to database (and from what user?) in between 1 and 2 PM, is there a way to find that out?
    I see v$session has a column MACHINE from which I can use count function to check the # of concurrent connections but I am not sure how to check the # of connections that happend few hours ago. Any suggestions?
    --MM                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           

    you should have audit on .. and create logon trigger and make entry in the tabe ..that would give you .
    --Girish                                                                                                                                                                                                                                       

  • How to find out number of  years worked using sql

    Hello,
    How to find from a table which has hiredate and should return number of years worked with range like 0-5, 5-10,10-15 etc.
    Any help is highly appreciated.
    Thanks

    I think this query can solve your issue
    SELECT CASE yeared,COUNT(CASE) FROM
    SELECT
    CASE
    WHEN MONTHS_BETWEEN(SYSDATE,hiredate)/12 <=5 THEN '0-5'
    WHEN MONTHS_BETWEEN(SYSDATE,hiredate)/12 > 5 AND MONTHS_BETWEEN(SYSDATE,hiredate)/12 <=10 THEN '5-10'
    WHEN MONTHS_BETWEEN(SYSDATE,hiredate)/12 > 10 AND MONTHS_BETWEEN(SYSDATE,hiredate)/12 <=15 THEN '10-15'
    WHEN MONTHS_BETWEEN(SYSDATE,hiredate)/12 > 15 AND MONTHS_BETWEEN(SYSDATE,hiredate)/12 <=20 THEN '15-20'
    WHEN MONTHS_BETWEEN(SYSDATE,hiredate)/12 > 20 AND MONTHS_BETWEEN(SYSDATE,hiredate)/12 <=25 THEN '20-25'
    WHEN MONTHS_BETWEEN(SYSDATE,hiredate)/12 > 25 AND MONTHS_BETWEEN(SYSDATE,hiredate)/12 <=30 THEN '25-30'
    ELSE '>=30'
    END CASE
    FROM scott.emp )
    GROUP BY CASE
    Regards.

  • How to find out number of users in an organization?

    Can you show me how I can find the total number of users in an organization please? Paging through is not an optimal way since there are alot of users.

    DamonL wrote:
    (be careful if you have a lot though!)That's an understatement. :) If you have a LOT of users in your organization doing a search on the organization just to find the user count will bog down the IDM server for several minutes.

  • Wish to find out number of rows returned from query

    hi,
    is it possible to determine how many rows have been returned after a query has been executed?
    thank you.

    It doesn't seem like there is a method to do it for you, [...]There can't be such a method that's guaranteed to work for all databases. Many databases just hand you a cursor with the query results, and you have to walk the cursor to find the complete set. It's even possible for the DB to continue computing the query in the background and just give you a cursor to walk and consume what it has already generated.
    So no, you have to walk the result set (effectively pulling everything over to the client) to count the number of rows..

Maybe you are looking for

  • How do I deleted a movie from an iDVD project

    I created an iDVD project using a movie, and have decided to go back into iMovie and make changes to the movie I am using for this project. Since I have put so much time into putting photos and music in submenus, I want to use the same project I crea

  • 96k Space Designer impulses ?

    Since all the factory presets for Space Designer default to "sample rate/2" in a 96k project, I'm assuming the factory impulses are all at 44.1k ? Any chance there are higher sampling rate versions of these factory impulses hidden somewhere ? Guessin

  • Form does not work

    Hi I use Adobe Livecycle Designer7.0 English and Acrobat7.0.8 Japanese. I made forms to upload to Workflow Server. One form I made does not work at all when the form is opened in the Form Manager. It is strange that the PDF preview of the Designer wo

  • Expand Tree Control

    I now have a Tree Control populated from an ArrayCollection and using the defaultDataDescriptor. At this point in the program the data exists only in the myTree.dataProvider and the root node is at myTree.dataProvider[0] or myTree.dataProvider.source

  • ... Forms Tlist error.. problem... help out plz ..

    Hi. i m facing a prblem with my Tlist. The problem is that i want to retrieve some record with dynmic record group. There are few neighbours against each site which are populated in the list. here is the code behind the mouse click trigger of the tex