Witam,
mam taki oto kod:
package com.company;
import javax.swing.*;
import java.awt.*;
import java.sql.*;
public class Main extends JPanel{
//...
public Frame frame;
public JPanel showTable;
public static void main(String[] args) {
//...
Main obiekt = new Main();
obiekt.start();
}
private void start(){
frame = new Frame();
frame.pack();
frame.getContentPane().setLayout(new BorderLayout());
System.out.println(frame.getWidth());
JPanel buttonsPanel = new JPanel();
buttonsPanel.setPreferredSize(new Dimension(150, 450));
buttonsPanel.setLayout(new GridLayout(nameOfTables.length, 1));
buttonsPanel.setBackground(Color.BLUE);
frame.getContentPane().add(buttonsPanel, BorderLayout.LINE_START);
//ScrollPanel scrollPanel = new ScrollPanel(frame.getWidth()-150, 450);
showTable = new JPanel();
showTable.setLayout(new BorderLayout());
showTable.setPreferredSize(new Dimension((frame.getWidth()-150), 450));
showTable.setBackground(Color.black);
frame.getContentPane().add(showTable, BorderLayout.LINE_END);
//showTable.add(scrollPanel, BorderLayout.CENTER);
JPanel actionButtons = new JPanel();
actionButtons.setPreferredSize(new Dimension(500, 50));
frame.getContentPane().add(actionButtons, BorderLayout.PAGE_END);
actionButtons.setBackground(Color.CYAN);
for (int i=0; i < nameOfTables.length; i++) {
buttonsPanel.add(new com.company.Button(nameOfTables[i]));
}
frame.pack();
frame.repaint();
System.out.println(buttonsPanel.getWidth());
System.out.println(showTable.getWidth());
System.out.println(frame.getWidth());
}
@Override
protected void paintComponent(Graphics g) {
super.paintComponent(g);
System.out.println("wywolanie!");
}
}
Dlaczego moja metoda paintComponent nie wywołuje się? Co więcej nawet rozszerzanie okna jej nie wywołuje;