001    // GraphLab Project: http://graphlab.sharif.edu
002    // Copyright (C) 2008 Mathematical Science Department of Sharif University of Technology
003    // Distributed under the terms of the GNU General Public License (GPL): http://www.gnu.org/licenses/
004    
005    package graphlab.ui.components.gsidebar;
006    
007    import graphlab.ui.components.gbody.GBody;
008    
009    import java.awt.*;
010    
011    /**
012     * @author azin azadi
013     */
014    public class GSideBarPanel extends javax.swing.JPanel {
015        private GBody body;
016    
017        /**
018         * Creates new form GSideBarPanel
019         *
020         * @param gBody
021         * @param leftPanel
022         * @param label
023         */
024        public GSideBarPanel(GBody gBody, Component leftPanel, String label) {
025            initComponents();
026            setTitle(label);
027            setBody(gBody);
028            jPanel2.add(leftPanel);
029    //        sidebarWrapper.jPanel2.setLayout(new BorderLayout(0,0));
030            jPanel2.validate();
031    
032        }
033    
034        /**
035         * This method is called from within the constructor to
036         * initialize the form.
037         * WARNING: Do NOT modify this code. The content of this method is
038         * always regenerated by the Form Editor.
039         */
040        private void initComponents() {
041            jPanel1 = new javax.swing.JPanel();
042            jLabel1 = new javax.swing.JLabel();
043            jButton1 = new javax.swing.JButton();
044            jPanel2 = new javax.swing.JPanel();
045    
046            setLayout(new java.awt.BorderLayout());
047    
048            jPanel1.setLayout(new java.awt.BorderLayout());
049    
050            jPanel1.setBackground(new java.awt.Color(242, 204, 128));
051            jPanel1.setBorder(new javax.swing.border.EtchedBorder());
052            jPanel1.setMinimumSize(new java.awt.Dimension(66, 15));
053            jPanel1.setPreferredSize(new java.awt.Dimension(70, 18));
054            jLabel1.setText("Close!");
055            jPanel1.add(jLabel1, java.awt.BorderLayout.CENTER);
056    
057            jButton1.setText("x");
058            jButton1.setBorderPainted(false);
059            jButton1.setContentAreaFilled(false);
060            jButton1.setIconTextGap(1);
061            jButton1.setMargin(new java.awt.Insets(2, 2, 2, 2));
062            jButton1.addActionListener(new java.awt.event.ActionListener() {
063                public void actionPerformed(java.awt.event.ActionEvent evt) {
064                    jButton1ActionPerformed(evt);
065                }
066            });
067            jButton1.addMouseMotionListener(new java.awt.event.MouseMotionAdapter() {
068                public void mouseDragged(java.awt.event.MouseEvent evt) {
069                    jButton1MouseDragged(evt);
070                }
071            });
072    
073            jPanel1.add(jButton1, java.awt.BorderLayout.EAST);
074    
075            add(jPanel1, java.awt.BorderLayout.NORTH);
076    
077            jPanel2.setLayout(new javax.swing.BoxLayout(jPanel2, javax.swing.BoxLayout.X_AXIS));
078    
079            add(jPanel2, java.awt.BorderLayout.CENTER);
080    
081        }
082    
083        private void jButton1MouseDragged(java.awt.event.MouseEvent evt) {
084        }
085    
086    
087        // Variables declaration - do not modify
088        private javax.swing.JButton jButton1;
089        private javax.swing.JLabel jLabel1;
090        private javax.swing.JPanel jPanel1;
091        public javax.swing.JPanel jPanel2;
092        // End of variables declaration
093    
094    
095        private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {
096            body.hideSideBar(jPanel2.getComponent(0), jLabel1.getText());
097        }
098    
099        public void setTitle(String title) {
100            jLabel1.setText(title);
101        }
102    
103        public void setBody(GBody b) {
104            this.body = b;
105        }
106    }