Example usage for java.awt BorderLayout WEST

List of usage examples for java.awt BorderLayout WEST

Introduction

In this page you can find the example usage for java.awt BorderLayout WEST.

Prototype

String WEST

To view the source code for java.awt BorderLayout WEST.

Click Source Link

Document

The west layout constraint (left side of container).

Usage

From source file:view.App.java

private void initGUI() {
    try {//w  w w  . j  a va  2s  .com
        {
            jPanel1 = new JPanel();
            BorderLayout jPanel1Layout = new BorderLayout();
            jPanel1.setLayout(jPanel1Layout);
            getContentPane().add(jPanel1, BorderLayout.CENTER);
            jPanel1.setPreferredSize(new java.awt.Dimension(901, 398));
            {
                jPanel2 = new JPanel();
                BoxLayout jPanel2Layout = new BoxLayout(jPanel2, javax.swing.BoxLayout.Y_AXIS);
                jPanel2.setLayout(jPanel2Layout);
                jPanel1.add(jPanel2, BorderLayout.WEST);
                jPanel2.setPreferredSize(new java.awt.Dimension(292, 446));
                {
                    jPanel5 = new JPanel();
                    jPanel2.add(jPanel5);
                    jPanel5.setPreferredSize(new java.awt.Dimension(292, 109));
                    {
                        {
                            jTextArea1 = new JTextArea();
                            jTextArea1.setWrapStyleWord(true);
                            jTextArea1.setLineWrap(true);
                            DefaultCaret caret = (DefaultCaret) jTextArea1.getCaret();
                            caret.setUpdatePolicy(DefaultCaret.ALWAYS_UPDATE);

                            jTextArea1.addFocusListener(new FocusAdapter() {
                                public void focusGained(FocusEvent evt) {

                                    if (jTable1.getModel().getRowCount() == 0 && !jButton1.isEnabled()) {
                                        jButton1.setEnabled(true);
                                        jTextArea1.setText("");
                                    }

                                }
                            });
                            JScrollPane sp = new JScrollPane();
                            sp.setPreferredSize(new java.awt.Dimension(281, 97));
                            sp.setViewportView(jTextArea1);

                            jPanel5.add(sp, BorderLayout.CENTER);
                        }
                    }

                }
                {
                    jPanel4 = new JPanel();
                    jPanel2.add(jPanel4);
                    FlowLayout jPanel4Layout = new FlowLayout();
                    jPanel4Layout.setAlignment(FlowLayout.RIGHT);
                    jPanel4.setPreferredSize(new java.awt.Dimension(292, 45));
                    jPanel4.setSize(102, 51);
                    jPanel4.setLayout(jPanel4Layout);
                    {
                        jButton1 = new JButton();
                        jPanel4.add(jButton1);
                        jButton1.setText("Get Quotes");
                        jButton1.setSize(100, 50);
                        jButton1.setPreferredSize(new java.awt.Dimension(100, 26));
                        jButton1.addActionListener(new ActionListener() {
                            public void actionPerformed(ActionEvent evt) {
                                //   
                                String tickerStr = jTextArea1.getText();
                                if (tickerStr.equals("") || tickerStr.equals(null)
                                        || tickerStr.equals(" ")) {
                                    jTextArea1.setText(" ");
                                    return;
                                }
                                StringTokenizer tokenizer = new StringTokenizer(tickerStr, " ");
                                String[] tickers = new String[tokenizer.countTokens()];
                                int i = 0;
                                while (tokenizer.hasMoreTokens()) {
                                    tickers[i] = tokenizer.nextToken();
                                    i++;
                                }
                                try {
                                    Controller.getQuotes(tickers);
                                } catch (CloneNotSupportedException e) {
                                    JOptionPane.showMessageDialog(jPanel1, "   ");
                                }
                                jButton1.setEnabled(false);
                            }
                        });
                    }
                }
                {
                    jPanel6 = new JPanel();
                    BorderLayout jPanel6Layout = new BorderLayout();
                    jPanel6.setLayout(jPanel6Layout);
                    jPanel2.add(jPanel6);
                    {
                        jScrollPane1 = new JScrollPane();
                        jPanel6.add(jScrollPane1, BorderLayout.CENTER);
                        jScrollPane1.setPreferredSize(new java.awt.Dimension(292, 341));
                        {
                            TableModel jTable1Model = new DefaultTableModel(null,
                                    new String[] { "", "MA Value", "", "MA Value" });
                            jTable1 = new JTable();

                            jScrollPane1.setViewportView(jTable1);
                            jTable1.setModel(jTable1Model);
                            jTable1.setSelectionMode(ListSelectionModel.SINGLE_INTERVAL_SELECTION);

                        }
                    }
                }
            }
            {
                jPanel3 = new JPanel();
                BorderLayout jPanel3Layout = new BorderLayout();
                jPanel3.setLayout(jPanel3Layout);
                jPanel1.add(jPanel3, BorderLayout.CENTER);
                {
                    //                  chart = ChartFactory.createLineChart(" ", "dates", "correlation ratio", null, 
                    //                        PlotOrientation.VERTICAL, true, true, false);
                    //                  ChartPanel chartPanel = new ChartPanel(chart);
                    //                  chartPanel.setPreferredSize( new java.awt.Dimension( 560 , 367 ) );
                    //                  jPanel3.add(chartPanel);
                }
                {

                }
            }
        }
        this.setSize(966, 531);
        {
            jMenuBar1 = new JMenuBar();
            setJMenuBar(jMenuBar1);
            {
                jMenu3 = new JMenu();
                jMenuBar1.add(jMenu3);
                jMenu3.setText("File");
                {
                    //                  newFileMenuItem = new JMenuItem();
                    //                  jMenu3.add(newFileMenuItem);
                    //                  newFileMenuItem.setText("New");
                    //                  newFileMenuItem.addActionListener(new ActionListener() {
                    //                     public void actionPerformed(ActionEvent evt) {
                    ////                        jTextArea1.setText("");
                    ////                        DefaultTableModel model = (DefaultTableModel)jTable1.getModel();
                    ////                        model.setRowCount(0);
                    ////                        Controller.clearPortfolio();
                    //                     }
                    //                  });
                }
                {
                    jSeparator2 = new JSeparator();
                    jMenu3.add(jSeparator2);
                }
                {
                    exitMenuItem = new JMenuItem();
                    jMenu3.add(exitMenuItem);
                    exitMenuItem.setText("Exit");
                    exitMenuItem.addActionListener(new ActionListener() {
                        public void actionPerformed(ActionEvent evt) {
                            int action = JOptionPane.showConfirmDialog(jPanel1,
                                    "     ?", "Confirm Exit",
                                    JOptionPane.OK_CANCEL_OPTION);

                            if (action == JOptionPane.OK_OPTION)
                                System.exit(0);

                        }
                    });
                }
            }
            {
                jMenu4 = new JMenu();
                jMenuBar1.add(jMenu4);
                jMenu4.setText("Edit");
                {
                    cutMenuItem = new JMenuItem();
                    jMenu4.add(cutMenuItem);
                    cutMenuItem.setText("Cut");
                    cutMenuItem.addActionListener(new ActionListener() {

                        @Override
                        public void actionPerformed(ActionEvent e) {
                            String txt = jTextArea1.getText();
                            StringSelection selection = new StringSelection(txt);
                            Clipboard clp = Toolkit.getDefaultToolkit().getSystemClipboard();
                            clp.setContents(selection, null);
                            jTextArea1.setText("");

                        }
                    });
                }
                {
                    copyMenuItem = new JMenuItem();
                    jMenu4.add(copyMenuItem);
                    copyMenuItem.setText("Copy");
                    copyMenuItem.addActionListener(new ActionListener() {

                        @Override
                        public void actionPerformed(ActionEvent arg0) {
                            String txt = jTextArea1.getText();
                            StringSelection selection = new StringSelection(txt);
                            Clipboard clp = Toolkit.getDefaultToolkit().getSystemClipboard();
                            clp.setContents(selection, null);

                        }
                    });
                }
                {
                    pasteMenuItem = new JMenuItem();
                    jMenu4.add(pasteMenuItem);
                    pasteMenuItem.setText("Paste");
                    pasteMenuItem.addActionListener(new ActionListener() {

                        @Override
                        public void actionPerformed(ActionEvent e) {
                            Clipboard clp = Toolkit.getDefaultToolkit().getSystemClipboard();
                            try {
                                String data = (String) clp.getData(DataFlavor.stringFlavor);
                                jTextArea1.setText(data);
                            } catch (UnsupportedFlavorException e1) {
                                // TODO Auto-generated catch block
                                e1.printStackTrace();
                            } catch (IOException e1) {
                                // TODO Auto-generated catch block
                                e1.printStackTrace();
                            }
                        }
                    });
                }
            }
            {
                jMenu5 = new JMenu();
                jMenuBar1.add(jMenu5);
                jMenu5.setText("Help");
                {
                    helpMenuItem = new JMenuItem();
                    jMenu5.add(helpMenuItem);
                    helpMenuItem.setText("About");
                    helpMenuItem.addActionListener(new ActionListener() {

                        @Override
                        public void actionPerformed(ActionEvent arg0) {
                            JOptionPane.showMessageDialog(jPanel1,
                                    "    .    r.zhumagulov@gmail.com",
                                    "About", JOptionPane.PLAIN_MESSAGE);

                        }
                    });
                }
            }
        }
    } catch (Exception e) {
        e.printStackTrace();
    }
}

From source file:org.gvsig.remotesensing.profiles.gui.LineProfileOptionsPanel.java

/**
 * Constructor/*from   w  w w . ja va 2 s.  co m*/
 * */
public LineProfileOptionsPanel(ProfilePanel mainPanel) {
    super();
    this.mapControl = mainPanel.getMapControl();
    this.mainPanel = mainPanel;
    try {
        this.fLayer = mainPanel.getFlayer().cloneLayer();
    } catch (Exception e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }
    BorderLayout bd = new BorderLayout();
    listener = new LineProfileOptionsListener(this);
    bd.setHgap(1);
    setLayout(bd);
    initialize();
    add(getTable(), BorderLayout.CENTER);
    add(getControlPanel(), BorderLayout.WEST);
    previousTool = mapControl.getCurrentTool();
}

From source file:opendial.gui.utils.DistributionViewer.java

/**
 * Constructs or update the current viewer with the distribution.
 * /*from   www  .j  a  v  a  2  s  . co  m*/
 * @param currentState the updated dialogue state
 */
protected void update(DialogueState currentState) {

    if (!currentState.hasChanceNode(queryVar)) {
        return;
    } else if (lastDistrib != null
            && this.lastDistrib.equals(currentState.getChanceNode(queryVar).getDistrib())) {
        return;
    }
    this.lastDistrib = currentState.queryProb(queryVar);

    Container container = new Container();
    container.setLayout(new BorderLayout());
    container.add(new JLabel("        "), BorderLayout.NORTH);
    container.add(new JLabel("        "), BorderLayout.WEST);
    container.add(new JLabel("        "), BorderLayout.EAST);
    container.add(new JLabel("        "), BorderLayout.SOUTH);

    try {
        IndependentDistribution indepDistrib = currentState.queryProb(queryVar);
        if (indepDistrib instanceof ContinuousDistribution) {
            container.add(generatePanel(indepDistrib.toContinuous()), BorderLayout.CENTER);
        } else {
            container.add(generatePanel(indepDistrib.toDiscrete()), BorderLayout.CENTER);
        }
    } catch (RuntimeException e) {
        log.warning("could not generate distribution viewer: " + e);
    }
    setContentPane(container);
    if (getSize().height == 0 || getSize().width == 0) {
        pack();
        setLocation(new Random().nextInt(500), (new Random()).nextInt(500));
        setVisible(true);
    } else {
        validate();
    }
}

From source file:jmemorize.gui.swing.panels.HistoryChartPanel.java

private JPanel buildChartChooser() {
    JComboBox comboBox = new JComboBox(new String[] { Localization.get(LC.HISTORY_RECENT),
            Localization.get(LC.HISTORY_BY_DATE), Localization.get(LC.HISTORY_BY_WEEK),
            Localization.get(LC.HISTORY_BY_MONTH), Localization.get(LC.HISTORY_BY_YEAR), });

    comboBox.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            JComboBox box = (JComboBox) e.getSource();
            m_mode = box.getSelectedIndex();
            updateDataSet();/*  w w  w.  ja  v a2s  .  com*/
        }
    });

    JPanel panel = new JPanel(new BorderLayout());
    panel.add(comboBox, BorderLayout.WEST);

    return panel;
}

From source file:org.codinjutsu.tools.nosql.couchbase.view.CouchbasePanel.java

private void initToolbar() {
    toolBarPanel.setLayout(new BorderLayout());

    rowLimitField.setColumns(5);/*from   w  w  w.  jav  a2  s.c  om*/
    rowLimitField.setDocument(new NumberDocument());
    rowLimitField.setText("100");

    JPanel rowLimitPanel = new NonOpaquePanel();
    rowLimitPanel.add(new JLabel("Row limit:"), BorderLayout.WEST);
    rowLimitPanel.add(rowLimitField, BorderLayout.CENTER);
    rowLimitPanel.add(Box.createHorizontalStrut(5), BorderLayout.EAST);
    toolBarPanel.add(rowLimitPanel, BorderLayout.WEST);

    addCommonsActions();
}

From source file:opendial.gui.stateviewer.DistributionViewer.java

/**
 * Constructs or update the current viewer with the distribution.
 * //from w  w  w  . j ava  2s .c  om
 * @param currentState the updated dialogue state
 */
protected void update(DialogueState currentState) {

    if (!currentState.hasChanceNode(queryVar)) {
        return;
    } else if (lastDistrib != null
            && this.lastDistrib.equals(currentState.getChanceNode(queryVar).getDistrib())) {
        return;
    }
    this.lastDistrib = currentState.queryProb(queryVar);

    Container container = new Container();
    container.setLayout(new BorderLayout());
    container.add(new JLabel("        "), BorderLayout.NORTH);
    container.add(new JLabel("        "), BorderLayout.WEST);
    container.add(new JLabel("        "), BorderLayout.EAST);
    container.add(new JLabel("        "), BorderLayout.SOUTH);

    try {
        IndependentProbDistribution indepDistrib = currentState.queryProb(queryVar);
        if (indepDistrib instanceof ContinuousDistribution) {
            container.add(generatePanel(indepDistrib.toContinuous()), BorderLayout.CENTER);
        } else {
            container.add(generatePanel(indepDistrib.toDiscrete()), BorderLayout.CENTER);
        }
    } catch (DialException e) {
        log.warning("could not generate distribution viewer: " + e);
    }
    setContentPane(container);
    if (getSize().height == 0 || getSize().width == 0) {
        pack();
        setLocation(new Random().nextInt(500), (new Random()).nextInt(500));
        setVisible(true);
    } else {
        validate();
    }
}

From source file:analysis.postRun.PostRunWindow.java

/**
 * Constructor - creates window and tabs.
 *//*  w w w  . j  av  a  2 s  .  c o  m*/
private PostRunWindow() {
    dcLegend = false;
    stats = false;
    readStats = false;
    save = false;

    // Create frame
    MainFrame = new JFrame("Cloudsim Post-Run Analysis");
    MainFrame.setSize(1150, 768);
    MainFrame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
    //MainFrame.addComponentListener(this);

    // Create panel
    MainPanel = new JPanel();
    MainPanel.setLayout(new BorderLayout());
    MainFrame.add(MainPanel, BorderLayout.CENTER);

    // Create button panel
    ButtonPanel = new JPanel();
    ButtonPanel.setLayout(new BorderLayout());
    MainFrame.add(ButtonPanel, BorderLayout.NORTH);

    // Create "change log" button
    JButton fileButton = new JButton("Change log");
    fileButton.addActionListener(this);
    ButtonPanel.add(fileButton, BorderLayout.WEST);

    // Create "Compare multiple logs" button
    JButton compButton = new JButton("Compare multiple logs");
    compButton.addActionListener(this);
    ButtonPanel.add(compButton, BorderLayout.CENTER);

    // Create "Save Charts" button
    JButton saveButton = new JButton("Save Charts");
    saveButton.addActionListener(this);
    ButtonPanel.add(saveButton, BorderLayout.EAST);

    // Find out which log file to look at & load the data
    failureSet = new DefaultXYDataset();
    cpuSet = new DefaultXYDataset();
    servSet = new DefaultXYDataset();
    costSet = new DefaultXYDataset();

    chooseFile1();
    //getFileName();
    getData(currFile);

    // Create tabs
    tabbedPane = new JTabbedPane();
    failureTab(true);
    cpuTab(true);
    servTab(true);
    costTab(true);
    consistencyTab(true);
    tabbedPane.setSelectedIndex(0);

    // Add + show window
    MainPanel.add(tabbedPane, BorderLayout.CENTER);
    MainFrame.add(MainPanel, BorderLayout.CENTER);
    MainFrame.add(ButtonPanel, BorderLayout.NORTH);
    MainFrame.setLocationByPlatform(true);
    MainFrame.setVisible(true);
}

From source file:au.org.ala.delta.intkey.ui.MultiStateInputDialog.java

/**
 * ctor//from  ww  w  . ja  v  a2 s .c  om
 * 
 * @param owner
 *            Owner frame of dialog
 * @param ch
 *            the character whose states are being set
 * @param initialSelectedStates
 *            initial states that should be selected in the dialog. In
 *            general this should be any states already set for the
 *            character. In the case that this is a controlling character
 *            being set before its dependent character, all states that make
 *            the dependent character applicable should be selected.
 * @param dependentCharacter
 *            the dependent character - if the dialog is being used to set a
 *            controlling character before its dependent character, this
 *            argument should be a reference to the dependent character. In
 *            all other cases it should be null.
 * @param imageSettings
 *            image settings
 * @param displayNumbering
 *            true if numbering should be displayed
 * @param enableImagesButton
 *            the if the images button should be enabled
 * @param imagesStartScaled
 *            true if images should start scaled.
 */
public MultiStateInputDialog(Frame owner, MultiStateCharacter ch, Set<Integer> initialSelectedStates,
        au.org.ala.delta.model.Character dependentCharacter, ImageSettings imageSettings,
        boolean displayNumbering, boolean enableImagesButton, boolean imagesStartScaled, boolean advancedMode) {
    super(owner, ch, imageSettings, displayNumbering, enableImagesButton, imagesStartScaled, advancedMode);

    ResourceMap resourceMap = Application.getInstance().getContext()
            .getResourceMap(MultiStateInputDialog.class);
    resourceMap.injectFields(this);

    setTitle(title);
    setPreferredSize(new Dimension(600, 350));

    if (dependentCharacter != null) {
        _pnlControllingCharacterMessage = new JPanel();
        _pnlControllingCharacterMessage.setFocusable(false);
        _pnlControllingCharacterMessage.setBorder(new EmptyBorder(5, 0, 0, 0));
        _pnlMain.add(_pnlControllingCharacterMessage, BorderLayout.SOUTH);
        _pnlControllingCharacterMessage.setLayout(new BorderLayout(0, 0));

        _lblWarningIcon = new JLabel("");
        _lblWarningIcon.setFocusable(false);
        _lblWarningIcon.setIcon(UIManager.getIcon("OptionPane.warningIcon"));
        _pnlControllingCharacterMessage.add(_lblWarningIcon, BorderLayout.WEST);

        _txtControllingCharacterMessage = new JTextArea();
        _txtControllingCharacterMessage.setText(MessageFormat.format(setControllingCharacterMessage,
                _formatter.formatCharacterDescription(dependentCharacter),
                _formatter.formatCharacterDescription(ch)));
        _txtControllingCharacterMessage.setFocusable(false);
        _txtControllingCharacterMessage.setBorder(new EmptyBorder(0, 5, 0, 0));
        _txtControllingCharacterMessage.setEditable(false);
        _pnlControllingCharacterMessage.add(_txtControllingCharacterMessage);
        _txtControllingCharacterMessage.setWrapStyleWord(true);
        _txtControllingCharacterMessage.setFont(UIManager.getFont("Button.font"));
        _txtControllingCharacterMessage.setLineWrap(true);
        _txtControllingCharacterMessage.setBackground(SystemColor.control);
    }

    _scrollPane = new JScrollPane();
    _pnlMain.add(_scrollPane, BorderLayout.CENTER);

    _list = new JList();
    _scrollPane.setViewportView(_list);

    _listModel = new DefaultListModel();
    for (int i = 0; i < ch.getNumberOfStates(); i++) {
        _listModel.addElement(_formatter.formatState(ch, i + 1));
    }

    _list.setModel(_listModel);

    _list.addMouseListener(new MouseAdapter() {

        @Override
        public void mouseClicked(MouseEvent e) {
            if (e.getClickCount() > 1) {
                // Treat double click on a list item as the ok button being
                // pressed.
                _okPressed = true;
                handleBtnOKClicked();
            }
        }

    });

    // Select the list items that correspond to the initial selected states.
    if (initialSelectedStates != null) {
        List<Integer> listIndiciesToSelect = new ArrayList<Integer>();
        for (int stateNumber : new ArrayList<Integer>(initialSelectedStates)) {
            listIndiciesToSelect.add(stateNumber - 1);
        }

        Integer[] wrappedPrimitivesList = listIndiciesToSelect
                .toArray(new Integer[initialSelectedStates.size()]);
        _list.setSelectedIndices(ArrayUtils.toPrimitive(wrappedPrimitivesList));
    }

    _inputData = new HashSet<Integer>();

}

From source file:es.uvigo.ei.sing.adops.views.TextFileViewer.java

public TextFileViewer(final File file) {
    super(new BorderLayout());

    this.file = file;

    // TEXT AREA//  ww w.j  av  a  2s  .c om
    this.textArea = new JTextArea(TextFileViewer.loadFile(file));
    this.textArea.setFont(new Font(Font.MONOSPACED, Font.PLAIN, this.textArea.getFont().getSize()));
    this.textArea.setLineWrap(true);
    this.textArea.setWrapStyleWord(true);
    this.textArea.setEditable(false);

    this.highlightPatiner = new DefaultHighlighter.DefaultHighlightPainter(Color.YELLOW);

    // OPTIONS PANEL
    final JPanel panelOptions = new JPanel(new BorderLayout());
    final JPanel panelOptionsEast = new JPanel(new FlowLayout());
    final JPanel panelOptionsWest = new JPanel(new FlowLayout());
    final JCheckBox chkLineWrap = new JCheckBox("Line wrap", true);
    final JButton btnChangeFont = new JButton("Change Font");

    final JLabel lblSearch = new JLabel("Search");
    this.txtSearch = new JTextField();
    this.chkRegularExpression = new JCheckBox("Reg. exp.", true);
    final JButton btnSearch = new JButton("Search");
    final JButton btnClear = new JButton("Clear");
    this.txtSearch.setColumns(12);
    // this.txtSearch.setOpaque(true);

    panelOptionsEast.add(btnChangeFont);
    panelOptionsEast.add(chkLineWrap);
    panelOptionsWest.add(lblSearch);
    panelOptionsWest.add(this.txtSearch);
    panelOptionsWest.add(this.chkRegularExpression);
    panelOptionsWest.add(btnSearch);
    panelOptionsWest.add(btnClear);

    if (FastaUtils.isFasta(file)) {
        panelOptionsWest.add(new JSeparator());

        final JButton btnExport = new JButton("Export...");

        panelOptionsWest.add(btnExport);

        btnExport.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {
                try {
                    new ExportDialog(file).setVisible(true);
                } catch (Exception e1) {
                    JOptionPane.showMessageDialog(Workbench.getInstance().getMainFrame(),
                            "Error reading fasta file: " + e1.getMessage(), "Export Error",
                            JOptionPane.ERROR_MESSAGE);
                }
            }
        });
    }

    panelOptions.add(panelOptionsWest, BorderLayout.WEST);
    panelOptions.add(panelOptionsEast, BorderLayout.EAST);

    this.fontChooser = new JFontChooser();

    this.add(new JScrollPane(this.textArea), BorderLayout.CENTER);
    this.add(panelOptions, BorderLayout.NORTH);

    chkLineWrap.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            textArea.setLineWrap(chkLineWrap.isSelected());
        }
    });

    btnChangeFont.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            changeFont();
        }
    });

    this.textArea.getDocument().addDocumentListener(new DocumentListener() {
        @Override
        public void removeUpdate(DocumentEvent e) {
            TextFileViewer.this.wasModified = true;
        }

        @Override
        public void insertUpdate(DocumentEvent e) {
            TextFileViewer.this.wasModified = true;
        }

        @Override
        public void changedUpdate(DocumentEvent e) {
            TextFileViewer.this.wasModified = true;
        }
    });

    this.textArea.addFocusListener(new FocusAdapter() {
        @Override
        public void focusLost(FocusEvent e) {
            if (TextFileViewer.this.wasModified) {
                try {
                    FileUtils.write(TextFileViewer.this.file, TextFileViewer.this.textArea.getText());
                    TextFileViewer.this.wasModified = false;
                } catch (IOException e1) {
                    e1.printStackTrace();
                }
            }
        }
    });

    final ActionListener alSearch = new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            updateSearch();
        }
    };
    txtSearch.addActionListener(alSearch);
    btnSearch.addActionListener(alSearch);

    btnClear.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            clearSearch();
        }
    });
}

From source file:edu.purdue.cc.bionet.ui.CorrelationDetailPanel.java

/**
 * Constructs a new CorrelationDetailPanel
 * //from   w w w.  ja v a2  s.c  o m
 * @param correlation The Correlation to display information about.
 * @param range The valid range for correlations displayed in this window.
 * @param detailWindow The parent window of this panel.
 */
public CorrelationDetailPanel(Correlation correlation, Range range, DetailWindow detailWindow,
        int correlationMethod) {
    super(new BorderLayout());
    this.correlation = correlation;
    this.correlationRange = range.clone();
    this.detailWindow = detailWindow;
    this.correlationMethod = correlationMethod;
    this.correlations = this.detailWindow.getCorrelations();

    String buttonText = Settings.getLanguage().get("Show Correlated");
    this.firstMoleculeButton = new JButton(buttonText);
    this.secondMoleculeButton = new JButton(buttonText);

    this.firstMoleculeTable = DataTable.getMoleculeTable(correlations, correlation.getFirst());
    this.secondMoleculeTable = DataTable.getMoleculeTable(correlations, correlation.getSecond());
    JPanel topMoleculePanel = new JPanel(new BorderLayout());
    JPanel bottomMoleculePanel = new JPanel(new BorderLayout());
    JScrollPane firstMoleculeScrollPane = new JScrollPane(this.firstMoleculeTable);
    JScrollPane secondMoleculeScrollPane = new JScrollPane(this.secondMoleculeTable);
    topMoleculePanel.add(firstMoleculeScrollPane, BorderLayout.CENTER);
    topMoleculePanel.add(this.firstMoleculeButton, BorderLayout.SOUTH);
    bottomMoleculePanel.add(secondMoleculeScrollPane, BorderLayout.CENTER);
    bottomMoleculePanel.add(this.secondMoleculeButton, BorderLayout.SOUTH);
    this.firstMoleculeButton.addActionListener(this);
    this.secondMoleculeButton.addActionListener(this);

    JPanel moleculePane = new JPanel(new GridLayout(2, 1));
    moleculePane.add(topMoleculePanel);
    moleculePane.add(bottomMoleculePanel);
    JPanel moleculePanel = new JPanel(new BorderLayout());
    moleculePanel.add(moleculePane, BorderLayout.CENTER);
    JPanel graphPanel = new ScatterPlot(correlation, correlations);
    JPanel infoPanel = new InfoPanel(this.correlation.getValue(this.correlationMethod),
            ((ScatterPlot) graphPanel).getSamples().size());

    JPanel mainPanel = new JPanel(new BorderLayout());
    mainPanel.add(moleculePanel, BorderLayout.WEST);
    mainPanel.add(graphPanel, BorderLayout.CENTER);
    mainPanel.add(infoPanel, BorderLayout.EAST);
    moleculePanel.setPreferredSize(new Dimension(200, 400));
    infoPanel.setPreferredSize(new Dimension(300, 400));
    this.add(mainPanel, BorderLayout.CENTER);

}