Skip to content

Commit dfa7dbd

Browse files
committed
Fix organization- and courselistwindows' visual bugs
1 parent 6bc9e49 commit dfa7dbd

File tree

2 files changed

+14
-10
lines changed

2 files changed

+14
-10
lines changed

tmc-plugin/src/fi/helsinki/cs/tmc/ui/CourseListWindow.java

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ public CourseListWindow(List<Course> courses, PreferencesPanel prefPanel) {
4848
this.title = new JLabel("Select a course:");
4949
Font titleFont = this.title.getFont();
5050
this.title.setFont(new Font(titleFont.getName(), Font.BOLD, 20));
51-
this.title.setBorder(new MatteBorder(new Insets(10, 10, 5, 10), new Color(242, 241, 240)));
51+
this.title.setBorder(new MatteBorder(new Insets(10, 10, 5, 10), getBackground()));
5252
Course[] courseArray = courses.toArray(new Course[courses.size()]);
5353
this.courses = new JList<>(courseArray);
5454
this.courses.setFixedCellHeight(107);
@@ -100,11 +100,7 @@ public static void display() throws Exception {
100100
CourseDb.getInstance().setAvailableCourses(courses);
101101
final CourseListWindow courseListWindow = new CourseListWindow(courses, prefPanel);
102102
frame.setContentPane(courseListWindow);
103-
if (hasCourses(courses, prefPanel)) {
104-
frame.pack();
105-
frame.setLocationRelativeTo(null);
106-
frame.setVisible(true);
107-
}
103+
108104
button.setMinimumSize(new Dimension(courseListWindow.getWidth(), button.getHeight()));
109105
button.setMaximumSize(new Dimension(courseListWindow.getWidth(), button.getHeight()));
110106
courseListWindow.addComponentListener(new ComponentListener() {
@@ -126,6 +122,12 @@ public void componentShown(ComponentEvent e) {
126122
public void componentHidden(ComponentEvent e) {
127123
}
128124
});
125+
126+
if (hasCourses(courses, prefPanel)) {
127+
frame.pack();
128+
frame.setLocationRelativeTo(null);
129+
frame.setVisible(true);
130+
}
129131
}
130132

131133
public static boolean isWindowVisible() {

tmc-plugin/src/fi/helsinki/cs/tmc/ui/OrganizationListWindow.java

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ public OrganizationListWindow(List<Organization> organizations) {
4949
this.title = new JLabel("Select an organization:");
5050
Font titleFont = this.title.getFont();
5151
this.title.setFont(new Font(titleFont.getName(), Font.BOLD, 20));
52-
this.title.setBorder(new MatteBorder(new Insets(10, 10, 5, 10), new Color(242, 241, 240)));
52+
this.title.setBorder(new MatteBorder(new Insets(10, 10, 5, 10), getBackground()));
5353
Collections.sort(organizations, (a, b) -> {
5454
if (a.isPinned() && b.isPinned()) {
5555
return a.getName().compareTo(b.getName());
@@ -107,9 +107,7 @@ public static void display() throws Exception {
107107
List<Organization> organizations = TmcCore.get().getOrganizations(ProgressObserver.NULL_OBSERVER).call();
108108
final OrganizationListWindow organizationListWindow = new OrganizationListWindow(organizations);
109109
frame.setContentPane(organizationListWindow);
110-
frame.pack();
111-
frame.setLocationRelativeTo(null);
112-
frame.setVisible(true);
110+
113111
button.setMinimumSize(new Dimension(organizationListWindow.getWidth(), button.getHeight()));
114112
button.setMaximumSize(new Dimension(organizationListWindow.getWidth(), button.getHeight()));
115113
organizationListWindow.addComponentListener(new ComponentListener() {
@@ -131,6 +129,10 @@ public void componentShown(ComponentEvent e) {
131129
public void componentHidden(ComponentEvent e) {
132130
}
133131
});
132+
133+
frame.pack();
134+
frame.setLocationRelativeTo(null);
135+
frame.setVisible(true);
134136
}
135137

136138
public static boolean isWindowVisible() {

0 commit comments

Comments
 (0)