-1
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."); 
}

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

4

1 回答 1

0

你在哪里画画?你的班级应该使用 JPanel 吗?您需要缓冲图像吗?

你需要在某个地方画画:

尝试:

Graphics g = (new BufferedImage(100, 100, BufferedImage.TYPE_INT_ARGB)).getGraphics();
于 2013-09-17T18:13:57.517 回答