私はJFrameのを持っていると私は内部フレームの1つにJPanelのを追加した
JInternalFrameの
2を追加して表示されません。マウスをリスナーをjPanelに使用し、マウスを離すとデバイスオブジェクト(クラスextendng jpanel)を配置するようなコードを書きました。
デバイスイメージは表示されますが、内部フレームを移動した後、または最大化すると表示されます。なぜtatですか?
次のコードは、内部フレームの1つに追加されるのJPanelです...
public class Board extends JPanel implements MouseListener{
Device[] devices=new Device[10];
int X,Y,i=0;
int j=10;
Point p1,p2;
ImageIcon icon;
public Board()
{
setBackground(Color.WHITE);
this.addMouseListener(this);
setLayout(null);
}
public void mouseClicked(MouseEvent me){
}
public void mouseExited(MouseEvent me){
}
public void mouseEntered(MouseEvent me){
}
public void mousePressed(MouseEvent me){
}
public void mouseReleased(MouseEvent me){
X=me.getX();
Y=me.getY();
icon=new ImageIcon("E:\\java\\ecadpb\\src\\ecadpb\\device"+Layout1.clicked+".png");
devices[i].setBounds(X,Y,icon.getIconWidth(),icon.getIconHeight()+20);
devices[i].setVisible(true);
this.add(devices[i]);
this.repaint(X,Y,icon.getIconWidth(),icon.getIconHeight()+20);
i++;
}
}
}
次は、デバイスクラス..です
public Device(Point pos,JLabel label,Rectangle r,int input,int output){
setVisible(true);
setBackground(Color.BLACK);
deviceNo=dno;
position=pos;
inputs=input;
outputs=output;
this.r=r;
label.setLayout(null);
setOpaque(false);
this.add(label);
label.addMouseListener(this);
dno++;
}
}
幻想を!!私はrevalidate()メソッドを呼び出し、それは問題を解決しました..ありがとう! –
優秀 - この回答に承諾してください:) –