Im trying to show images and/or labels in my JPanel. The thing is, I want to show many JLabels in custom locations but currently I can only show like 4 labels. I understand I need to use ScrollPane. I have tried using it but its not letting me alocate them with customs locations. (By custom locations I mean using coords to place my label.)
Here is the code WITHOUT using ScrollPane:
import java.awt.Dimension;
import javax.swing.ImageIcon;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.border.EmptyBorder;
public class Images extends JFrame{
private JPanel contentPane;
public static void main(String[] args) {
Images image=new Images();
}
public Images(){
setVisible(true);
setTitle("myTitle");
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
setBounds(100, 100, 800, 800);
contentPane = new JPanel();
contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
setContentPane(contentPane);
contentPane.setLayout(null);
JLabel lblNombreequipo = new JLabel("trying: ");
lblNombreequipo.setBounds(147, 110, 145, 14);
contentPane.add(lblNombreequipo);
int coordY=150;
for(int i=0;i<10;i++){
JLabel myLabel = new JLabel("attempt: "+i);
myLabel.setBounds(147,coordY, 145, 14);
contentPane.add(myLabel);
coordY=coordY+150;
}
}
}