Related questions
Automatically size JPanel inside JFrame
I have a JPanel subclass on which I add buttons, labels, tables, etc. To show on screen it I use JFrame:
MainPanel mainPanel = new MainPanel(); //JPanel subclass
JFrame mainFrame = new JFrame();
mainFrame.setTitle("main window title");
mainFrame.getContentPane().add(mainPanel);
…
Java JTable setting Column Width
I have a JTable in which I set the column size as follows:
table.setAutoResizeMode(JTable.AUTO_RESIZE_OFF);
table.getColumnModel().getColumn(0).setPreferredWidth(27);
table.getColumnModel().getColumn(1).setPreferredWidth(120);
table.getColumnModel().getColumn(2).setPreferredWidth(100);
table.getColumnModel().getColumn(3).setPreferredWidth(90);
table.getColumnModel().getColumn(4).setPreferredWidth(90);
table.…
Scale the ImageIcon automatically to label size
On my JFrame, I am using the following code to display an image on the Panel :
ImageIcon img= new ImageIcon("res.png");
jLabel.setIcon(img);
I would like to "auto-size" the picture in the label. Indeed, sometimes the image size …