当前位置: 代码迷 >> Java相关 >> 象棋二(chessFrame.java)
  详细解决方案

象棋二(chessFrame.java)

热度:230   发布时间:2006-04-11 12:27:00.0
象棋二(chessFrame.java)

package chess;

import java.awt.Toolkit;
import javax.swing.SwingUtilities;
import javax.swing.UIManager;
import java.awt.Dimension;

public class chessApp {
boolean packFrame = false;

/**
* Construct and show the application.
*/
public chessApp() {
chessFrame frame = new chessFrame();
// Validate frames that have preset sizes
// Pack frames that have useful preferred size info, e.g. from their layout
if (packFrame) {
frame.pack();
} else {
frame.validate();
}

// Center the window
Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
Dimension frameSize = frame.getSize();
if (frameSize.height > screenSize.height) {
frameSize.height = screenSize.height;
}
if (frameSize.width > screenSize.width) {
frameSize.width = screenSize.width;
}
frame.setLocation((screenSize.width - frameSize.width) / 2,
(screenSize.height - frameSize.height) / 2);
frame.setVisible(true);
}

/**
* Application entry point.
*
* @param args String[]
*/
public static void main(String[] args) {
SwingUtilities.invokeLater(new Runnable() {
public void run() {
try {
UIManager.setLookAndFeel(UIManager.
getSystemLookAndFeelClassName());
} catch (Exception exception) {
exception.printStackTrace();
}

new chessApp();
}
});
}
}

搜索更多相关的解决方案: 象棋  java  chessFrame  import  awt  

----------------解决方案--------------------------------------------------------
你发错了,怎么发到J2ME来了
----------------解决方案--------------------------------------------------------
楼主的程序似乎有问题哟,我用JBuilder2006运行后抛出了几个异常:
java.lang.NullPointerException
at chess.chessFrame.drawChessMan(chessFrame.java:230)
at chess.chessFrame.<init>(chessFrame.java:58)
at chess.chessApp.<init>(chessApp.java:15)
at chess.chessApp$1.run(chessApp.java:53)
at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:209)
at java.awt.EventQueue.dispatchEvent(EventQueue.java:461)
at java.awt.EventDispatchThread.pumpOneEventForHierarchy(EventDispatchThread.java:242)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:163)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:157)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:149)
at java.awt.EventDispatchThread.run(EventDispatchThread.java:110)

----------------解决方案--------------------------------------------------------
呵呵,根本就不全,在别的机子上就运行不了。
----------------解决方案--------------------------------------------------------
  相关解决方案