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:
override
paint(graphics g)
method. have first paint instance ofbufferedimage
, use rotation matrix rotate image before drawing on underlying panel.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
Post a Comment