4343import java .awt .GridBagConstraints ;
4444import java .awt .GridBagLayout ;
4545import java .awt .GridLayout ;
46- import java .awt .Insets ;
4746import java .awt .event .KeyListener ;
4847import java .awt .event .MouseAdapter ;
4948import java .awt .event .MouseEvent ;
5655import java .util .Set ;
5756import java .util .regex .Pattern ;
5857import javax .inject .Inject ;
58+ import javax .swing .Box ;
59+ import javax .swing .BoxLayout ;
5960import javax .swing .Icon ;
6061import javax .swing .ImageIcon ;
6162import javax .swing .JButton ;
@@ -141,10 +142,12 @@ public enum WarningLabel
141142 private static final int HEADER_PAD = 3 ;
142143 private static final int WARNING_PAD = 5 ;
143144 private static final int VALUE_PAD = 2 ;
145+ private static final int SUB_PANEL_SEPARATION_HEIGHT = 10 ;
144146 private static final Border SUB_PANEL_BORDER = new EmptyBorder (5 , 10 , 10 , 10 );
145147 private static final Dimension HEADER_PREFERRED_SIZE = new Dimension (0 , 25 );
146148
147149 private static final int MAX_FEEDBACK_TEXT_CHARS = 250 ;
150+ private static final Dimension FEEDBACK_TEXTBOX_PREFERRED_SIZE = new Dimension (0 , 75 );
148151
149152 private static final PlayerStatsType [] PLAYER_STAT_TYPES = {
150153 PlayerStatsType .TOTAL , PlayerStatsType .PASSIVE , PlayerStatsType .MANUAL
@@ -223,9 +226,9 @@ public BotDetectorPanel(
223226 this .nameAutocompleter = nameAutocompleter ;
224227 this .eventBus = eventBus ;
225228
226- setBorder (new EmptyBorder (18 , 10 , 0 , 10 ));
229+ setBorder (new EmptyBorder (18 , 10 , 10 , 10 ));
227230 setBackground (BACKGROUND_COLOR );
228- setLayout (new GridBagLayout ( ));
231+ setLayout (new BoxLayout ( this , BoxLayout . Y_AXIS ));
229232
230233 currentPlayerStatsType = config .panelDefaultStatsType ();
231234
@@ -235,39 +238,29 @@ public BotDetectorPanel(
235238 playerStatsTabGroup = playerStatsTabGroup ();
236239 playerStatsPanel = playerStatsPanel ();
237240 primaryPredictionPanel = primaryPredictionPanel ();
238- predictionFeedbackPanel = predictionFeedbackPanel ();
241+ predictionFeedbackPanel = putInBoxPanelWithVerticalSeparator ( predictionFeedbackPanel () );
239242 predictionFeedbackPanel .setVisible (false );
240- predictionFlaggingPanel = predictionFlaggingPanel ();
243+ predictionFlaggingPanel = putInBoxPanelWithVerticalSeparator ( predictionFlaggingPanel () );
241244 predictionFlaggingPanel .setVisible (false );
242- predictionBreakdownPanel = predictionBreakdownPanel ();
245+ predictionBreakdownPanel = putInBoxPanelWithVerticalSeparator ( predictionBreakdownPanel () );
243246 predictionBreakdownPanel .setVisible (false );
244247
245- GridBagConstraints c = new GridBagConstraints ();
246- c .fill = GridBagConstraints .HORIZONTAL ;
247- c .gridx = 0 ;
248- c .gridy = 0 ;
249- c .weightx = 1 ;
250- c .weighty = 0 ;
251- c .insets = new Insets (0 , 0 , 10 , 0 );
252- add (linksPanel , c );
248+ add (linksPanel );
253249
254- c . gridy ++ ;
255- add (playerStatsPanel , c );
250+ add ( Box . createVerticalStrut ( SUB_PANEL_SEPARATION_HEIGHT )) ;
251+ add (playerStatsPanel );
256252
257- c . gridy ++ ;
258- add (searchBar , c );
253+ add ( Box . createVerticalStrut ( SUB_PANEL_SEPARATION_HEIGHT )) ;
254+ add (searchBar );
259255
260- c . gridy ++ ;
261- add (primaryPredictionPanel , c );
256+ add ( Box . createVerticalStrut ( SUB_PANEL_SEPARATION_HEIGHT )) ;
257+ add (primaryPredictionPanel );
262258
263- c .gridy ++;
264- add (predictionBreakdownPanel , c );
259+ add (predictionBreakdownPanel );
265260
266- c .gridy ++;
267- add (predictionFeedbackPanel , c );
261+ add (predictionFeedbackPanel );
268262
269- c .gridy ++;
270- add (predictionFlaggingPanel , c );
263+ add (predictionFlaggingPanel );
271264
272265 setPlayerIdVisible (false );
273266 setPrediction (null );
@@ -288,6 +281,21 @@ public void onActivate()
288281 eventBus .post (new BotDetectorPanelActivated ());
289282 }
290283
284+ /**
285+ * Puts the panel in a box layout panel with a vertical pad above ({@link #SUB_PANEL_SEPARATION_HEIGHT}).
286+ * @param panel The panel.
287+ * @return A panel containing the previous panel with a vertical padding element above.
288+ */
289+ private static JPanel putInBoxPanelWithVerticalSeparator (JPanel panel )
290+ {
291+ JPanel newPanel = new JPanel ();
292+ newPanel .setBorder (new EmptyBorder (0 , 0 , 0 , 0 ));
293+ newPanel .setLayout (new BoxLayout (newPanel , BoxLayout .Y_AXIS ));
294+ newPanel .add (Box .createVerticalStrut (SUB_PANEL_SEPARATION_HEIGHT ));
295+ newPanel .add (panel );
296+ return newPanel ;
297+ }
298+
291299 /**
292300 * Generates and sets variables related to the links panel.
293301 * @return The panel containing all the related elements.
@@ -387,6 +395,7 @@ private JPanel playerStatsPanel()
387395 playerStatsHeaderLabel .setFont (BOLD_FONT );
388396 playerStatsHeaderLabel .setForeground (HEADER_COLOR );
389397 playerStatsHeaderLabel .setPreferredSize (HEADER_PREFERRED_SIZE );
398+ playerStatsHeaderLabel .setMinimumSize (HEADER_PREFERRED_SIZE );
390399
391400 c .gridx = 0 ;
392401 c .gridy = 0 ;
@@ -598,6 +607,7 @@ private JPanel primaryPredictionPanel()
598607 label .setFont (BOLD_FONT );
599608 label .setForeground (HEADER_COLOR );
600609 label .setPreferredSize (HEADER_PREFERRED_SIZE );
610+ label .setMinimumSize (HEADER_PREFERRED_SIZE );
601611 c .gridx = 0 ;
602612 c .gridy = 0 ;
603613 c .ipady = HEADER_PAD ;
@@ -689,6 +699,7 @@ private JPanel predictionFeedbackPanel()
689699 feedbackHeaderLabel .setFont (NORMAL_FONT );
690700 feedbackHeaderLabel .setForeground (HEADER_COLOR );
691701 feedbackHeaderLabel .setPreferredSize (HEADER_PREFERRED_SIZE );
702+ feedbackHeaderLabel .setMinimumSize (HEADER_PREFERRED_SIZE );
692703 c .gridx = 0 ;
693704 c .gridy = 0 ;
694705 c .ipady = HEADER_PAD ;
@@ -706,7 +717,8 @@ private JPanel predictionFeedbackPanel()
706717 feedbackTextbox .setTabSize (2 );
707718 feedbackTextScrollPane = new JScrollPane (feedbackTextbox );
708719 feedbackTextScrollPane .setVerticalScrollBarPolicy (JScrollPane .VERTICAL_SCROLLBAR_ALWAYS );
709- feedbackTextScrollPane .setPreferredSize (new Dimension (0 , 75 ));
720+ feedbackTextScrollPane .setPreferredSize (FEEDBACK_TEXTBOX_PREFERRED_SIZE );
721+ feedbackTextScrollPane .setMinimumSize (FEEDBACK_TEXTBOX_PREFERRED_SIZE );
710722 feedbackTextScrollPane .setBorder (new EmptyBorder (0 , 0 , 10 , 0 ));
711723 feedbackTextScrollPane .setOpaque (false );
712724 c .gridy ++;
@@ -754,6 +766,7 @@ private JPanel predictionFlaggingPanel()
754766 flaggingHeaderLabel .setFont (NORMAL_FONT );
755767 flaggingHeaderLabel .setForeground (HEADER_COLOR );
756768 flaggingHeaderLabel .setPreferredSize (HEADER_PREFERRED_SIZE );
769+ flaggingHeaderLabel .setMinimumSize (HEADER_PREFERRED_SIZE );
757770 c .gridx = 0 ;
758771 c .gridy = 0 ;
759772 c .ipady = HEADER_PAD ;
@@ -803,6 +816,7 @@ private JPanel predictionBreakdownPanel()
803816 label .setFont (BOLD_FONT );
804817 label .setForeground (HEADER_COLOR );
805818 label .setPreferredSize (HEADER_PREFERRED_SIZE );
819+ label .setMinimumSize (HEADER_PREFERRED_SIZE );
806820 c .gridx = 0 ;
807821 c .gridy = 0 ;
808822 c .weightx = 1.0 ;
0 commit comments