2
我必須將Zoom In and Zoom Out
功能添加到JPanel
,其中包含JLabel
和ImageIcon
等組件。Jpanel中的放大和縮小功能
我想要Zoom JPanel
及其組件適當 我試着用下面的代碼片段,但它沒有正常工作。
JPanel
它有null
佈局和本身放置在Applet
內。 我不確定爲什麼它不起作用,或者是因爲Applet
或別的什麼!
cPanel
是我JPanel
它包含了放大Button
點擊JLabel
下面的代碼片段, 它顯示了在上按一下按鈕閃爍屏幕,原來
Graphics g = cPanel.getGraphics();
Graphics2D g2d = (Graphics2D) g;
AffineTransform savedXForm = g2d.getTransform();
g2d.scale(1.0, 1.0);
g2d.setColor(Color.red);
super.paint(g);
g2d.setTransform(savedXForm);
cPanel.validate();
cPanel.repaint();
*「我想放大和放大」*我想要問題很容易閱讀。請停止「嘟'」在句子的開頭添加大寫字母。 – 2013-05-02 07:06:11
我會看看你的佈局問題,然後我會看看'JXLayer' – MadProgrammer 2013-05-02 07:11:35
請參閱*** [this](http://stackoverflow.com/questions/2944442/zoom-in-java-swing - 應用程序?rq = 1)***後 – 2013-05-02 07:15:04