Programming a GUI with resizable components using Java.swing

后端 未结 2 1684
囚心锁ツ
囚心锁ツ 2021-01-22 22:25

I\'m supposed to program a GUI. Every component in this GUI has to have the possibility to be resized dynamically.

So far I worked with GlassPane and ContentPane, added

相关标签:
2条回答
  • 2021-01-22 22:58

    You have to determine the component point from your coordinate. Use this instead of p2 to to create the event:

    Point p2 = SwingUtilities.convertPoint(this.getGlassPane(), p, component);
    
    0 讨论(0)
  • 2021-01-22 22:58

    You might be able to use the Component Resizer. It would need to be added to all components in advance.

    Or maybe you could add the listener when you select the component and then remove the listener when you deselect the component.

    The code you posted is of little help when guessing what your actual program is doing. When you have problems with your code you need to post a SSCCE.

    0 讨论(0)
提交回复
热议问题