java - Can you create a JPanel that is rotated? -


i wondering if there might way using java swing create rotated jpanel? i'd read other questions/answers on topic didn't understand if create 1 rotated or not. not need rotate once it's created, created tilted on x/y axis. thanks.

thanks, quite helpful!

you can't behavior default. however, extend jpanel , desired rotation behavior if little linear algebra:

  1. override paint(graphics g) method. have first paint instance of bufferedimage, use rotation matrix rotate image before drawing on underlying panel.

  2. override methods handle mouse input , apply reverse rotation coordinates passed in associated listeners. way, underlying layout manager still 'thinks' panel hasn't been rotated, you've rotated drawing , event notification things still "line up" properly.

i'll caveat of saying i've never done before, , run unexpected issues not outlined here, have 10 years of experience java swing , how i'd if had to.


Comments

Popular posts from this blog

html - Sizing a high-res image (~8MB) to display entirely in a small div (circular, diameter 100px) -

java - IntelliJ - No such instance method -

identifier - Is it possible for an html5 document to have two ids? -