I made a small application to open a file and show the contents of opened file in some JTextField and JLabels. I can get all the contents and fill in the TextFields and Labels but the problem is these JLabels and JTextFields are not shown untill and unless I resize(even a little) the windows. I want my contents to be shown straight away. What do I need to do for this.
WL
here is a piece of code to initialize the panel and adding it to scrollpane
panel = new JPanel();
scrollPane = new JScrollPane(panel);
In the actionlistener of open button I got the following code
int returnVal = fc.showOpenDialog(FileReader.this);
if (returnVal == JFileChooser.APPROVE_OPTION) {
File file = fc.getSelectedFile();
String filePath = file.getPath();
// if(panel.isDisplayable()==true)panel.
if(scrollPane != null){
//panel.removeAll();
this.remove(scrollPane);
// scrollPane.add(panel);
//panel.add(panel);
//panel.validate();
//panel.repaint();
}
//pass the file to XMLparser
xmlParsing = new XMLParsing(filePath);
panel = new JPanel();
panel=fill();
panel.revalidate();
panel.repaint();
scrollPane = new JScrollPane(panel);
add(scrollPane, BorderLayout.CENTER);
//add(buttonPanel, BorderLayout.SOUTH);
saveButton.setEnabled(true);
saveasButton.setEnabled(true);
After adding all the components call
of container