I trying to use SwingUtilities.invokelater to allow me to resize and move my programs window about while my long process is running. What I'm getting is that I'm able to move the window and resize it but the components inside don't update e.g. If I resize the window to being larger than it was when it started I just get black colour filling it.
I'm not quite sure where I'm going wrong but I feel like it's how I have my panels/frames setup? Any help would be appreciated.
public static void main(String[] args) {
try {
UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
} catch (Exception e) {
System.out.println("Error setting system look and feel: "+e);
}
SwingUtilities.invokeLater(new Runnable(){
@Override
public void run(){
BrowseModel model = new BrowseModel();
BrowseView view = new BrowseView(model);
BrowseController controller = new BrowseController(model, view);
view.setVisible(true);
}
});
}
My View:
BrowseView(BrowseModel model){
m_model = model;
JScrollPane targetUrlScroller = new JScrollPane(m_targetURLs);
targetUrlScroller.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS);
targetUrlScroller.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED);
targetUrlScroller.setAlignmentX(Component.LEFT_ALIGNMENT);
m_resultsTable = new JTable(table_model);
table_model.addColumn("Locale");
table_model.addColumn("URL");
table_model.addColumn("Product");
table_model.addColumn("Category");
table_model.addColumn("Filter");
table_model.addColumn("Article Title");
table_model.addColumn("Article Image");
table_model.addColumn("Article Description");
table_model.addColumn("Article URL");
m_resultsTable.setFillsViewportHeight(true);
JScrollPane resultsScroller = new JScrollPane(m_resultsTable);
resultsScroller.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS);
resultsScroller.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED);
resultsScroller.setAlignmentX(Component.LEFT_ALIGNMENT);
JPanel localeSelection = new JPanel();
localeSelection.add(new JLabel("Locales:"));
localeSelection.add(m_selectLocale = new JComboBox(getLocales().toArray()));
localeSelection.setLayout(new FlowLayout(FlowLayout.RIGHT));
localeSelection.setAlignmentX(Component.LEFT_ALIGNMENT);
JPanel buttonsPanel = new JPanel();
buttonsPanel.add(m_currentStatus);
buttonsPanel.add(m_clearButton);
buttonsPanel.add(m_runButton);
buttonsPanel.setAlignmentX(Component.LEFT_ALIGNMENT);
buttonsPanel.setLayout(new FlowLayout(FlowLayout.RIGHT));
JPanel content = new JPanel();
content.setBorder(new EmptyBorder(10, 10, 10, 10));
content.setAlignmentX(Component.LEFT_ALIGNMENT);
content.setLayout(new BoxLayout(content, BoxLayout.Y_AXIS));
content.add(localeSelection);
content.add(new JLabel("Target URLs:"));
content.add(targetUrlScroller);
content.add(new JLabel("Results:"));
content.add(resultsScroller);
content.add(buttonsPanel);
this.setContentPane(content);
this.pack();
this.setMinimumSize(new Dimension(900,600));
this.setTitle("Browse Page Inspector");
this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
}