Scaleable Swing components

Discussion in 'Java' started by Jens Piegsa, Dec 16, 2006.

  1. Jens Piegsa

    Jens Piegsa Guest

    Hello!

    The following problem troubles me already for hours:

    I would like to use scaleable TextPanes in my graphical editor adapting
    the global scaling.
    MyTextPane inherites from JTextPane and overrides the paintComponent method.

    public void paintComponent(Graphics g) {
    Graphics2D g2d = (Graphics2D) g.create();
    AffineTransform at = new AffineTransform();
    g2d.setRenderingHint(RenderingHints.
    KEY_ANTIALIASING,
    RenderingHints.VALUE_ANTIALIAS_ON);
    at.scale(getTransform().getScaleX(),
    getTransform().getScaleY());
    g2d.transform(at);
    super.paintComponent(g2d);
    g2d.dispose();
    }

    I had to remove the scaling from the Display class. so far so good :-}
    The following behavior disturbs me a little:

    * the cursor doesn't flash
    * the cursor position isn't accurate any longer (e.g. iiiii | )
    * selected text is shown at a shifted position
    * the component is larger than the drawn area
    (noticeable with the background; a vertacally centered text field
    disappears completely)
    * size/position of text and node should be updated with panning and
    zooming or growing of the input

    who can make me lucky?

    Jens
     
    Jens Piegsa, Dec 16, 2006
    #1
    1. Advertisements

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Mickey Segal
    Replies:
    0
    Views:
    1,122
    Mickey Segal
    Feb 2, 2004
  2. mkrause
    Replies:
    0
    Views:
    851
    mkrause
    May 6, 2005
  3. Sascha Kerschhofer

    SVG scaleable?

    Sascha Kerschhofer, Jul 15, 2003, in forum: XML
    Replies:
    6
    Views:
    2,285
  4. jsqrd

    Scaleable naviagtion pane

    jsqrd, Mar 2, 2007, in forum: ASP .Net
    Replies:
    2
    Views:
    383
    jsqrd
    Mar 2, 2007
  5. metaperl
    Replies:
    4
    Views:
    484
    Chris Uppal
    Mar 3, 2007
  6. Chris Thomasson
    Replies:
    3
    Views:
    561
    Chris Thomasson
    Oct 22, 2007
  7. Robert P. J. Day

    python simply not scaleable enough for google?

    Robert P. J. Day, Nov 11, 2009, in forum: Python
    Replies:
    11
    Views:
    887
    Robin Becker
    Nov 23, 2009
  8. Terry Reedy
    Replies:
    85
    Views:
    1,746
    Aaron Watters
    Nov 21, 2009
Loading...