gpt4 book ai didi

java - 在类里面找不到符号

转载 作者:行者123 更新时间:2023-12-02 11:10:59 29 4
gpt4 key购买 nike

public class sagum2 {

private static int n1;
private static int[] apw1;

public static void main(String[] args) {
try{
Scanner console = new Scanner(System.in);
sagum2 s = new sagum2();
Graphics g= getGraphics();

char c,c1 = 0,c2=0,c3=0;
int apw1[];
int p[];
int n,n1,ch;

String input;
char ans1, ans, input1;
boolean retry = true;

BufferedReader obj=new
BufferedReader(new InputStreamReader (System.in));
System.out.println("ENTER no. of processes:");
n=Integer.parseInt(obj.readLine());

int bt[]=new int[n];
System.out.println("MENU FOR CPU SCHEDULING");
ch=Integer.parseInt(obj.readLine());
switch(ch) {

case 1:

.....

case 2:
....
case 3:
....

}
} catch (Exception e) {

}

}

private String[] p;
public void paint(Graphics g)
{
for(int j=1;j<=n1;j++)
{
g.drawRect(50,50,(apw1[j]*20),30);
g.drawString("p"+p[j-1],(55+(apw1[j-1]*20)),70);
g.drawString(""+apw1[j-1],50+(apw1[j-1]*20),100);
}
g.drawString(""+apw1[n1],50+(apw1[n1]*20),100);
}
}

我在有一个错误
 Graphics g= getGraphics(); 

说找不到符号“getGraphics”,我已经将其更改为
   private static Graphics getGraphics() { throw new UnsupportedOperationException("Not supported yet."); 
}

我叫它执行一个扩展的小程序来显示甘特图。
请帮我这个项目

最佳答案

你在哪画您的类(class)应该花费JPanel吗?您是否需要缓冲图像?

您需要在某处绘制:

尝试:

Graphics g = (new BufferedImage(100, 100, BufferedImage.TYPE_INT_ARGB)).getGraphics();

关于java - 在类里面找不到符号,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18856118/

29 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com