Put JLabel on Component in JPanel
I have JPanel which contain a component imageWindow(object of this ) now i want to put a label tag in the center of this imagewindow but i am not able to do so? JPanel imagePanel = new JPanel(); imagePanel.setLayout(new GridBagLayout()); imagePanel.add(ic); //ic is imageWindow obj JLabel l1=new JLabel("First Label."); JPanel example =new JPanel(); example.add(l1); imagePanel.add(example); what i am doing wrong here is screenshow i need to put the label here. i want to put the label at the center but it always coming in the right side what i am doing wrong? You could display the image in a