Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

jerwin

Suspended
Original poster
Jun 13, 2015
2,895
4,652
For the past couple of years, I've been developing a Java Swing application-- basically a vector graphics program.

I've been working on it both before and after installing MacOSX Sierra, and I've noticed that some of the behavior is a bit strange. The code I use to detect a mouse press on a shape doesn't seem that reliable anymore. The handling of image compositing seems different. Maybe I've been coding against a buggy JVM and have been expecting certain behavior, but it's driving me nuts.
 
For the past couple of years, I've been developing a Java Swing application-- basically a vector graphics program.

I've been working on it both before and after installing MacOSX Sierra, and I've noticed that some of the behavior is a bit strange. The code I use to detect a mouse press on a shape doesn't seem that reliable anymore. The handling of image compositing seems different. Maybe I've been coding against a buggy JVM and have been expecting certain behavior, but it's driving me nuts.
Can you be more specific? Some remarks can hardly be related to Sierra, because it is a utility release, not a
system update (although, that's what I read).
;JOOP!
 
I upgraded one of my iMacs to Sierra: no problems with JAVA 8-102 w.r.t Swing.
Some other problems, but NOT JAVA-related.
;JOOP!
 
Hmm.

Let me see what I had to change.

Here's my original code:

The code is supposed to iterate through various shapes (all subclasses of class BasicPoint, which implements the Shape interface) that I've drawn on screen and add them to tree selection model, if the mouse is clicked on them.


Code:
public void mousePressed(MouseEvent e)
        {
           /* .... */
                Graphics2D g2=(Graphics2D) getGraphics();

                g2.setTransform(AffineTransform.getScaleInstance(scale, scale));
               Point2D p=e.getPoint();
                AffineTransform at=g2.getTransform();
                try
                {
                    at.inverseTransform(p, p);
                } catch (NoninvertibleTransformException e1)

                {
                
                    e1.printStackTrace();
                }
                int x=(int) Math.round(p.getX());
                int y=(int) Math.round(p.getY());
                Rectangle r=new Rectangle(x-1,y-1, 3,3);
                for(BasicPoint bp:pm)
                {  
if(g2.hit(r,bp,false))
  {      setSelectedPoint(bp);}
 }

To get it to work, I had to change the "if(g2.hit(r,bp,false))" condition to "if(bp.intersects(r))"
 
I'm using Swing and several of my programs use the same library classes and methods as yours,
and those work as before. In my opinion this has nothing to do with Sierra.
;JOOP!
 
I found thread management in osx is different than in windows and linux. If I put a thread in JavaFx scene like this thread.join(). Then that thread will not self terminate when close app, then app not terminate too
 
I found thread management in osx is different than in windows and linux. If I put a thread in JavaFx scene like this thread.join(). Then that thread will not self terminate when close app, then app not terminate too
You should report this to ORACLE (bug): thread management should be transparently the same.

Other observation: I switched from USB (wire) mouse to Magic Mouse 2 (accu, no batteries).
Since then JAVA has intermittent trouble with double clicks and clicks into components other than buttons.
;JOOP!
 
  • Like
Reactions: okieiam
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.