'Soft' pointer in swing

Hi,
I wish to create a 'soft' pointer in swing, i.e. a second 'mouse' pointer that is controlled by a different device. I have all the control software working and a simple swing application that draws lines in response to gestures, but I can't find anything about creating new pointer as all the searches I run seem to result in tips on changing the mouse pointer size or image. Just to be clear: this is in addition to the mouse pointer, I don't want to control the mouse pointer itself with my device.
TIA,
Paul

I don't believe so... or if it is, they have a special relationship tieing them together.
why?

Similar Messages

  • Multitouch--does point overlap Swing Element?

    Hello,
    I am working on creating a multi-touch framework for java. I have all the camera/blob detection/blob tracking code written and functioning well. You have all been very helpful getting me this far! However, now I need to write some code that will make coordinates of tracked blobs interface with an api meant for single input points from a mouse: Swing.
    My question is this: What is the best way to determine if a point (x, y) is within a swing element? Ultimately, I would like to be able to create an actionlistener class that can be applied to, for example, a JLabel. So, when a point representing a blob overlaps with a swing element, the actionperformed() fires.
    What is the best way to go about this? Am I going in the right direction, or is there a simpler or better non-swing way to do this?
    I appreciate all your input!
    Cheers,
    James

    camickr wrote:
    My question is this: What is the best way to determine if a point (x, y) is within a swing element?Use the contains(...) method.Okay, thanks! So from what I've been able to find, the code would be as follows:
    SwingElement.contains(Point p);From what I read, it seems that Point p has to have coordinates relative to the position of the swing element. How would you recommend I get around this? Also, does this method work by comparing the minimum and maximum coordinates of the swing element to the coordinates of the point? If so, it probably wouldn't function correctly if, for example, it was used with a rotated ImageIcon. Other suggestions/ideas?
    Thanks

  • Am I missing a basic  point in Swing Gui

    Hi,
    Why does the text('Hello') not display. ??? The JFrame is empty with no component(JTextField). Here's my code:-
    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.*;
    public class DspTxt extends JPanel {
         String txt="Hello" ;
         JTextField jtxt;     
    // Constr
         DspTxt(){
         jtxt= new JTextField(txt);
         JPanel panel= new JPanel(new BorderLayout());
         panel.add(jtxt);
         public static void main(String[] args) {
         JFrame mainframe = new JFrame();
              mainframe.addWindowListener(new WindowAdapter() {
    public void windowClosing(WindowEvent e) {System.exit(0);}
              DspTxt f= new DspTxt();
              mainframe.getContentPane().add(f);
              mainframe.pack();
              mainframe.setVisible(true);
    Thanks in advance
    Gurmej

    You created a jpanel in your constructor and added the jtextfield to it but you didn't add the jpanel to dsptxt. Dsptxt is a jpanel so you don't need to create a new one.
    Run it like this :
    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.*;
    public class DspTxt extends JPanel {
         String txt="Hello" ;
         JTextField jtxt;
         // Constr
         DspTxt(){
              jtxt= new JTextField(txt);
              add(jtxt);
         public static void main(String[] args) {
              JFrame mainframe = new JFrame();
              mainframe.addWindowListener(new WindowAdapter() {
                   public void windowClosing(WindowEvent e) {System.exit(0);}
              DspTxt f= new DspTxt();
              mainframe.getContentPane().add(f);
              mainframe.pack();
              mainframe.setVisible(true);
    }

  • Swing Layout for different screen resolution

    Hi All,
    I am developing an application which will always run in a FULL SCREEN mode.
    I intend to make it working on all screen sizes (resoultions) and on different OS and devices.
    Since I am new to Swing, could anyone of you suggest a good layout manager to manage the components?
    I am using NetBeans 6.8 (which uses a GroupLayout) for designing the GUI but when I change the screen resolution, the arrangement is all messed up.
    Also, I am not able to design my application's GUI using NetBeans GUI builder as there is noway I can get an idea of how things will look like in the EXTENDED_BOTH state.
    It will be very helpful if anyone could suggest..
    Thanks!

    The entire point of Swing LayoutManagers is to get a (reasonably) consistent layout across different resolutions, window sizes, platforms, etc. Of course, different window sizes and aspect ratios will affect things slightly, but any LayoutManager properly used will do the job you're describing.
    As for which LayoutManager to use, I think that's a misleading question because it's not uncommon to use multiple LayoutManagers for a single screen. But in my experience it's possible to do 95% of what you want using GridBagLayout and a properly nested hierarchy of JPanels. GridBagLayout is a pain to get used to (caution against re-using GridBagConstraints), but once you do it's amazing what you can get out of it.

  • Null pointer at DefaultListCellRenderer

    Has anyone else seen this problem? It doesn't happen consistently but it is quite puzzling. When the user double clicks a JButton to display a plugin, a null pointer at swing.DefaultListCellRenderer.getListCellRendererComponent is occasionally thrown. Here is the stack trace. Any insight would be greatly appreciated.
    java.lang.NullPointerException
         at javax.swing.DefaultListCellRenderer.getListCellRendererComponent(DefaultListCellRenderer.java:80)
         at javax.swing.plaf.basic.BasicComboBoxUI.getDisplaySize(BasicComboBoxUI.java:1288)
         at javax.swing.plaf.basic.BasicComboBoxUI.getMinimumSize(BasicComboBoxUI.java:973)
         at javax.swing.plaf.basic.BasicComboBoxUI.getPreferredSize(BasicComboBoxUI.java:963)
         at javax.swing.JComponent.getPreferredSize(JComponent.java:1262)
         at java.awt.GridBagLayout.GetLayoutInfo(GridBagLayout.java:877)
         at java.awt.GridBagLayout.getLayoutInfo(GridBagLayout.java:791)
         at java.awt.GridBagLayout.preferredLayoutSize(GridBagLayout.java:627)
         at java.awt.Container.preferredSize(Container.java:989)
         at java.awt.Container.getPreferredSize(Container.java:973)
         at javax.swing.JComponent.getPreferredSize(JComponent.java:1264)
         at java.awt.BorderLayout.preferredLayoutSize(BorderLayout.java:569)
         at java.awt.Container.preferredSize(Container.java:989)
         at java.awt.Container.getPreferredSize(Container.java:973)
         at javax.swing.JComponent.getPreferredSize(JComponent.java:1264)
         at java.awt.BorderLayout.layoutContainer(BorderLayout.java:678)
         at java.awt.Container.layout(Container.java:835)
         at java.awt.Container.doLayout(Container.java:825)
         at java.awt.Container.validateTree(Container.java:903)
         at java.awt.Container.validateTree(Container.java:910)
         at java.awt.Container.validateTree(Container.java:910)
         at java.awt.Container.validateTree(Container.java:910)
         at java.awt.Container.validateTree(Container.java:910)
         at java.awt.Container.validateTree(Container.java:910)
         at java.awt.Container.validate(Container.java:878)
         at javax.swing.JInternalFrame.reshape(JInternalFrame.java:1449)
         at java.awt.Component.setBounds(Component.java:1644)

    your triangle and square variables are not initialized.
    i think what you need is change the following lines or initialize the above two before you use them.
    Polygon triangle = new Polygon(xPoints, yPoints, 3);                       //Triangle
    Rectangle2D.Double square = new Rectangle2D.Double(370, 384, 20, 20);      //Squareto
    triangle = new Polygon(xPoints, yPoints, 3);                       //Triangle
    square = new Rectangle2D.Double(370, 384, 20, 20);      //Square

  • Hand held camera effect

    hi,
    I think i've worked this out but i wondered if there were any other tips.
    I want to create a hand held camera effect in differing amounts from a very subtle one that looks real and would work well on say a talking head that has been shot on a locked off camera. to a more extreme version that could be used for a more edgy effect and when you don't mind nauseating your audience.
    i've got it looking ok by changing the footage to 3d and using a camera. then using wiggle on point of interest with a few manually typed in z rot changes.
    has anyone got any tips for this kind of effect. even mentioning what magnitude and frequency you use would be useful. as well as the kf animation types to get a natural feel
    cheers

    For the keyframes: Short intervals and linear. Even the best hobby filmer will not be able to hold the camera perfectly still for more than a few seconds and when your hand goes into a "fall", reaction is mostly abrupt and aimed at retaining the original centering. For the wiggle, you usually have two types interacting: A general, soft and slow swing for your entire arm, where the elbow or shoulder are the pivot, and then a more rapid jitter from your wrist and hand, further influenced by your pulse... At an average pulse of 85 bpm, this would be about 1.3 Hz. Your wrist can move vertically (hand aligned with body's vertical axis) about +/- 30 degrees, horizontally about +/- 80. Depending on how far the object is away, this can translate to just a few centimeters or meters based on how much jitters you have. You should however consider, that far shots are more stable due to how it better serves stereoscopic perception. And of course just like any other camera, wind and tremors e.g. from passing cars would also add an ever so slight variation... Generally there is no recipe, though. I would not overdo, as exactly this may look fake. As so often: subtlety is key.
    Mylenium

  • Hourglass-Bug

    I have developed a Java-Application (JDBC-Tool) and noticed several bugs in the Swing components:
    1. I have a JDialog in a JFrame. Now setting an hourglass-mousecursor in the dialog only works as long as the user does not move the cursor outside the dialog. If he does, the cursor gets to normal state again and even stays normal if I move it back into the dialog. There have been several tips here in the forum (glasspanes and so on), but none of them works for this case (Dialog in Frame). I consider this a bug in the Swing-components and hope it will be fixed soon. The behaviour is the same for 1.3 to 1.4.1
    2. I derived AbstractTableModel, and have the effect that getValueAt(row,col) gets sometimes called with negative column-values (-2) !? I have implemented a sorting feature for the columns when pressing at the column header. If one does quick sorts after another, this problem may occur. I'm not sure if this is my bug or Sun's bug ;-) Any ideas, is this a known fact ?
    3. For the same scenario, I noticed that model.getValueAt is called very often even when I move only the mouse over the table. Well, he has to repaint the elements which were under the mouse before, ok. But I noticed that for 1.3.0, there were many more calls than for 1.4. Seems like this has been optimized...
    Apart from these points, the Swing-Components make a good impression to me, I like working with them.
    Regards,
    Christian Sy Software-Development
    http://www.csy-software.de
    [email protected]

    1. I have a JDialog in a JFrame. Now setting an
    hourglass-mousecursor in the dialog only works as long
    as the user does not move the cursor outside the
    dialog. If he does, the cursor gets to normal state
    again and even stays normal if I move it back into the
    dialog. There have been several tips here in the forum
    (glasspanes and so on), but none of them works for
    this case (Dialog in Frame). I consider this a bug in
    the Swing-components and hope it will be fixed soon.
    The behaviour is the same for 1.3 to 1.4.1The solution to this problem, is to execute the actual code and the setting of the hourglass in a separate thread. I don't recall the exact reason for that, but it sure worked for me. I found it somewhere in this forum....
    2. I derived AbstractTableModel, and have the effect
    that getValueAt(row,col) gets sometimes called with
    negative column-values (-2) !? I have implemented a
    sorting feature for the columns when pressing at the
    column header. If one does quick sorts after another,
    this problem may occur. I'm not sure if this is my bug
    or Sun's bug ;-) Any ideas, is this a known fact ?This could be related to clicks which do not exactly hit the right column and getColumnIndexAtX() returns an invalid column. You should check your code which starts the sorting not to sort if the column is < 0
    This isn't by chance the code where you set the hourglass as well. If yes this should definitely be done in a separate thread.
    3. For the same scenario, I noticed that
    model.getValueAt is called very often even when I move
    only the mouse over the table. Well, he has to repaint
    the elements which were under the mouse before, ok.
    But I noticed that for 1.3.0, there were many more
    calls than for 1.4. Seems like this has been
    optimized...That's true. getValueAt() is constantly beeing called. Paying attention to memory allocation and performance there will speed up things.
    Regards
    Thomas

  • RTF Editing

    I have added an RTf editor to an applet and it works fine but I have 2 questions,
    1. Is there anyways I can get some kind of toolbar to display above it to do editing inside it.
    2. when I copy and paste things into it they appear correctly except when I try to copy and paste a table it, won't work is there a way I can get it to work?
    thank you

    You can create your own Toolbar class. Basically, just extend a Panel object and set it's layout to FlowLayout. Then you can add images to the toolbar. Add a MouseListener to the Toolbar panel (well that is have it implement MouseListener). Attach the listener to the images (which are AWT Components).
    You could have two images per "icon", one would be the off position, the other would be the on position.
    I'm sure Swing has a better way, and I'll bet a more visual-design-time based API.
    I hate Swing. Long live AWT! Although each has good and bad points. Swing is better for people who do not hard code things (i.e. don't really know java) - these would be the visual-design timers such as the Forte studio, JBuilder, etc. I am a hard (or hand) coder. I spend hours and hours typing long lines of detailed and intricate code. However, my apps run better and I can debug them faster - because I know what is happening, what it is called, and where it is and what it should be doing at any given point.

  • PIM Sync: where to change the pod

    Hi,
    I've installed PIM Sync for outlook, i have 2 pods, but the soft points to one pod, where do i change it to connect to the other pod?
    thanks

    Marcelo, if you go into the registry you can edit this settign and change your POD.
    cheers
    Alex

  • How to store grid points in a file using Java Swing?

    Please someone help me with any suggestions about how to store the grid points in a file using Java Swing

    Actually i have designed a gridlayout in Java Swing and have added some components to it such as buttons or images....My problem is when I click on any of the cell of the grid,the corresponding cell number should be stored in an external file....Do u have any suggestions on how to do it?

  • Entry points for integrating Openoffice writer into Java swing application

    I googled the web and also took a look in below 2 web sites, just seems it is very difficult to get an entry point for me to try my frist application with open office writer integrated with my swing application.
    http://wiki.services.openoffice.org/wiki/Documentation/DevGuide/OpenOffice.org_Developers_Guide
    http://api.openoffice.org/
    What my question is:
    1. Where can I get the completed jar files for using the open office writer api for my java application?
    2. Is there any step by step practical example for using the api? It seems that the above links are quite messy and difficult to find an entry point to get a start, but just contain many segments separated through out the web site.
    Thanks much for any suggestion.

    Information regarding OOo is not on Sun websites, or in these forums. There may be 3rd-party sites that have some info regarding OOo use.

  • Do I need to make an applet with swing point to the JRE 1.4 plug-in?

    Do I need to make an applet with swing point to the JRE 1.4 plug-in? I mean, in 1.3.1 plug-in, if you did not run your code through the HTML converter, the applet would still use the browsers JRE (JVM). However, with 1.4.0, it seems that you don't need to. Is this correct?

    When you ran an applet that has been compiled under 1.4 and needs classes or methods from 1.4 with an old HTML file (presumedly with the <object> tag that still refers to JRE 1.3+), the browser is going to look at the <object> tag and see that at least JRE1.3.1 is needed to correctly run the applet and since 1.4, which is higher than 1.3+, is on the system, it ignorantly proceeds to load and run the applet. The problem that you're going to run into is when you deploy the applet on the web and your viewer only have JRE1.3+, your applet which really needs 1.4, will crap out....
    ;o)
    V.V.

  • Hotel Menu Like Swing Component

    Hi , I need a swing component which has the functionality as below
    Initially, its looks like this
    # Beverages
    # Starters
    # MainCourse
    # Deserts
    When the user clicks on > it should expand that menu item and show the individual items along with their icons.
    # Beverages
           icon1 Tea
           icon2 Ice Tea
           icon3 Soft drink
    # Starters
    # MainCourse
    # Deserts
    Is there any readily available swing component which I can use for this behavior ?
    It is ok even the swing component misses out expand functionality when the "#" is clicked.

    But how can I set the icons to what I need ? Read the tutorial!!!
    There is no way you could have read the tutorial and understand how a JTree works in 10 minutes.
    So do some work on you own. Read the tutorial. Search the forum for examples.
    We've pointed you in the right direction so do some learning on your own.

  • How to find a point lies inside circle

    Hi,
    How do I find a point (x,y) is lies inside a circle? I trying to do a small shooting game.
    If the user clicks inside the circle they get a point. I am using the Pythagoras theorem to achieve this. But I can't.
    Please advice me.
    Here is my code
    import javax.swing.*;
    import java.awt.*;
    import java.awt.event.*;
    public class Shoot extends JFrame implements MouseListener, MouseMotionListener
        private int winWidth = 300;
        private int winHeight = 300;
        private MyCanvas canvas = null;
        private int ballX = 50;
        private int ballY = 50;
        private int ballW = 50;
        private int ballH = 50;
        private int ballR = ballW / 2;
        private int curX = 0;
        private int curY = 0;
        private int left = 0;
        private int top = 0;
        public Shoot()
            Cursor c = new Cursor(Cursor.CROSSHAIR_CURSOR);
            this.setCursor(c);
            canvas = new MyCanvas();
            packIt();
            left = getInsets().left;
            top = getInsets().top;
        private void packIt()
            setTitle("My first game!");
            setPreferredSize(new Dimension(winWidth, winHeight));
            setSize(new Dimension(winWidth, winHeight));
            setContentPane(canvas);
            addMouseListener(this);
            addMouseMotionListener(this);
            setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
            //setUndecorated(true);
            setLocation(300, 0);
            setVisible(true);
        public void mouseClicked(MouseEvent e)
            int x = e.getX() - left - ballX;
            int y = e.getY() - top - ballY;
            int r = ballR;
            System.out.println("x :" + x + "\ty :" + y);
            //Trying to implememt Pythagoras theorem. But I am missing something.
            System.out.println(((x * x) + (y * y)) + "\t=\t" + (r * r));
            System.out.println();
        public void mousePressed(MouseEvent e)
        public void mouseReleased(MouseEvent e)
        public void mouseEntered(MouseEvent e)
        public void mouseExited(MouseEvent e)
        public void mouseDragged(MouseEvent e)
        public void mouseMoved(MouseEvent e)
            curX = e.getX() - left;
            curY = e.getY() - top;
            canvas.repaint();
        private class MyCanvas extends JPanel
            public MyCanvas()
                setBackground(Color.BLACK);
                setBorder(BorderFactory.createLineBorder(Color.yellow));
            public void paintComponent(Graphics g)
                super.paintComponent(g);
                g.setColor(Color.WHITE);
                g.drawString("x :" + curX, 10, 20);
                g.drawString("y :" + curY, 10, 30);
                g.setColor(Color.RED);
                g.fillOval(ballX, ballY, ballW, ballH);
        public static void main(String[] asd)
            new Shoot();
    }

    public boolean isPointInCircle(){
        double x= circle.getWidth/2.0+circle.getX();
        double y= circle.getHeight/2.0+circle.getY();
        double distance=getDistance(x,y,pointX,PointY);
        return (distance<= circle.getWidth/2.0); //if the distance from the point to the center of the circle is less than the radius of the circle return true
    double getDistance(double x1, double y1, double x2, double y2){
        return math.sqrt((x1-x2)(x1-x2) + (y1-y2)(y1-y2));
    }Edited by: ghostbust555 on Jan 23, 2011 3:20 PM

  • Can I build a GUI application with SWING only without [import java.awt.*;]

    I have seen several threads (in forums), books and tutorials about SWING and I see that they all mix SWING with AWT (I mean they import both Swing and AWT in their code).
    The conclusion that comes out is:
    It is good to learn about SWING and forget AWT as it won't be supported later. I have decided to do so, and I never include <<import java.awt.*;>> in my code.
    But I see that you cannot do much without <<import java.awt.*;>>. For example this line which changes the background color:
    <<frame.getContentPane().setBackground(Color.red)>>
    works only with <<import java.awt.*;>>. I have seen that codes in this and other forums import awt to change the background. Why is that?
    After all, I wonder, what can I do;
    My question is, can I change the background (and of course do all other things listener, buttons etc) without using <<import java.awt.*;>>.
    I would like to avoid using <<import java.awt.*;>> and using awt since my program will not work later.
    In addition, I believe there is no point to learn awt, which later will not exist.
    I know, I must have misunderstood something. I would appreceate it very much, if anyone could give me even a short answer.
    Thank you in advance,
    JMelsi

    Since swing is a layer on top of awt, AWT will exist for as long as swing does.
    If sun does ever remove AWT they will have to replace it something else swing can layer on to and you will probably only have to replace your import statements.
    The main difference is the way there drawn to the screen.
    You can do custom drawing on swing components but you can't on AWT.
    If your using a desktop PC system it's probably best to use swing just in case you wish to do some custom drawing.
    awt uses less memory than swing and is faster but swing can be extended. awt comes only as standard.
    Say for example you wish to implement a JButton with a ProgressBar below the button text, this can be done with swing!

Maybe you are looking for

  • Error message when opening iTunes

    I just updated my macbook for the first time since early July, now iTunes throws an error everytime I try to open it or plug my iPhone in.  I have tried reinstalling iTunes 10.4.  After reading a variety of posts I have also tried uninstalling quickt

  • 12511 Unexpectedly received TLS alert message; treating as a rejection by the client

    ISE Version: 1.2.0.899 (Running in VMware) WLC: 5508 ver 7.6.100.0 I have a WLAN created that uses dot1x authentication. The WLAN points to ISE for RADIUS AAA. I cannot get any windows computer to connect to it (7,8 or 8.1 tested), but android, ios a

  • Internet Explorer Problem with Spry Menu Bar

    http://www.cloud9industries.com/clients/jewelryworld/index4.html OK here we go #1) In IE, the toolbar doesn't appear with the same decreased opacity as it does in Firefox and Safari. I'm using a png background image with a transparent background and

  • Make activity available only as follow-up

    Hello, is there a possibility in CRM 2007 to deactivate an activity to be created from the activities work center so that it is only available as follow-up from e.g. an opportunity? Example: There would be an activity "ZXY Follow-up opportunity" and

  • Adobe hasn't allowed me to cancel my CC subscription in order to collect a 50% fee.

    Yes, I know: " if you have an annual membership then you will need to contact our support team directly at Contact Customer Care.  A one to one interaction is necessary to ensure that you are authorized to cancel your annual membership." I've tried t