/*     */ package useful;
/*     */ 
/*     */ import java.awt.BasicStroke;
/*     */ import java.awt.Color;
/*     */ import java.awt.Dimension;
/*     */ import java.awt.Graphics;
/*     */ import java.awt.Graphics2D;
/*     */ import java.awt.event.MouseEvent;
/*     */ import java.util.ArrayList;
/*     */ import javax.swing.BorderFactory;
/*     */ import javax.swing.ButtonModel;
/*     */ import javax.swing.JButton;
/*     */ import javax.swing.JOptionPane;
/*     */ import javax.swing.JTabbedPane;
/*     */ import javax.swing.plaf.basic.BasicButtonUI;
/*     */ import main.ChronoPanel;
/*     */ import main.ChronoWindow;
/*     */ 
/*     */ public class TabButton extends JButton implements java.awt.event.MouseListener
/*     */ {
/*     */   private static final long serialVersionUID = 1L;
/*     */   private ButtonTabComponent comp;
/*     */   
/*     */   public TabButton(ButtonTabComponent comp)
/*     */   {
/*  26 */     int size = 17;
/*  27 */     this.comp = comp;
/*  28 */     setPreferredSize(new Dimension(size, size));
/*     */     
/*  30 */     setUI(new BasicButtonUI());
/*     */     
/*  32 */     setContentAreaFilled(false);
/*     */     
/*  34 */     setFocusable(false);
/*  35 */     setBorder(BorderFactory.createEtchedBorder());
/*  36 */     setBorderPainted(false);
/*     */     
/*     */ 
/*  39 */     addMouseListener(this);
/*  40 */     setRolloverEnabled(true);
/*     */   }
/*     */   
/*     */   protected void paintComponent(Graphics g)
/*     */   {
/*  45 */     super.paintComponent(g);
/*  46 */     Graphics2D g2 = (Graphics2D)g.create();
/*     */     
/*  48 */     if (getModel().isPressed()) {
/*  49 */       g2.translate(1, 1);
/*     */     }
/*  51 */     g2.setStroke(new BasicStroke(2.0F));
/*  52 */     g2.setColor(new Color(50, 50, 50));
/*  53 */     if (getModel().isRollover()) {
/*  54 */       g2.setColor(Color.RED);
/*     */     }
/*  56 */     int delta = 6;
/*  57 */     g2.drawLine(delta, delta, getWidth() - delta, getHeight() - delta);
/*  58 */     g2.drawLine(getWidth() - delta, delta, delta, getHeight() - delta);
/*  59 */     g2.dispose();
/*     */   }
/*     */   
/*     */ 
/*     */ 
/*     */ 
/*     */   public void mouseClicked(MouseEvent arg0) {}
/*     */   
/*     */ 
/*     */ 
/*     */ 
/*     */   public void mouseEntered(MouseEvent arg0) {}
/*     */   
/*     */ 
/*     */ 
/*     */ 
/*     */   public void mouseExited(MouseEvent arg0) {}
/*     */   
/*     */ 
/*     */ 
/*     */ 
/*     */   public void mousePressed(MouseEvent arg0)
/*     */   {
/*  82 */     int i = ChronoWindow.tabs.indexOfTabComponent(this.comp);
/*  83 */     if (i != -1) {
/*  84 */       if (((ChronoPanel)ChronoWindow.chrono.get(i)).modifToSave) {
/*  85 */         int option = JOptionPane.showConfirmDialog(null, "Save chronogram before closing ?", "Closing file", 1, 3);
/*  86 */         if ((option != 2) && (option != -1)) {
/*  87 */           if (option == 0) {
/*  88 */             main.Main.window.save(false, i);
/*     */           }
/*  90 */           close(i);
/*     */         }
/*     */       }
/*     */       else
/*     */       {
/*  95 */         close(i);
/*     */       }
/*     */     }
/*     */   }
/*     */   
/*     */   public void close(int i) {
/* 101 */     ChronoWindow.tabs.remove(i);
/* 102 */     ChronoWindow.chrono.remove(i);
/*     */   }
/*     */   
/*     */   public void mouseReleased(MouseEvent arg0) {}
/*     */ }


