문제

Iam trying to position my jlabel in a jpanel what is made final because of an actionlistener.

final JPanel panelPayDetails = new JPanel();
panelPayDetails.setBounds(250, 25, 350, 250);

JLabel lblnumber = new JLabel("Insert Number:");         
lblnumber.setFont(Applicatie.FONT_12_BOLD);
lblnumber.setBounds(5, 5, 200, 20);

panelPayDetails.add(lblnumber);
panelPayDetails.setVisible(false);
jpExtraDetails.add(panelPayDetails);

bill.addActionListener(new ActionListener() {

            public void actionPerformed(ActionEvent e)
            {                
              if(bill.getSelectedItem() == "CREDIT CARD")
              {

                   panelPayDetails.setVisible(true);
              }
            }
        });    

im not luck so far.. because the label is positioned in the middle of the jpanel.. how come?

도움이 되었습니까?

해결책

Because the default layout manager for JPanel is FlowLayout, which centers things. Read this tutorial.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top