안녕을 작동하지 않습니다,하지만 난 설정보다 패널의 경계를 존중하지 않는이 내 코드 ItemCurso이 JPanel의에서, 마지막 확장JPanel의 내가 목록 수평 같은 JScrollPane의에 패널을 삽입 할
public PrincipalPanel() {
initComponents();
for(int i=0;i<3;i++){
addItem(new ItemCurso(),i);
}
}
public void addItem(ItemCurso item,int index){
item.setVisible(true);
item.setBounds(400*index, 0, 400, 300);
jScrollPane1.getViewport().add(item,null);
}
입니다 ItemCurso 내가 JScrollPane의 크기를 가져옵니다 설정하고 스크롤
을 작동하지 않습니다 ItemCurso의 코드는 다음과 같습니다
public class ItemCurso extends javax.swing.JPanel {
public ItemCurso() {
initComponents();
}
@SuppressWarnings("unchecked")
private void initComponents() {
jLabel1 = new javax.swing.JLabel();
jPanel1 = new javax.swing.JPanel();
nombreTxt = new javax.swing.JLabel();
escuelaTxt = new javax.swing.JLabel();
bimestresComboBox = new javax.swing.JComboBox();
jButton1 = new javax.swing.JButton();
jButton2 = new javax.swing.JButton();
jButton3 = new javax.swing.JButton();
jButton4 = new javax.swing.JButton();
jButton5 = new javax.swing.JButton();
jButton6 = new javax.swing.JButton();
jButton7 = new javax.swing.JButton();
jLabel1.setText("jLabel1");
setBackground(new java.awt.Color(229, 232, 221));
setPreferredSize(new java.awt.Dimension(100, 100));
jPanel1.setBackground(new java.awt.Color(255, 255, 255));
javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
jPanel1.setLayout(jPanel1Layout);
jPanel1Layout.setHorizontalGroup(
jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGap(0, 100, Short.MAX_VALUE)
);
jPanel1Layout.setVerticalGroup(
jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGap(0, 100, Short.MAX_VALUE)
);
nombreTxt.setText("Nombre");
escuelaTxt.setText("Escuela");
bimestresComboBox.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Item 1", "Item 2", "Item 3", "Item 4" }));
jButton1.setIcon(new javax.swing.ImageIcon("C:\\Users\\Cristian_Franco\\Documents\\Sithec\\Proyectos\\Proyecto Escuelas\\SITCEA\\mavenproject1\\Images\\Resources\\Recurso 14.png")); // NOI18N
jButton2.setIcon(new javax.swing.ImageIcon("C:\\Users\\Cristian_Franco\\Documents\\Sithec\\Proyectos\\Proyecto Escuelas\\SITCEA\\mavenproject1\\Images\\Resources\\Recurso 28.png")); // NOI18N
jButton3.setIcon(new javax.swing.ImageIcon("C:\\Users\\Cristian_Franco\\Documents\\Sithec\\Proyectos\\Proyecto Escuelas\\SITCEA\\mavenproject1\\Images\\Resources\\Recurso 27.png")); // NOI18N
jButton4.setIcon(new javax.swing.ImageIcon("C:\\Users\\Cristian_Franco\\Documents\\Sithec\\Proyectos\\Proyecto Escuelas\\SITCEA\\mavenproject1\\Images\\Resources\\Recurso 29.png")); // NOI18N
jButton5.setIcon(new javax.swing.ImageIcon("C:\\Users\\Cristian_Franco\\Documents\\Sithec\\Proyectos\\Proyecto Escuelas\\SITCEA\\mavenproject1\\Images\\Resources\\Recurso 30.png")); // NOI18N
jButton6.setIcon(new javax.swing.ImageIcon("C:\\Users\\Cristian_Franco\\Documents\\Sithec\\Proyectos\\Proyecto Escuelas\\SITCEA\\mavenproject1\\Images\\Resources\\Recurso 31.png")); // NOI18N
jButton7.setIcon(new javax.swing.ImageIcon("C:\\Users\\Cristian_Franco\\Documents\\Sithec\\Proyectos\\Proyecto Escuelas\\SITCEA\\mavenproject1\\Images\\Resources\\Recurso 32.png")); // NOI18N
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
this.setLayout(layout);
layout.setHorizontalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addContainerGap()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(bimestresComboBox, 0, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addGroup(layout.createSequentialGroup()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addComponent(jButton1, javax.swing.GroupLayout.PREFERRED_SIZE, 100, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 15, Short.MAX_VALUE)
.addComponent(jButton3, javax.swing.GroupLayout.PREFERRED_SIZE, 100, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGroup(layout.createSequentialGroup()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(18, 18, 18)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(nombreTxt)
.addComponent(escuelaTxt)))
.addComponent(jButton7, javax.swing.GroupLayout.PREFERRED_SIZE, 100, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGap(0, 0, Short.MAX_VALUE))
.addGroup(layout.createSequentialGroup()
.addComponent(jButton4, javax.swing.GroupLayout.PREFERRED_SIZE, 100, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(jButton5, javax.swing.GroupLayout.PREFERRED_SIZE, 100, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(0, 0, Short.MAX_VALUE)))
.addGap(18, 18, 18)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addGap(0, 0, Short.MAX_VALUE)
.addComponent(jButton2, javax.swing.GroupLayout.PREFERRED_SIZE, 100, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGroup(layout.createSequentialGroup()
.addComponent(jButton6, javax.swing.GroupLayout.PREFERRED_SIZE, 100, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(0, 0, Short.MAX_VALUE)))))
.addContainerGap())
);
layout.setVerticalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addContainerGap()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addComponent(nombreTxt)
.addGap(18, 18, 18)
.addComponent(escuelaTxt))
.addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGap(18, 18, 18)
.addComponent(bimestresComboBox, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(18, 18, 18)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jButton1, javax.swing.GroupLayout.PREFERRED_SIZE, 100, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jButton2, javax.swing.GroupLayout.PREFERRED_SIZE, 100, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jButton3, javax.swing.GroupLayout.PREFERRED_SIZE, 100, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGap(18, 18, 18)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
.addComponent(jButton5, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.PREFERRED_SIZE, 0, Short.MAX_VALUE)
.addComponent(jButton6, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.PREFERRED_SIZE, 100, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jButton4, javax.swing.GroupLayout.PREFERRED_SIZE, 0, Short.MAX_VALUE))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 26, Short.MAX_VALUE)
.addComponent(jButton7, javax.swing.GroupLayout.PREFERRED_SIZE, 100, javax.swing.GroupLayout.PREFERRED_SIZE))
);
}// </editor-fold>
// Variables declaration - do not modify
private javax.swing.JComboBox bimestresComboBox;
private javax.swing.JLabel escuelaTxt;
private javax.swing.JButton jButton1;
private javax.swing.JButton jButton2;
private javax.swing.JButton jButton3;
private javax.swing.JButton jButton4;
private javax.swing.JButton jButton5;
private javax.swing.JButton jButton6;
private javax.swing.JButton jButton7;
private javax.swing.JLabel jLabel1;
private javax.swing.JPanel jPanel1;
private javax.swing.JLabel nombreTxt;
// End of variables declaration
}
'ItemCurso' 클래스의 코드가 필요합니다. 그것 없이는'setBounds()'의 구현을 볼 수 없다. –
ok, 잠시 기다리십시오. –
생성 된 코드를 포함하여 모든 코드가 필요합니다. –