I wanted to create card view using jpanel array with the below code but it is not working the code is as:
This is to be same as that a facebook post on web I wanted to create it on gui
You may also suggest me other techniques to perform the same operation it would be a great help.
import java.awt.BorderLayout;
import java.awt.EventQueue;
import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.border.EmptyBorder;
import javax.swing.JScrollPane;
public class test extends JFrame {
private JPanel contentPane;
public static void main(String[] args) {
EventQueue.invokeLater(new Runnable() {
public void run() {
try {
test frame = new test();
frame.setVisible(true);
} catch (Exception e) {
e.printStackTrace();
}
}
});
}
public test() {
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
setBounds(100, 100, 587, 391);
contentPane = new JPanel();
contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
setContentPane(contentPane);
contentPane.setLayout(null);
JPanel[] pan = new JPanel[5];
int j= 0;
for(int i= 0;i<5;i++)
{
pan[i].setBounds(28, 22+j, 522, 149);
contentPane.add(pan[i]);
pan[i].setVisible(true);
j= j+160;
}
}
}
error
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.run(Unknown Source)