Scaling of JTextField
From: Alex Molochnikov (NOBODY_at_NOSPAM.COM)
Date: 08/23/04
- Next message: ak: "Re: how to set focus to an AWT edit field?"
- Previous message: Robert Rozman: "Live floorplan implementation possibilities - any open source/free code?"
- Next in thread: ak: "Re: Scaling of JTextField"
- Reply: ak: "Re: Scaling of JTextField"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Sun, 22 Aug 2004 23:04:44 GMT
I am working on a zooming feature that should allow scaling the content of a
JFrame. Some of the frame's components are instances of JTextComponent, such
as JTextField. The zooming is done by scaling the Graphics2D object in
paint() method of a subclass of JPanel (ScalablePane class in the attached
test case).
Components that do not support text editing (like JLabel or JButton) come
out scaled (enlarged to 200% of the original size), as expected according to
the test case. However, JTextComponents show both the scaled and the
original (unscaled) image, such that a single JTextField is shown as the
"normal" field at the unscaled (x, y) location, and again as a double-sized
field at the location (x*2, y*2).
Worse yet, if I want to edit the content of JTextField, the editable area
that gets the focus, is still at the unscaled location. It looks like the
text editing machinery of Swing operates independently of the painting
mechanism (Graphics2D), and does not get scaled along with the rest of the
frame's content.
I searched the forums, tutorials etc., but found nothing of help.
Any clues will be highly appreciated.
TIA
Alex Molochnikov
Gestalt Corporation
begin 666 Controller.java
M:6UP;W)T(&IA=F$N87=T+BH[#0II;7!O<G0@:F%V87@N<W=I;F<N*CL-"FEM
M<&]R="!J879A+F%W="YG96]M+BH[#0H-"G!U8FQI8R!C;&%S<R!#;VYT<F]L
M;&5R#0I[#0H)<')I=F%T92!*1G)A;64@9G)A;64[#0H)<')I=F%T92!#;VYT
M86EN97(@8V]N=&5N=%!A;F4[#0H)<')I=F%T92!&;VYT('!L86EN1F]N=#L-
M"@T*"7!U8FQI8R!S=&%T:6,@=F]I9"!M86EN*%-T<FEN9UM=(&%R9W8I#0H)
M>PT*"0ET<GD@>R!524UA;F%G97(N<V5T3&]O:T%N9$9E96PH54E-86YA9V5R
M+F=E=%-Y<W1E;4QO;VM!;F1&965L0VQA<W-.86UE*"DI.R!]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*"D[#0H)"71E>'1&:65L9"YS971&;VYT*'!L86EN
M1F]N="D[#0H)"71E>'1&:65L9"YS971";W5N9',H-3 L(#4P+" Q,# L(#(Q
M*3L-"@D)8V]N=&5N=%!A;F4N861D*'1E>'1&:65L9"D[#0H)?0T*?0T*#0IC
M;&%S<R!38V%L86)L95!A;F4@97AT96YD<R!*4&%N96P-"GL-"@EP=6)L:6,@
M=F]I9"!P86EN="A'<F%P:&EC<R!G*0T*"7L-"@D)1W)A<&AI8W,R1"!G,F0@
M/2 H1W)A<&AI8W,R1"D@9SL-"@D)9&]U8FQE('IO;VU&86-T;W(@/2 R+C [
M#0H)"4%F9FEN951R86YS9F]R;2!O;&0@/2!G,F0N9V5T5')A;G-F;W)M*"D[
M#0H)"6<R9"YS8V%L92AZ;V]M1F%C=&]R+"!Z;V]M1F%C=&]R*3L-"@D)<W5P
M97(N<&%I;G0H9S)D*3L-"@D)9S)D+G-E=%1R86YS9F]R;2AO;&0I.PT*"7T-
""GT`
`
end
- Next message: ak: "Re: how to set focus to an AWT edit field?"
- Previous message: Robert Rozman: "Live floorplan implementation possibilities - any open source/free code?"
- Next in thread: ak: "Re: Scaling of JTextField"
- Reply: ak: "Re: Scaling of JTextField"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]