Java: Why doesn't this JPanel paint properly?
问题 I have a 2D array. I want each pixel to be represented by a total of four in the actual image. I've tried various piece of code but none seem to work and I don't really understand how it works either. So far I have: panel = new JPanel() { @Override public void paint(Graphics g) { Rectangle rect = g.getClipBounds(); g.setColor(Color.white); g.fillRect(rect.x, rect.y, rect.width, rect.height); for (int i = 0; i < m.width(); i++) { for (int j=0; j < m.height(); j++) { g.setColor(Color.red); g