Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.java.programmer > #35261

Re: Making a cross-hair visible

From Eric Sosman <esosman@comcast-dot-net.invalid>
Newsgroups comp.lang.java.programmer
Subject Re: Making a cross-hair visible
Date 2016-08-11 17:40 -0400
Organization A noiseless patient Spider
Message-ID <noirbo$u8j$1@dont-email.me> (permalink)
References <87a8gjm2it.fsf@Equus.decebal.nl>

Show all headers | View raw


On 8/11/2016 5:14 PM, Cecil Westerhof wrote:
> I am dabbling with Swing to do some GUI stuff. This is relatively new
> for me. At the moment I draw a rectangle for cropping an image. The
> position is selected by clicking on the centre from where I think the
> rectangle should be placed. This can be a little of, so I have to
> fine-tune it. For this I draw a little cross in the centre. Problem is
> that I paint it in black and when the centre is black, I will not see
> it. And with every colour I choose I can have this problem. Is there a
> smart way to make the cross always visible?

     The cleanest approach (you'll have to experiment to decide whether
it's also "best") might be to use the java.awt.Cursor class.  When
entering "center selection mode," query and save the current Cursor,
then change it to CROSSHAIR_CURSOR for the duration.  Restore the
original Cursor when finished.

     If you're bound and determined to do your own cursor-painting,
I suppose you could paint two crosses in contrasting colors, one
with thicker strokes beneath one that's thinner.  For example, you
might paint a white cross with 3-pixel strokes and then a one-pixel
black cross atop it.

     ... and there's probably something you could do with XOR, but
that might have weird interactions if you ever ran on a display with
a different ColorModel than you anticipated.  I'd go for Cursor.

-- 
esosman@comcast-dot-net.invalid
"Don't be afraid of work. Make work afraid of you." -- TLM

Back to comp.lang.java.programmer | Previous | Next — Previous in thread | Find similar | Unroll thread


Thread

Making a cross-hair visible Cecil Westerhof <Cecil@decebal.nl> - 2016-08-11 23:14 +0200
  Re: Making a cross-hair visible Arne Vajhøj <arne@vajhoej.dk> - 2016-08-11 17:34 -0400
  Re: Making a cross-hair visible Silvio <silvio@internet.com> - 2016-08-11 23:36 +0200
    Re: Making a cross-hair visible Cecil Westerhof <Cecil@decebal.nl> - 2016-08-12 00:20 +0200
  Re: Making a cross-hair visible Eric Sosman <esosman@comcast-dot-net.invalid> - 2016-08-11 17:40 -0400

csiph-web