Java 我调用的是哪种静态方法?
这是我的密码:Java 我调用的是哪种静态方法?,java,static,non-static,Java,Static,Non Static,这是我的密码: package project; import java.awt.Graphics; import java.awt.event.KeyAdapter; import java.awt.event.KeyEvent; import javax.swing.JFrame; import javax.swing.JLabel; import javax.swing.JPanel; import project.Project.MyGraphics; public class
package project;
import java.awt.Graphics;
import java.awt.event.KeyAdapter;
import java.awt.event.KeyEvent;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;
import project.Project.MyGraphics;
public class Project extends JFrame implements Runnable{
String thing = "none";
public static int x;
public static int y;
int w = 1600;
int h = 1000;
public int ww = 5;
public int hh = 5;
public class AL extends KeyAdapter{
public void keyPressed(KeyEvent e) {
int KeyCode = e.getKeyCode();
if (KeyCode == e.VK_NUMPAD1){
downleft();
if (thing == "none" || thing == "d" || thing == "dr" || thing == "l" || thing == "r" ||
thing == "ul" || thing == "u" || thing == "ur") {
thing = "dl";
System.out.println("Drawing down to the left!");
}
if (x > 1595) {
x = 1595;
}
if (y > 974) {
y = 974;
}
if (x < 0) {
x = 0;
}
if (y < 0) {
y = 0;
}
}
if (KeyCode == e.VK_NUMPAD2){
down();
if (thing == "none" || thing == "dl" || thing == "dr" || thing == "l" || thing == "r" ||
thing == "ul" || thing == "u" || thing == "ur") {
thing = "d";
System.out.println("Drawing down!");
}
if (x > 1595) {
x = 1595;
}
if (y > 974) {
y = 974;
}
if (x < 0) {
x = 0;
}
if (y < 0) {
y = 0;
}
}
if (KeyCode == e.VK_NUMPAD3){
downright();
if (thing == "none" || thing == "dl" || thing == "d" || thing == "l" || thing == "r" ||
thing == "ul" || thing == "u" || thing == "ur") {
thing = "dr";
System.out.println("Drawing down to the right!");
}
if (x > 1595) {
x = 1595;
}
if (y > 974) {
y = 974;
}
if (x < 0) {
x = 0;
}
if (y < 0) {
y = 0;
}
}
if (KeyCode == e.VK_NUMPAD4){
left();
if (thing == "none" || thing == "dl" || thing == "d" || thing == "dr" || thing == "r" ||
thing == "ul" || thing == "u" || thing == "ur") {
thing = "l";
System.out.println("Drawing to the left");
}
if (x > 1595) {
x = 1595;
}
if (y > 974) {
y = 974;
}
if (x < 0) {
x = 0;
}
if (y < 0) {
y = 0;
}
}
if (KeyCode == e.VK_NUMPAD6){
right();
if (thing == "none" || thing == "dl" || thing == "d" || thing == "dr" || thing == "l" ||
thing == "ul" || thing == "u" || thing == "ur") {
thing = "r";
System.out.println("Drawing to the right!");
}
if (x > 1595) {
x = 1595;
}
if (y > 974) {
y = 974;
}
if (x < 0) {
x = 0;
}
if (y < 0) {
y = 0;
}
}
if (KeyCode == e.VK_NUMPAD7){
upleft();
if (thing == "none" || thing == "dl" || thing == "d" || thing == "dr" || thing == "l" ||
thing == "r" || thing == "u" || thing == "ur") {
thing = "ul";
System.out.println("Drawing up to the left!");
}
if (x > 1595) {
x = 1595;
}
if (y > 974) {
y = 974;
}
if (x < 0) {
x = 0;
}
if (y < 0) {
y = 0;
}
}
if (KeyCode == e.VK_NUMPAD8){
up();
if (thing == "none" || thing == "dl" || thing == "d" || thing == "dr" || thing == "l" ||
thing == "r" || thing == "ul" || thing == "ur") {
thing = "u";
System.out.println("Drawing up!");
}
if (x > 1595) {
x = 1595;
}
if (y > 974) {
y = 974;
}
if (x < 0) {
x = 0;
}
if (y < 0) {
y = 0;
}
}
if (KeyCode == e.VK_NUMPAD9){
upright();
if (thing == "none" || thing == "dl" || thing == "d" || thing == "dr" || thing == "l" ||
thing == "r" || thing == "ul" || thing == "u") {
thing = "ur";
System.out.println("Drawing up to the right!");
}
if (x > 1595) {
x = 1595;
}
if (y > 974) {
y = 974;
}
if (x < 0) {
x = 0;
}
if (y < 0) {
y = 0;
}
}
if (KeyCode == e.VK_B){
ww += 5;
hh += 5;
System.out.println("Resized! It is now " + ww + " by " + hh + "!");
if (ww > 150) {
ww = 150;
hh = 150;
System.out.println("The size went too high! Resized back to 150 by 150!");
}
}
if (KeyCode == e.VK_S){
ww -= 5;
hh -= 5;
System.out.println("Resized! It is now " + ww + " by " + hh + "!");
if (ww < 5) {
ww = 5;
hh = 5;
System.out.println("The size went too low! Resized back to 5 by 5!");
}
}
}
}
public void downleft(){
x-=5;
y+=5;
}
public void down(){
y+=5;
}
public void downright(){
x+=5;
y+=5;
}
public void left(){
x-=5;
}
public void right(){
x+=5;
}
public void upleft(){
x-=5;
y-=5;
}
public void up(){
y-=5;
}
public void upright(){
x+=5;
y-=5;
}
public Project(){
addKeyListener(new AL());
setTitle("Etch a Sketch");
setResizable(false);
setVisible(true);
setSize(w, h);
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
getContentPane().add(new MyGraphics());
JLabel label1 = new JLabel("Size: " + x + " by " + y, JLabel.CENTER);
label1.setAlignmentX(0);
label1.setAlignmentY(0);
Project.add(label1);
x = 100;
y = 100;
}
public static void main(String[] args) {
new Project();
}
class MyGraphics extends JPanel {
public void paintComponent(Graphics g) {
g.fillRect(x, y, ww, hh);
repaint();
}
}
@Override
public void run() {
}
}
成套工程;
导入java.awt.Graphics;
导入java.awt.event.KeyAdapter;
导入java.awt.event.KeyEvent;
导入javax.swing.JFrame;
导入javax.swing.JLabel;
导入javax.swing.JPanel;
导入project.project.MyGraphics;
公共类项目扩展JFrame实现可运行{
字符串thing=“无”;
公共静态int x;
公共静态智力;
int w=1600;
int h=1000;
公共int ww=5;
公共int hh=5;
公共类AL扩展了KeyAdapter{
按下公共无效键(按键事件e){
int KeyCode=e.getKeyCode();
if(KeyCode==e.VK_NUMPAD1){
左下();
如果(thing==“none”| thing==“d”| thing==“dr”| thing==“l”| thing==“r”||
东西==“ul”|东西==“u”|东西==“ur”){
thing=“dl”;
System.out.println(“向左绘制!”);
}
如果(x>1595){
x=1595;
}
如果(y>974){
y=974;
}
if(x<0){
x=0;
}
if(y<0){
y=0;
}
}
if(KeyCode==e.VK_NUMPAD2){
向下();
如果(thing==“none”| thing==“dl”| thing==“dr”| thing==“l”| thing==“r”||
东西==“ul”|东西==“u”|东西==“ur”){
thing=“d”;
System.out.println(“向下绘制!”);
}
如果(x>1595){
x=1595;
}
如果(y>974){
y=974;
}
if(x<0){
x=0;
}
if(y<0){
y=0;
}
}
if(KeyCode==e.VK_NUMPAD3){
彻头彻尾的();
如果(thing==“none”| thing==“dl”| thing==“d”| thing==“l”| thing==“r”||
东西==“ul”|东西==“u”|东西==“ur”){
thing=“dr”;
System.out.println(“向右绘制!”);
}
如果(x>1595){
x=1595;
}
如果(y>974){
y=974;
}
if(x<0){
x=0;
}
if(y<0){
y=0;
}
}
if(KeyCode==e.VK_numpa4){
左();
如果(thing==“none”| thing==“dl”| thing==“d”| thing==“dr”| thing==“r”||
东西==“ul”|东西==“u”|东西==“ur”){
thing=“l”;
System.out.println(“向左绘制”);
}
如果(x>1595){
x=1595;
}
如果(y>974){
y=974;
}
if(x<0){
x=0;
}
if(y<0){
y=0;
}
}
if(KeyCode==e.VK_NUMPAD6){
对();
如果(thing==“none”| thing==“dl”| thing==“d”| thing==“dr”| thing==“l”||
东西==“ul”|东西==“u”|东西==“ur”){
thing=“r”;
System.out.println(“向右绘制!”);
}
如果(x>1595){
x=1595;
}
如果(y>974){
y=974;
}
if(x<0){
x=0;
}
if(y<0){
y=0;
}
}
if(KeyCode==e.VK_NUMPAD7){
upleft();
如果(thing==“none”| thing==“dl”| thing==“d”| thing==“dr”| thing==“l”||
事物==“r”| |事物==“u”| |事物==“ur”){
thing=“ul”;
System.out.println(“向左绘制!”);
}
如果(x>1595){
x=1595;
}
如果(y>974){
y=974;
}
if(x<0){
x=0;
}
if(y<0){
y=0;
}
}
if(KeyCode==e.VK_NUMPAD8){
up();
如果(thing==“none”| thing==“dl”| thing==“d”| thing==“dr”| thing==“l”||
事物==“r”| |事物==“ul”| |事物==“ur”){
thing=“u”;
System.out.println(“绘图!”);
}
如果(x>1595){
x=1595;
}
如果(y>974){
y=974;
}
if(x<0){
x=0;
}
if(y<0){
y=0;
}
}
if(KeyCode==e.VK_NUMPAD9){
直立的();
如果(thing==“none”| thing==“dl”| thing==“d”| thing==“dr”| thing==“l”||
事物==“r”| |事物==“ul”| |事物==“u”){
thing=“ur”;
System.out.println(“向右绘制!”);
}
如果(x>1595){
x=1595;
}
如果(y>974){
y=974;
}
if(x<0){
x=0;
}
if(y<0){
y=0;
}
}
if(KeyCode==e.VK_B){
ww+=5;
hh+=5;
System.out.println(“已调整大小!现在由“+hh+”!”)调整为“+ww+”;
如果(ww>150){
ww=150;
hh=150;
System.out.println(“大小太大了!大小调整回150乘150!”);
}
}
if(KeyCode==e.VK_S){
ww-=5;
hh-=5;
System.out.println(“已调整大小!现在由“+hh+”!”)调整为“+ww+”;
如果(ww<5){
ww=5;
hh=5;
System.out.println(“