I'm back to start again with GBL. Application start-up layout is as desired. However as soon as I draw upon "main page view panel" with paintComponent() page view panel does overlay thumbnail panel on the left.
Code for main panel to group up 3 main components
public class RottrMainPanel extends JPanel{
private PdfManager pdfManager;
public RottrMainPanel(){
super();
pdfManager = new PdfManager();
setPanel();
setBackground(Color.WHITE);
}
private void setPanel(){
Dimension dim = new Dimensions().getMaxDimension();
setLayout(new GridBagLayout());
GridBagConstraints gbc = new GridBagConstraints();
gbc.fill = GridBagConstraints.HORIZONTAL;
gbc.anchor = GridBagConstraints.NORTHWEST;
gbc.gridwidth = GridBagConstraints.REMAINDER;
gbc.gridx = 0;
gbc.gridy = 0;
RottrToolBar rottrToolBar = new RottrToolBar(pdfManager);
add(rottrToolBar, gbc);
gbc.insets = new Insets(10, 10, 10, 10);
gbc.fill = GridBagConstraints.VERTICAL;
gbc.ipadx = 185;
gbc.gridx = 0;
gbc.gridy = 1;
RottrThumbnailsPanel rottrThumbnailsPanel = new RottrThumbnailsPanel(pdfManager);
JScrollPane jspThumbnails = new JScrollPane(rottrThumbnailsPanel,
ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED,
ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED);
add(jspThumbnails, gbc);
gbc.fill = GridBagConstraints.BOTH;
gbc.gridx = 1;
gbc.gridy = 1;
gbc.weightx = 1.0;
gbc.weighty = 1.0;
RottrPageViewPanel rottrPageViewPanel = new RottrPageViewPanel(pdfManager);
JScrollPane jspPageView = new JScrollPane(rottrPageViewPanel,
ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED,
ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED);
add(jspPageView, gbc);
dim = new Dimension((int)dim.getWidth()-10, (int)dim.getHeight()-10);
setPreferredSize(dim);
setMaximumSize(dim);
}
}
and drawing on main view panel ( I do not think issue is here)
public void paintComponent(Graphics g) {
//super.paintComponent(g);
if (isDrawingAllowed) {
g.drawImage(img, 0, 0, this);
}
}
public void fileToOpen() {
isDrawingAllowed = true;
Pdf2Image pdf2Image = new Pdf2Image();
img = pdf2Image.getPage(1, pdfManager.getPdfFile().toString());
repaint();
}