说我使用不合法的API?关于canvas 哪个方法是不推荐使用的啊,最好别用它因为那个方法可能会在后续的jdk版本中去掉。 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 javac -deprecation ***.java就可以知道是哪个方法过时。jdk1.5用javac -Xlint **.java 呵呵,我想没把问题说清楚,用louisqiang(tenwin)提供的方法查了一下,结果就是鼠标进入画图区时,我把它变成十字光标,结果产生我发贴的这个问题,现在我还是想用这样的效果,类库中还有什么可以使用的? 没人知道不?setCursor(Cursor.CROSSHAIR_CURSOR);这句有错,应该用什么函数代替? /** * @(#)StopMe.java 2004-3-24 * * Copyright 2004 Opensource Develop Team. All rights reserved. */package com.opensource.internal;import javax.swing.*;import java.awt.*;public class CustomDesktop extends JFrame{ JDesktopPane desktopPane = new JDesktopPane(); public CustomDesktop() { JInternalFrame jif = new JInternalFrame( "Drag and ResizeMe", true, true, true, true); jif.setBounds(10, 10, 250, 100); jif.setVisible(true); desktopPane.add(jif); getContentPane().setLayout(new BorderLayout()); getContentPane().add(desktopPane, BorderLayout.CENTER); desktopPane.setDesktopManager(new OutlineManager()); desktopPane.revalidate(); setSize(500, 400); setVisible(true); } public static void main(String[] args) { new CustomDesktop(); }}class OutlineManager extends DefaultDesktopManager{ private Rectangle start, last; private boolean first = true; // dragging... public void beginDraggingFrame(JComponent frame) { initializeOutline(frame); } public void dragFrame(JComponent frame, int x, int y) { updateOutline(frame, x, y, start.width, start.height); } public void endDraggingFrame(JComponent frame) { endOutline(frame); } // resizing... public void beginResizingFrame(JComponent frame, int dir) { initializeOutline(frame); } public void resizeFrame(JComponent frame, int x, int y, int w, int h) { updateOutline(frame, x, y, w, h); } public void endResizingFrame(JComponent frame) { endOutline(frame); } // outline... private void initializeOutline(final JComponent frame) { frame.setVisible(false); start = frame.getBounds(); last = new Rectangle(start); first = true; SwingUtilities.invokeLater(new Runnable() { public void run() { updateOutline(frame, start.x, start.y, start.width, start.height); } }); } public void updateOutline(JComponent frame, int x, int y, int w, int h) { Container _container = frame.getParent(); Graphics g = _container.getGraphics(); try { g.setXORMode(_container.getBackground()); if (!first) { g.drawRect(last.x, last.y, last.width-1, last.height-1); } g.drawRect(x, y, w-1, h-1); first = false; } finally { g.dispose(); last.setBounds(x, y, w, h); } } public void endOutline(JComponent frame) { frame.setVisible(true); setBoundsForFrame( frame, last.x, last.y, last.width, last.height); }} JAVA程序运行一段时间之后,就变得很奇怪 诡异的Integer,大家帮忙看下 java获取程序运行时间 我写了这样一个监听 java 如何对TCP报文进行过滤 如何画一个上面2个角带圆弧的JButton? 请教 mysql jdbc select 中文问题? JBuilder6 或JBuilder7如何注册? Applet与Application用JDBC连数据库时用法上的区别 因本人要买奔腾4电脑,故甩卖原来的电脑,整机零件都可以,各位请报价格,合适就拿走! 请教:如何将int转换为16进制的byte? 模式对话框关闭后能得到返回值么?
就可以知道是哪个方法过时。
jdk1.5
用javac -Xlint **.java
setCursor(Cursor.CROSSHAIR_CURSOR);
这句有错,应该用什么函数代替?
* @(#)StopMe.java 2004-3-24
*
* Copyright 2004 Opensource Develop Team. All rights reserved.
*/
package com.opensource.internal;import javax.swing.*;
import java.awt.*;
public class CustomDesktop extends JFrame
{
JDesktopPane desktopPane = new JDesktopPane(); public CustomDesktop()
{
JInternalFrame jif = new JInternalFrame(
"Drag and ResizeMe",
true, true, true, true);
jif.setBounds(10, 10, 250, 100);
jif.setVisible(true);
desktopPane.add(jif);
getContentPane().setLayout(new BorderLayout());
getContentPane().add(desktopPane, BorderLayout.CENTER);
desktopPane.setDesktopManager(new OutlineManager());
desktopPane.revalidate();
setSize(500, 400);
setVisible(true);
} public static void main(String[] args)
{
new CustomDesktop();
}
}class OutlineManager extends DefaultDesktopManager
{
private Rectangle start, last;
private boolean first = true; // dragging...
public void beginDraggingFrame(JComponent frame)
{
initializeOutline(frame);
} public void dragFrame(JComponent frame, int x, int y)
{
updateOutline(frame, x, y, start.width, start.height);
} public void endDraggingFrame(JComponent frame)
{
endOutline(frame);
} // resizing...
public void beginResizingFrame(JComponent frame, int dir)
{
initializeOutline(frame);
} public void resizeFrame(JComponent frame, int x, int y, int w, int h)
{
updateOutline(frame, x, y, w, h);
} public void endResizingFrame(JComponent frame)
{
endOutline(frame);
} // outline...
private void initializeOutline(final JComponent frame)
{
frame.setVisible(false);
start = frame.getBounds();
last = new Rectangle(start);
first = true; SwingUtilities.invokeLater(new Runnable()
{
public void run()
{
updateOutline(frame, start.x, start.y, start.width, start.height);
}
});
} public void updateOutline(JComponent frame, int x, int y, int w, int h)
{
Container _container = frame.getParent();
Graphics g = _container.getGraphics(); try
{
g.setXORMode(_container.getBackground());
if (!first)
{
g.drawRect(last.x, last.y, last.width-1, last.height-1);
}
g.drawRect(x, y, w-1, h-1);
first = false;
}
finally
{
g.dispose();
last.setBounds(x, y, w, h);
}
} public void endOutline(JComponent frame)
{
frame.setVisible(true);
setBoundsForFrame(
frame, last.x, last.y, last.width, last.height);
}
}