Gui 빌더에서 JPanel을 다시 칠하기 위해 truble을 얻을 수 있습니다. 여기GUI에서 JPanel을 다시 유효화합니다.
다음private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
new Main();
Jpl jpl=new Jpl();
}
가 손님의 구성 요소로 추가 할 클래스 사용자 지정 코드로 JPanel을 포함 클래스 A의 버튼 클릭 이벤트의 생성자 여기
public class Main {
public static int q;
public Main(){
Random randomGenerator = new Random();
for (int idx = 1; idx <= 10; ++idx) {
q = randomGenerator.nextInt(100);
}
}
에서 난수를 생성하는 기본 클래스입니다 A 급
public class Jpl extends JPanel {
public Jpl() {
printMe(Main.q);
}
public int printMe(int q) {
removeAll();
for (int i = 0; i <q; i++) {
System.out.println("rinting lable");
String htmlLabel = "<html><font color=\"#A01070\">" + i + " New Lable </font></html>";
JLabel lbl = new JLabel(htmlLabel);
setLayout(new GridLayout(0, 1));
add(lbl, Jpl.RIGHT_ALIGNMENT);
lbl.setForeground(Color.BLUE);
Border border = BorderFactory.createLineBorder(Color.lightGray);
lbl.setBorder(border);
lbl.add(new JSeparator(SwingConstants.HORIZONTAL));
lbl.addMouseListener(new MouseAdapter() {
@Override
public void mousePressed(MouseEvent e) {
JLabel label = (JLabel) e.getSource();
JOptionPane.showMessageDialog(null, "You Slected");
System.out.println(label.getText() + "NO AKKA is Selected");
}
});
}
revalidate();
repaint();
return 1;
}
실제로 올바른 코드를 붙여 넣는 것을 잊어 버렸습니다. –
"실제로 올바른 코드를 붙여 넣는 것을 잊어 버렸습니다."- 훌륭합니다. 아직 실행 가능한 질문을하지 않았습니다. 이러한 결점을 바로 잡으려면주의해야합니까? –
actully이 JPanel을 다른 JPanel 클래스로 추가하려고합니다.이 값을 JPanel에 올리면이 패널을 업데이트하고 싶습니다. button을 사용할 때이 패널을 업데이트하고 싶습니다. availabel 무선 네트워크에 대한 새로 고침 버튼과 똑같이 말할 수 있습니다. 동일한 Netbeans를 사용하여 내 gui 페이지에서 구현하려고하는 것과 같습니다. –