@@ -101,6 +101,30 @@ public void addPanel(String name, Component comp) {
101101 }
102102
103103
104+ // public void setPanel(int index) {
105+ // cardLayout.show(cardPanel, tabs.get(index).name);
106+ // }
107+
108+
109+ public void setPanel (Component comp ) {
110+ for (Tab tab : tabs ) {
111+ if (tab .comp == comp ) {
112+ cardLayout .show (cardPanel , tab .name );
113+ }
114+ }
115+ }
116+
117+
118+ public void setNotification (Component comp , boolean note ) {
119+ for (Tab tab : tabs ) {
120+ if (tab .comp == comp ) {
121+ tab .notification = note ;
122+ repaint ();
123+ }
124+ }
125+ }
126+
127+
104128 public void updateMode () {
105129 Mode mode = editor .getMode ();
106130
@@ -127,7 +151,7 @@ public void mousePressed(MouseEvent e) {
127151 for (Tab tab : tabs ) {
128152 if (tab .contains (x )) {
129153 //editor.setFooterPanel(tab.index);
130- cardLayout .show (cardPanel , tab .text );
154+ cardLayout .show (cardPanel , tab .name );
131155 }
132156 }
133157 }
@@ -178,7 +202,7 @@ public void paintComponent(Graphics screen) {
178202 // reset all tab positions
179203 for (Tab tab : tabs ) {
180204 tab .textWidth = (int )
181- font .getStringBounds (tab .text , g2 .getFontRenderContext ()).getWidth ();
205+ font .getStringBounds (tab .name , g2 .getFontRenderContext ()).getWidth ();
182206 }
183207
184208 // now actually draw the tabs
@@ -192,77 +216,81 @@ public void paintComponent(Graphics screen) {
192216
193217 screen .drawImage (offscreen , 0 , 0 , imageW , imageH , null );
194218 }
195- }
196219
197220
198- /**
199- * @param left starting position from the left
200- * @param g graphics context, or null if we're not drawing
201- */
202- private void placeTabs (int left , Graphics2D g ) {
203- int x = left ;
221+ /**
222+ * @param left starting position from the left
223+ * @param g graphics context, or null if we're not drawing
224+ */
225+ private void placeTabs (int left , Graphics2D g ) {
226+ int x = left ;
204227
205- for (Tab tab : tabs ) {
206- int state = tab .isCurrent () ? SELECTED : UNSELECTED ;
207- tab .left = x ;
208- x += TEXT_MARGIN ;
209- x += tab .textWidth + TEXT_MARGIN ;
210- tab .right = x ;
211-
212- // if drawing and not just placing
213- if (g != null ) {
214- g .setColor (tabColor [state ]);
215- drawTab (g , tab .left , tab .right , tab .isFirst (), tab .isLast ());
216-
217- int textLeft = tab .left + ((tab .right - tab .left ) - tab .textWidth ) / 2 ;
218- g .setColor (textColor [state ]);
219- int tabHeight = TAB_BOTTOM - TAB_TOP ;
220- int baseline = TAB_TOP + (tabHeight + fontAscent ) / 2 ;
221- g .drawString (tab .text , textLeft , baseline );
228+ for (Tab tab : tabs ) {
229+ int state = tab .isCurrent () ? SELECTED : UNSELECTED ;
230+ tab .left = x ;
231+ x += TEXT_MARGIN ;
232+ x += tab .textWidth + TEXT_MARGIN ;
233+ tab .right = x ;
234+
235+ // if drawing and not just placing
236+ if (g != null ) {
237+ g .setColor (tabColor [state ]);
238+ if (tab .notification ) {
239+ g .setColor (new Color (192 , 0 , 0 ));
240+ }
241+ drawTab (g , tab .left , tab .right , tab .isFirst (), tab .isLast ());
242+
243+ int textLeft = tab .left + ((tab .right - tab .left ) - tab .textWidth ) / 2 ;
244+ g .setColor (textColor [state ]);
245+ int tabHeight = TAB_BOTTOM - TAB_TOP ;
246+ int baseline = TAB_TOP + (tabHeight + fontAscent ) / 2 ;
247+ g .drawString (tab .name , textLeft , baseline );
248+ }
249+ x += TAB_BETWEEN ;
222250 }
223- x += TAB_BETWEEN ;
224251 }
225- }
226252
227253
228- private void drawTab (Graphics g , int left , int right ,
229- boolean leftNotch , boolean rightNotch ) {
230- Graphics2D g2 = (Graphics2D ) g ;
231- EditorHeader .roundRect (g2 , left , TAB_TOP , right , TAB_BOTTOM ,
232- 0 , 0 ,
233- leftNotch ? CURVE_RADIUS : 0 ,
234- rightNotch ? CURVE_RADIUS : 0 );
235- }
254+ private void drawTab (Graphics g , int left , int right ,
255+ boolean leftNotch , boolean rightNotch ) {
256+ Graphics2D g2 = (Graphics2D ) g ;
257+ EditorHeader .roundRect (g2 , left , TAB_TOP , right , TAB_BOTTOM ,
258+ 0 , 0 ,
259+ leftNotch ? CURVE_RADIUS : 0 ,
260+ rightNotch ? CURVE_RADIUS : 0 );
261+ }
236262
237263
238- public Dimension getPreferredSize () {
239- return new Dimension (300 , HIGH );
240- }
264+ public Dimension getPreferredSize () {
265+ return new Dimension (300 , HIGH );
266+ }
241267
242268
243- public Dimension getMinimumSize () {
244- return getPreferredSize ();
245- }
269+ public Dimension getMinimumSize () {
270+ return getPreferredSize ();
271+ }
246272
247273
248- public Dimension getMaximumSize () {
249- return new Dimension (super .getMaximumSize ().width , HIGH );
274+ public Dimension getMaximumSize () {
275+ return new Dimension (super .getMaximumSize ().width , HIGH );
276+ }
250277 }
251278
252279
253280 // . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
254281
255282
256283 class Tab {
257- String text ;
284+ String name ;
258285 Component comp ;
286+ boolean notification ;
259287
260288 int left ;
261289 int right ;
262290 int textWidth ;
263291
264292 Tab (String name , Component comp ) {
265- this .text = name ;
293+ this .name = name ;
266294 this .comp = comp ;
267295 }
268296
0 commit comments