66import java .awt .Color ;
77import java .awt .Dimension ;
88import java .awt .FlowLayout ;
9+ import java .awt .GridBagConstraints ;
10+ import java .awt .GridBagLayout ;
911import java .awt .Graphics ;
1012import java .awt .Graphics2D ;
1113import java .awt .GridLayout ;
@@ -67,11 +69,14 @@ public void removeNotify() {
6769 private void initComponents () {
6870 setBorder (BorderFactory .createEmptyBorder (2 , 5 , 2 , 5 ));
6971
70- JPanel topPanel = new JPanel (new BorderLayout (10 , 0 ));
71- JPanel statusDisplayPanel = new JPanel (new FlowLayout (FlowLayout .LEFT , 5 , 0 ));
72+ JPanel topPanel = new JPanel (new GridBagLayout ());
73+ GridBagConstraints gbc = new GridBagConstraints ();
74+ gbc .insets = new java .awt .Insets (0 , 2 , 0 , 2 );
75+ gbc .gridy = 0 ;
7276
7377 statusIndicator = new StatusIndicator ();
7478 statusLabel = new JLabel ("Initializing..." );
79+ statusLabel .setMinimumSize (new Dimension (10 , 16 ));
7580
7681 soundToggle = new JToggleButton (IconUtils .getIcon ("bell.png" ));
7782 soundToggle .setSelectedIcon (IconUtils .getIcon ("bell_mute.png" ));
@@ -83,16 +88,36 @@ private void initComponents() {
8388 killButton .setToolTipText ("Interrupt current API request or tool execution" );
8489 killButton .setVisible (false );
8590 killButton .addActionListener (e -> parentPanel .getChat ().kill ());
91+ killButton .setMargin (new java .awt .Insets (0 , 2 , 0 , 2 ));
92+ killButton .setFocusable (false );
8693
87- statusDisplayPanel .add (soundToggle );
88- statusDisplayPanel .add (statusIndicator );
89- statusDisplayPanel .add (statusLabel );
90- statusDisplayPanel .add (killButton );
94+ // Left-aligned components
95+ gbc .anchor = GridBagConstraints .WEST ;
96+ gbc .fill = GridBagConstraints .NONE ;
97+ gbc .weightx = 0.0 ;
98+
99+ gbc .gridx = 0 ;
100+ topPanel .add (soundToggle , gbc );
91101
92- contextUsageBar = new ContextUsageBar (parentPanel );
102+ gbc .gridx = 1 ;
103+ topPanel .add (statusIndicator , gbc );
104+
105+ gbc .gridx = 2 ;
106+ topPanel .add (killButton , gbc );
93107
94- topPanel .add (statusDisplayPanel , BorderLayout .WEST );
95- topPanel .add (contextUsageBar , BorderLayout .EAST );
108+ // Flexible center component
109+ gbc .gridx = 3 ;
110+ gbc .weightx = 1.0 ;
111+ gbc .fill = GridBagConstraints .HORIZONTAL ;
112+ topPanel .add (statusLabel , gbc );
113+
114+ // Right-aligned component
115+ contextUsageBar = new ContextUsageBar (parentPanel );
116+ gbc .gridx = 4 ;
117+ gbc .weightx = 0.0 ;
118+ gbc .fill = GridBagConstraints .NONE ;
119+ gbc .anchor = GridBagConstraints .EAST ;
120+ topPanel .add (contextUsageBar , gbc );
96121
97122 detailsPanel = new JPanel (new FlowLayout (FlowLayout .LEFT , 10 , 0 ));
98123 detailsPanel .setVisible (false );
@@ -213,7 +238,10 @@ private static class StatusIndicator extends JComponent {
213238 private Color color = Color .GRAY ;
214239
215240 public StatusIndicator () {
216- setPreferredSize (new Dimension (16 , 16 ));
241+ Dimension size = new Dimension (16 , 16 );
242+ setPreferredSize (size );
243+ setMinimumSize (size );
244+ setMaximumSize (size );
217245 }
218246
219247 public void setColor (Color color ) {
@@ -227,7 +255,8 @@ protected void paintComponent(Graphics g) {
227255 Graphics2D g2d = (Graphics2D ) g .create ();
228256 g2d .setRenderingHint (RenderingHints .KEY_ANTIALIASING , RenderingHints .VALUE_ANTIALIAS_ON );
229257 g2d .setColor (color );
230- g2d .fillOval (2 , 2 , getWidth () - 4 , getHeight () - 4 );
258+ // Draw a 12x12 circle centered in the 16x16 component
259+ g2d .fillOval (2 , 2 , 12 , 12 );
231260 g2d .dispose ();
232261 }
233262 }
0 commit comments