无法在Java中使用HashMap从BuffereImage渲染视频
在我的项目中,我有一个类FramesUtil,它包含一组存储在HashMap中的帧-无法在Java中使用HashMap从BuffereImage渲染视频,java,jframe,jwt,bufferedimage,gridbaglayout,Java,Jframe,Jwt,Bufferedimage,Gridbaglayout,在我的项目中,我有一个类FramesUtil,它包含一组存储在HashMap中的帧- ConcurrentHashMap<Integer, Frame> frameMap 在迭代过程中,JFrame似乎没有在循环中使用新的BuffereImage进行更新 下面是我在Arbiter.java中的playVideo方法- public static void playVideo() { BufferedImage img; JFrame frame =
ConcurrentHashMap<Integer, Frame> frameMap
在迭代过程中,JFrame似乎没有在循环中使用新的BuffereImage进行更新
下面是我在Arbiter.java中的playVideo方法-
public static void playVideo() {
BufferedImage img;
JFrame frame = new JFrame();
GridBagLayout gLayout = new GridBagLayout();
frame.getContentPane().setLayout(gLayout);
JLabel lbIm1;
for(int i=0; (img=FramesUtil.frameMap.get(i).bufferedImage)!=null; i++) {
lbIm1 = new JLabel(new ImageIcon(img));
GridBagConstraints c = new GridBagConstraints();
c.fill = GridBagConstraints.HORIZONTAL;
c.anchor = GridBagConstraints.CENTER;
c.fill = GridBagConstraints.HORIZONTAL;
c.gridx = 0;
c.gridy = 1;
System.out.println(lbIm1);
frame.getContentPane().add(lbIm1, c);
frame.pack();
frame.setVisible(true);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
}
}
P.P.S.我已经尝试在for循环中创建新的jFrand和GrdAgBayes实例,请看一看,我也会考虑一个可能通过
public static void playVideo() {
BufferedImage img;
JFrame frame = new JFrame();
GridBagLayout gLayout = new GridBagLayout();
frame.getContentPane().setLayout(gLayout);
JLabel lbIm1;
for(int i=0; (img=FramesUtil.frameMap.get(i).bufferedImage)!=null; i++) {
lbIm1 = new JLabel(new ImageIcon(img));
GridBagConstraints c = new GridBagConstraints();
c.fill = GridBagConstraints.HORIZONTAL;
c.anchor = GridBagConstraints.CENTER;
c.fill = GridBagConstraints.HORIZONTAL;
c.gridx = 0;
c.gridy = 1;
System.out.println(lbIm1);
frame.getContentPane().add(lbIm1, c);
frame.pack();
frame.setVisible(true);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
}
}