猿问

扩展JPanel类的程序不访问方法plotComponent()

扩展JPanel类的程序不访问方法plotComponent()

这是JFrame

package client.connection;import java.awt.Dimension;import java.io.ObjectInputStream;import java.io.ObjectOutputStream;import javax.swing.JFrame;class DrawFrameRemoteControl extends JFrame{
    private DrawPanelRemoteControl imagePanel;
    private ClientRemoteControlConnection clientRemoteControlConnection;
    private ObjectInputStream clientInputStream;
    private ObjectOutputStream clientOutputStream;
    private Dimension imageDimension;
    private Dimension serverDimension;

    public DrawFrameRemoteControl(Dimension imageDimension,ClientRemoteControlConnection clientRemoteControlConnection,ObjectInputStream clientInputStream,ObjectOutputStream clientOutputStream,Dimension serverDimension)
    {
        super("Remote Desktop Control");

        this.clientRemoteControlConnection=clientRemoteControlConnection;
        this.clientInputStream=clientInputStream;
        this.clientOutputStream=clientOutputStream;
        this.imageDimension=imageDimension;
        this.serverDimension=serverDimension;

        imagePanel=new DrawPanelRemoteControl(imageDimension);
        add(imagePanel);


        setSize(imageDimension.width,imageDimension.height);
        setResizable(false);
        setDefaultCloseOperation(EXIT_ON_CLOSE);
        setVisible(true);
        setLocationRelativeTo(null);
    }

    void drawNewImageGrayscale(byte[] array)
    {
        imagePanel.setNewImageGrayscale(array);
        imagePanel.repaint();
    }}


我试过调试代码,尽管imagePanel.repaint()正在多次执行,程序永远不会到达paintComponent()方法DrawPanelRemoteControl班级,等级。

有人能告诉我为什么会发生这种事吗?是否与imageDimension反对?

补充资料:在……里面main()方法,aDrawFrameRemoteControl对象被创建,并且它的drawNewImageGrayscale(byte[] arr)方法正在从main()每一秒。


隔江千里
浏览 347回答 1
1回答
随时随地看视频慕课网APP

相关分类

Java
我要回答