Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/363.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/templates/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 如何在单击按钮时重新绘制jPanel_Java_Paint - Fatal编程技术网

Java 如何在单击按钮时重新绘制jPanel

Java 如何在单击按钮时重新绘制jPanel,java,paint,Java,Paint,我有这个类的类映射,我有这个方法 public void vykresliGraf(Graphics g){ Set set = graf.getUzly().entrySet(); g.setColor(Color.BLUE); Iterator it = set.iterator(); while(it.hasNext()){ Map.Entry entry = (Map.Entry) it.next(); Uzel u =

我有这个类的类映射,我有这个方法

public void vykresliGraf(Graphics g){

    Set set = graf.getUzly().entrySet();
    g.setColor(Color.BLUE);

    Iterator it = set.iterator();
    while(it.hasNext()){
        Map.Entry entry = (Map.Entry) it.next();
        Uzel u = (Uzel)entry.getValue();
        Obec o = (Obec)u.getValue();
        g.drawOval(o.getSouradnice().x - 3, o.getSouradnice().y - 3, 6, 6);
        g.fillOval(o.getSouradnice().x - 3, o.getSouradnice().y - 3, 6, 6);
    }
    it = set.iterator();
    List<Hrana> pomList = new ArrayList<>();
    while(it.hasNext()){
        Map.Entry entry = (Map.Entry) it.next();
        Uzel u = (Uzel)entry.getValue();
        for (int i = 0; i < u.getHranyUzlu().size(); i++) {
            Hrana h = (Hrana)u.getHranyUzlu().get(i);

            if(!pomList.contains(h)){

                pomList.add(h); 
                Obec o1 = (Obec)h.getZdroj().getValue();
                Obec o2 = (Obec)h.getCil().getValue();
                g.drawLine(o1.getSouradnice().x, o1.getSouradnice().y, o2.getSouradnice().x, o2.getSouradnice().y);
            }

        }
    }
}
public void vykresliGraf(图g){
Set=graf.getUzly().entrySet();
g、 setColor(Color.BLUE);
Iterator it=set.Iterator();
while(it.hasNext()){
Map.Entry=(Map.Entry)it.next();
Uzel u=(Uzel)entry.getValue();
Obec o=(Obec)u.getValue();
g、 drawOval(o.getSouradnice().x-3,o.getSouradnice().y-3,6,6);
g、 fillOval(o.getSouradnice().x-3,o.getSouradnice().y-3,6,6);
}
it=set.iterator();
List pomList=新的ArrayList();
while(it.hasNext()){
Map.Entry=(Map.Entry)it.next();
Uzel u=(Uzel)entry.getValue();
对于(int i=0;i
在我的MainFrame类中,我有一个关于buttonClick的方法 vykresliGraf(jPanel1.getGraphics());在jPanel上画我的地图但是什么时候
移除一些顶点(单击按钮)并调用相同的map.vykresliGraf(jPanel1.getGraphics());没有发生任何事情,我尝试重新绘制();仍然没有什么可以帮我做这件事?

可能是重复的不,它不起作用,但当我调用panel.repaint()时;它的透明面板