今天早上完成了连连看的收尾工作,设置JTable透明,实现时间条,连线,背景图片。
部分功能还没实现,如:提示功能、边界消除。
设置JTable透明:
JTable table = new JTable(model){ public Component prepareRenderer(TableCellRenderer renderer, int row, int column) { JComponent component = (JComponent)super.prepareRenderer(renderer, row, column); component.setOpaque(false); return component; } }; table.setOpaque(false);
JProgressBar bar = new JProgressBar(); bar.setValue(progressbarvalue); this.add(bar); new Thread(){ public void run() { while(progressbarvalue>0){ progressbarvalue--; bar.setValue(progressbarvalue); try { Thread.sleep(1000); } catch (InterruptedException e) { e.printStackTrace(); } } }; }.start();
int x1 = 23+Column1*45; int x2 = 23+Column2*45; int y1 = 23+Row1*45; int y2 = 23+Row2*45; g.drawLine(x1, y1, x2, y2); try { Thread.sleep(500); } catch (InterruptedException e) { e.printStackTrace(); }
</pre>背景图片:</p><p><span style="font-size:24px;"></span><pre name="code" class="java">//往层面版加背景图片 this.getLayeredPane().setLayout(null); JLabel label = new JLabel(new ImageIcon("images/back.jpg")); //设置图片位置 label.setBounds(0, 0, this.getWidth(), this.getHeight()); this.getLayeredPane().add(label,new Integer(Integer.MIN_VALUE)); //容器面板 JComponent comp = (JComponent)this.getContentPane(); comp.setOpaque(false);