Hallo
Situation:
Ich habe ein BorderLayout in dem wird ein JScroolpanel gepackt, das zeigt auf ein JPanel welches ein BoxLayout (Y) hat.
Jetzt werden diverse Gruppen von JPanels erstellt und dort drin diverse Werte hinzugefügt, z. B. JTable.
Problem: Ein JTabel ist genau 1 Zeile, aber das JScroolpanel ist 30 % zu Breit und 1000 % zu lang.
So sieht das im Editor aus (Eclipse)
Frage:
Ich frage mich warum, all die JScroolpanel die auf JTabel zeigen, die selber grösse haben, welche aber falsch ist.
Situation:
Ich habe ein BorderLayout in dem wird ein JScroolpanel gepackt, das zeigt auf ein JPanel welches ein BoxLayout (Y) hat.
Jetzt werden diverse Gruppen von JPanels erstellt und dort drin diverse Werte hinzugefügt, z. B. JTable.

Java:
public GuiSettingSelectionMain(
GuiDataTransferDatab classeGuiDataTransferDatab) {
setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
setBounds(100, 100, 450, 300);
contentPane = new JPanel();
contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
contentPane.setLayout(new BorderLayout(0, 0));
setContentPane(contentPane);
panelForSelectionAnyMain.setLayout(new BoxLayout(
panelForSelectionAnyMain, BoxLayout.Y_AXIS));
panelForSelectionAnyMain.setSize(new Dimension(0,0));
scrollbarForTableSelectionAnyMain = new JScrollPane(panelForSelectionAnyMain);
contentPane.add(scrollbarForTableSelectionAnyMain, BorderLayout.CENTER);
contentPane
.setAlignmentX(scrollbarForTableSelectionAnyMain.LEFT_ALIGNMENT);
JButton btnNewButton = new JButton("New button");
contentPane.add(btnNewButton, BorderLayout.SOUTH);
this.classeGuiDataTransferDatab = classeGuiDataTransferDatab;
createSelectionChooser();
createPathScanTable();
setPanelSize();
addJtableAJCombobox();
addJtableToTableListener();
setVisible();
}
private void createSelectionChooser() {
panelForSelectionAnyMain.add(Box.createRigidArea(new Dimension(0, 5)));
panelForSelectionAnyMain.add(new JLabel("Selection Chooser"));
panelForSelectionAnyMain.add(Box.createRigidArea(new Dimension(0, 5)));
tableSelectionAnyMain = new JTable();
tableSelectionAnyMainDatabase.add(null);
WhatYouWantToChangeHandler classeWhatYouWantToChangeHandler = new WhatYouWantToChangeHandler();
classeWhatYouWantToChangeHandler
.createSelectionList(tableSelectionAnyMain,
tableSelectionAnyMainDatabase);
scrollPaneForSelectionChooser = new JScrollPane(tableSelectionAnyMain);
scrollPaneForSelectionChooser.setAlignmentX(Component.LEFT_ALIGNMENT);
tableSelectionAnyMain.setCellSelectionEnabled(true);
}
Problem: Ein JTabel ist genau 1 Zeile, aber das JScroolpanel ist 30 % zu Breit und 1000 % zu lang.
So sieht das im Editor aus (Eclipse)

Frage:
Ich frage mich warum, all die JScroolpanel die auf JTabel zeigen, die selber grösse haben, welche aber falsch ist.