1 33 34 package edu.rice.cs.drjava.ui; 35 36 import javax.swing.*; 37 import java.awt.event.*; 38 import java.awt.*; 39 40 48 public abstract class TabbedPanel extends JPanel { 49 protected boolean _displayed; 51 protected JButton _closeButton; 53 protected JPanel _closePanel; 56 protected JPanel _mainPanel; 58 protected MainFrame _frame; 60 private String _name; 62 63 68 public TabbedPanel(MainFrame frame, String name) { 69 _frame = frame; 70 _name = name; 71 _setUpPanes(); 72 _displayed = false; 73 } 74 75 79 private void _setUpPanes() { 80 this.setFocusCycleRoot(true); 81 this.setLayout(new BorderLayout()); 82 83 _mainPanel = new JPanel(); 84 _closePanel = new JPanel(new BorderLayout()); 85 _closeButton = new CommonCloseButton(_closeListener); 86 _closePanel.add(_closeButton, BorderLayout.NORTH); 87 add(_closePanel, BorderLayout.EAST); 88 add(_mainPanel, BorderLayout.CENTER); 89 } 90 91 92 private final ActionListener _closeListener = 93 new ActionListener() { 94 public void actionPerformed(ActionEvent e) { 95 _close(); 96 } 97 }; 98 99 100 protected void _close() { 101 _displayed = false; 102 _frame.removeTab(this); 103 } 104 105 106 public boolean isDisplayed() { return _displayed; } 107 108 111 public String getName() { 112 return _name; 113 } 114 115 118 public void setDisplayed(boolean displayed) { 119 _displayed = displayed; 120 } 121 122 JPanel getMainPanel() { 123 return _mainPanel; 124 } 125 126 130 public boolean requestFocusInWindow() { 131 super.requestFocusInWindow(); 132 return _mainPanel.requestFocusInWindow(); 133 } 134 } | Popular Tags |