Skip to content

Commit 5b0d6f5

Browse files
Changed layout of ListOfFlashcardsDataPanel.java so that buttons stay on top of the flashcards.
1 parent 8b6a776 commit 5b0d6f5

File tree

1 file changed

+11
-5
lines changed

1 file changed

+11
-5
lines changed

src/main/java/frameworks_and_drivers/components/ListOfFlashcardsDataPanel.java

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
import frameworks_and_drivers.screens.EditorMainScreen;
1010

1111
import javax.swing.*;
12+
import javax.swing.border.EmptyBorder;
1213
import java.awt.*;
1314
import java.awt.event.ActionEvent;
1415
import java.awt.event.ActionListener;
@@ -62,8 +63,8 @@ public ListOfFlashcardsDataPanel(DBGateway dbGateway, List<FlashcardDsRequestMod
6263
int numCards = flashcardData.size();
6364
if (numCards == 0){
6465
JLabel label = new JLabel("You have no Flashcards in this FlashcardSet.");
65-
label.setHorizontalAlignment(SwingConstants.CENTER);
66-
label.setVerticalAlignment(SwingConstants.TOP);
66+
//label.setHorizontalAlignment(SwingConstants.CENTER);
67+
//label.setVerticalAlignment(SwingConstants.TOP);
6768
JPanel labelPanel = new JPanel();
6869
labelPanel.add(label);
6970
flashcardPanels.add(labelPanel);
@@ -76,17 +77,22 @@ public ListOfFlashcardsDataPanel(DBGateway dbGateway, List<FlashcardDsRequestMod
7677
//flashcardPanels customization
7778
int size = flashcardData.size();
7879
int rows;
79-
if (size % 3 == 0){
80+
if (size == 0){
81+
flashcardPanels.setLayout(new GridLayout(1, 1));
82+
}
83+
else if (size % 3 == 0){
8084
rows = size/3;
85+
flashcardPanels.setLayout(new GridLayout(rows, 3));
8186
}
8287
else{
8388
rows = size/3 + 1;
89+
flashcardPanels.setLayout(new GridLayout(rows, 3));
8490
}
85-
flashcardPanels.setLayout(new GridLayout(rows, 3));
8691

8792
//This panel customization
8893
this.add(flashcardPanels);
89-
this.setLayout(new FlowLayout());
94+
this.setLayout(new BoxLayout(this, BoxLayout.Y_AXIS));
95+
this.setBorder(new EmptyBorder(10, 10, 10, 10));
9096
this.setComponentOrientation(ComponentOrientation.LEFT_TO_RIGHT);
9197
Dimension fcPSize = flashcardPanels.getPreferredSize();
9298
this.setPreferredSize(new Dimension(fcPSize.width, fcPSize.height + 100));

0 commit comments

Comments
 (0)