Hi,
I have a panel that contains 3 rows. The first one contains a label, the second row contains the table paging stuff and the third one contains a table.
I want the label and the table to grow onall the panel but I want to remove the empty space between the paging components, previous, next buttons and start and end page number as the expected image
Attachment:
expected.JPG [ 8.74 KiB | Viewed 59 times ]
Below is what I'm getting
Attachment:
result.JPG [ 9.21 KiB | Viewed 59 times ]
Code:
import javax.swing.table.DefaultTableModel;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JTable;
import javax.swing.JTextField;
import net.miginfocom.swing.MigLayout;
public class ShrinkButtons extends JFrame {
public ShrinkButtons() {
JPanel panel = new JPanel(new MigLayout("fill"));
getContentPane().add(panel);
JLabel label = new JLabel("Description");
panel.add(label, "cell 0 0, spanx 4");
JButton previousButton = new JButton("<<");
panel.add(previousButton, "cell 0 1");
JTextField startField = new JTextField();
panel.add(startField, "cell 1 1, width 20px");
JLabel maxPages = new JLabel("/ 10");
panel.add(maxPages, "cell 2 1");
JButton nextButton = new JButton(">>");
panel.add(nextButton, "cell 3 1");
DefaultTableModel tableModel = new DefaultTableModel();
tableModel.setDataVector(new Object[][] {{"Value 1","A"}, {"Value 2","B"}}, new Object[] {"Column 1", "Column 2"});
JTable table = new JTable(tableModel);
panel.add(table, "cell 0 2, spanx 4, grow, pushy");
setVisible(true);
setExtendedState(MAXIMIZED_BOTH);
}
public static void main(String[] args) {
new ShrinkButtons();
}
}
Thank you,