Example usage for javax.swing Box add

List of usage examples for javax.swing Box add

Introduction

In this page you can find the example usage for javax.swing Box add.

Prototype

public Component add(Component comp) 

Source Link

Document

Appends the specified component to the end of this container.

Usage

From source file:net.sf.maltcms.chromaui.msviewer.ui.panel.MassSpectrumPanel.java

public void addIdentification() {
    // Create a custom NotifyDescriptor, specify the panel instance as a parameter + other params
    NotifyDescriptor nd = new NotifyDescriptor(ddp, // instance of your panel
            "Select Databases and Settings", // title of the dialog
            NotifyDescriptor.OK_CANCEL_OPTION, // it is Yes/No dialog ...
            NotifyDescriptor.PLAIN_MESSAGE, // ... of a question type => a question mark icon
            null, // we have specified YES_NO_OPTION => can be null, options specified by L&F,
            // otherwise specify options as:
            //     new Object[] { NotifyDescriptor.YES_OPTION, ... etc. },
            NotifyDescriptor.OK_OPTION // default option is "Yes"
    );/*  w w  w .  j ava2s .  c  om*/
    ddp.updateView();
    // let's display the dialog now...
    if (DialogDisplayer.getDefault().notify(nd) == NotifyDescriptor.OK_OPTION) {
        if (ddp.getSelectedDatabases().isEmpty()) {
            return;
        }
        Runnable r = new Runnable() {
            @Override
            public void run() {
                IQuery<IScan> query = Lookup.getDefault().lookup(IQueryFactory.class).createQuery(
                        ddp.getSelectedDatabases(), ddp.getRetentionIndexCalculator(),
                        ddp.getSelectedMetabolitePredicate(), ddp.getMatchThreshold(), ddp.getMaxNumberOfHits(),
                        ddp.getRIWindow(), seriesToScan.values().toArray(new IScan[seriesToScan.size()]));
                try {
                    List<QueryResultList<IScan>> results = query.call();
                    Box outerBox = Box.createVerticalBox();
                    for (QueryResultList<IScan> mdqrl : results) {
                        for (IQueryResult<IScan> result : mdqrl) {
                            Box vbox = Box.createVerticalBox();
                            JLabel label = new JLabel("Results for scan " + result.getScan().getScanIndex()
                                    + " at " + result.getScan().getScanAcquisitionTime() + " with ri: "
                                    + result.getRetentionIndex());
                            JLabel dbLabel = new JLabel(
                                    "DB: " + result.getDatabaseDescriptor().getResourceLocation());
                            vbox.add(label);
                            vbox.add(dbLabel);
                            JLabel parameterLabel = new JLabel("Minimum Score: " + ddp.getMatchThreshold()
                                    + "; Maximum #Hits Returned: " + ddp.getMaxNumberOfHits());
                            vbox.add(parameterLabel);
                            DefaultTableModel dlm = new DefaultTableModel(
                                    new String[] { "Score", "RI", "Name", "ID", "MW", "Formula", "Max Mass" },
                                    0);
                            for (IMetabolite metabolite : result.getMetabolites()) {
                                String name = metabolite.getName();
                                if (name.lastIndexOf("_") != -1) {
                                    name = name.substring(name.lastIndexOf("_") + 1);
                                }
                                dlm.addRow(new Object[] { result.getScoreFor(metabolite),
                                        result.getRiFor(metabolite), name, metabolite.getID(),
                                        metabolite.getMW(), metabolite.getFormula(), metabolite.getMaxMass() });
                            }
                            JTable jl = new JTable(dlm);
                            JScrollPane resultScrollPane = new JScrollPane(jl);
                            jl.setAutoCreateRowSorter(true);
                            jl.setUpdateSelectionOnSort(true);
                            vbox.add(resultScrollPane);
                            outerBox.add(vbox);
                            outerBox.add(Box.createVerticalStrut(10));
                        }
                    }
                    JScrollPane jsp = new JScrollPane(outerBox);
                    NotifyDescriptor nd = new NotifyDescriptor(jsp, // instance of your panel
                            "Database Search Results", // title of the dialog
                            NotifyDescriptor.OK_CANCEL_OPTION, // it is Yes/No dialog ...
                            NotifyDescriptor.PLAIN_MESSAGE, // ... of a question type => a question mark icon
                            null, // we have specified YES_NO_OPTION => can be null, options specified by L&F,
                            // otherwise specify options as:
                            //     new Object[] { NotifyDescriptor.YES_OPTION, ... etc. },
                            NotifyDescriptor.OK_OPTION // default option is "Yes"
                    );
                    if (DialogDisplayer.getDefault().notify(nd) == NotifyDescriptor.OK_OPTION) {
                    }
                    //DBConnectionManager.close();
                } catch (Exception ex) {
                    Exceptions.printStackTrace(ex);
                }
            }
        };
        RequestProcessor.getDefault().post(r);

    }
}

From source file:net.sf.firemox.DeckBuilder.java

/**
 * Creates new form DeckBuilder/*from  w  w  w  .  jav  a  2 s . c o m*/
 */
private DeckBuilder() {
    super("DeckBuilder");
    form = this;
    timerPanel = new TimerGlassPane();
    cardLoader = new CardLoader(timerPanel);
    timer = new Timer(200, cardLoader);
    setGlassPane(timerPanel);
    try {
        setIconImage(Picture.loadImage(IdConst.IMAGES_DIR + "deckbuilder.gif"));
    } catch (Exception e) {
        // IGNORING
    }

    // Load settings
    loadSettings();

    // Initialize components
    final JMenuItem newItem = UIHelper.buildMenu("menu_db_new", 'n', this);
    newItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_N, InputEvent.CTRL_MASK));

    final JMenuItem loadItem = UIHelper.buildMenu("menu_db_load", 'o', this);
    loadItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_O, InputEvent.CTRL_MASK));

    final JMenuItem saveAsItem = UIHelper.buildMenu("menu_db_saveas", 'a', this);
    saveAsItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_F12, 0));

    final JMenuItem saveItem = UIHelper.buildMenu("menu_db_save", 's', this);
    saveItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_S, InputEvent.CTRL_MASK));

    final JMenuItem quitItem = UIHelper.buildMenu("menu_db_exit", this);
    quitItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_F4, InputEvent.ALT_MASK));

    final JMenuItem deckConstraintsItem = UIHelper.buildMenu("menu_db_constraints", 'c', this);
    deckConstraintsItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_F3, 0));

    final JMenuItem aboutItem = UIHelper.buildMenu("menu_help_about", 'a', this);
    aboutItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_F1, InputEvent.SHIFT_MASK));

    final JMenuItem convertDCK = UIHelper.buildMenu("menu_convert_DCK_MP", this);

    final JMenu mainMenu = UIHelper.buildMenu("menu_file");
    mainMenu.add(newItem);
    mainMenu.add(loadItem);
    mainMenu.add(saveAsItem);
    mainMenu.add(saveItem);
    mainMenu.add(new JSeparator());
    mainMenu.add(quitItem);

    super.optionMenu = new JMenu("Options");

    final JMenu convertMenu = UIHelper.buildMenu("menu_convert");
    convertMenu.add(convertDCK);

    final JMenuItem helpItem = UIHelper.buildMenu("menu_help_help", 'h', this);
    helpItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_F1, 0));

    final JMenu helpMenu = new JMenu("?");
    helpMenu.add(helpItem);
    helpMenu.add(deckConstraintsItem);
    helpMenu.add(aboutItem);

    final JMenuBar menuBar = new JMenuBar();
    menuBar.add(mainMenu);
    initAbstractMenu();
    menuBar.add(optionMenu);
    menuBar.add(convertMenu);
    menuBar.add(helpMenu);
    setJMenuBar(menuBar);
    addWindowListener(this);

    // Build the panel containing amount of available cards
    final JLabel amountLeft = new JLabel("<html>0/?", SwingConstants.RIGHT);

    // Build the left list
    allListModel = new MListModel<MCardCompare>(amountLeft, false);
    leftList = new ThreadSafeJList(allListModel);
    leftList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    leftList.setLayoutOrientation(JList.VERTICAL);
    leftList.getSelectionModel().addListSelectionListener(this);
    leftList.addMouseListener(this);
    leftList.setVisibleRowCount(10);

    // Initialize the text field containing the amount to add
    addQtyTxt = new JTextField("1");

    // Build the "Add" button
    addButton = new JButton(LanguageManager.getString("db_add"));
    addButton.setMnemonic('a');
    addButton.setEnabled(false);

    // Build the panel containing : "Add" amount and "Add" button
    final Box addPanel = Box.createHorizontalBox();
    addPanel.add(addButton);
    addPanel.add(addQtyTxt);
    addPanel.setMaximumSize(new Dimension(32010, 26));

    // Build the panel containing the selected card name
    cardNameTxt = new JTextField();
    new HireListener(cardNameTxt, addButton, this, leftList);

    final JLabel searchLabel = new JLabel(LanguageManager.getString("db_search") + " : ");
    searchLabel.setLabelFor(cardNameTxt);

    // Build the panel containing search label and card name text field
    final Box searchPanel = Box.createHorizontalBox();
    searchPanel.add(searchLabel);
    searchPanel.add(cardNameTxt);
    searchPanel.setMaximumSize(new Dimension(32010, 26));

    listScrollerLeft = new JScrollPane(leftList);
    MToolKit.addOverlay(listScrollerLeft);

    // Build the left panel containing : list, available amount, "Add" panel
    final JPanel srcPanel = new JPanel(null);
    srcPanel.add(searchPanel);
    srcPanel.add(listScrollerLeft);
    srcPanel.add(amountLeft);
    srcPanel.add(addPanel);
    srcPanel.setMinimumSize(new Dimension(220, 200));
    srcPanel.setLayout(new BoxLayout(srcPanel, BoxLayout.Y_AXIS));

    // Initialize constraints
    constraintsChecker = new ConstraintsChecker();
    constraintsChecker.setBorder(new EtchedBorder());
    final JScrollPane constraintsCheckerScroll = new JScrollPane(constraintsChecker);
    MToolKit.addOverlay(constraintsCheckerScroll);

    // create a pane with the oracle text for the present card
    oracleText = new JLabel();
    oracleText.setPreferredSize(new Dimension(180, 200));
    oracleText.setVerticalAlignment(SwingConstants.TOP);

    final JScrollPane oracle = new JScrollPane(oracleText, ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED,
            ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);
    MToolKit.addOverlay(oracle);

    // build some Pie Charts and a panel to display it
    initSets();
    datasets = new ChartSets();
    final JTabbedPane tabbedPane = new JTabbedPane();
    for (ChartFilter filter : ChartFilter.values()) {
        final Dataset dataSet = filter.createDataSet(this);
        final JFreeChart chart = new JFreeChart(null, null,
                filter.createPlot(dataSet, painterMapper.get(filter)), false);
        datasets.addDataSet(filter, dataSet);
        ChartPanel pieChartPanel = new ChartPanel(chart, true);
        tabbedPane.add(pieChartPanel, filter.getTitle());
    }
    // add the Constraints scroll panel and Oracle text Pane to the tabbedPane
    tabbedPane.add(constraintsCheckerScroll, LanguageManager.getString("db_constraints"));
    tabbedPane.add(oracle, LanguageManager.getString("db_text"));
    tabbedPane.setSelectedComponent(oracle);

    // The toollBar for color filtering
    toolBar = new JToolBar();
    toolBar.setFloatable(false);
    final JButton clearButton = UIHelper.buildButton("clear");
    clearButton.addActionListener(this);
    toolBar.add(clearButton);
    final JToggleButton toggleColorlessButton = new JToggleButton(
            UIHelper.getTbsIcon("mana/colorless/small/" + MdbLoader.unknownSmlMana), true);
    toggleColorlessButton.setActionCommand("0");
    toggleColorlessButton.addActionListener(this);
    toolBar.add(toggleColorlessButton);
    for (int index = 1; index < IdCardColors.CARD_COLOR_NAMES.length; index++) {
        final JToggleButton toggleButton = new JToggleButton(
                UIHelper.getTbsIcon("mana/colored/small/" + MdbLoader.coloredSmlManas[index]), true);
        toggleButton.setActionCommand(String.valueOf(index));
        toggleButton.addActionListener(this);
        toolBar.add(toggleButton);
    }

    // sorted card type combobox creation
    final List<String> idCards = new ArrayList<String>(Arrays.asList(CardFactory.exportedIdCardNames));
    Collections.sort(idCards);
    final Object[] cardTypes = ArrayUtils.addAll(new String[] { LanguageManager.getString("db_types.any") },
            idCards.toArray());
    idCardComboBox = new JComboBox(cardTypes);
    idCardComboBox.setSelectedIndex(0);
    idCardComboBox.addActionListener(this);
    idCardComboBox.setActionCommand("cardTypeFilter");

    // sorted card properties combobox creation
    final List<String> properties = new ArrayList<String>(
            CardFactory.getPropertiesName(DeckConstraints.getMinProperty(), DeckConstraints.getMaxProperty()));
    Collections.sort(properties);
    final Object[] cardProperties = ArrayUtils
            .addAll(new String[] { LanguageManager.getString("db_properties.any") }, properties.toArray());
    propertiesComboBox = new JComboBox(cardProperties);
    propertiesComboBox.setSelectedIndex(0);
    propertiesComboBox.addActionListener(this);
    propertiesComboBox.setActionCommand("propertyFilter");

    final JLabel colors = new JLabel(" " + LanguageManager.getString("colors") + " : ");
    final JLabel types = new JLabel(" " + LanguageManager.getString("types") + " : ");
    final JLabel property = new JLabel(" " + LanguageManager.getString("properties") + " : ");

    // filter Panel with colors toolBar and card type combobox
    final Box filterPanel = Box.createHorizontalBox();
    filterPanel.add(colors);
    filterPanel.add(toolBar);
    filterPanel.add(types);
    filterPanel.add(idCardComboBox);
    filterPanel.add(property);
    filterPanel.add(propertiesComboBox);

    getContentPane().add(filterPanel, BorderLayout.NORTH);

    // Destination section :

    // Build the panel containing amount of available cards
    final JLabel rightAmount = new JLabel("0/?", SwingConstants.RIGHT);
    rightAmount.setMaximumSize(new Dimension(220, 26));

    // Build the right list
    rightListModel = new MCardTableModel(new MListModel<MCardCompare>(rightAmount, true));
    rightListModel.addTableModelListener(this);
    rightList = new JTable(rightListModel);
    rightList.setShowGrid(false);
    rightList.setTableHeader(null);
    rightList.getSelectionModel().addListSelectionListener(this);
    rightList.getColumnModel().getColumn(0).setMaxWidth(25);
    rightList.setSelectionMode(ListSelectionModel.SINGLE_INTERVAL_SELECTION);

    // Build the panel containing the selected deck
    deckNameTxt = new JTextField("loading...");
    deckNameTxt.setEditable(false);
    deckNameTxt.setBorder(null);
    final JLabel deckLabel = new JLabel(LanguageManager.getString("db_deck") + " : ");
    deckLabel.setLabelFor(deckNameTxt);
    final Box deckNamePanel = Box.createHorizontalBox();
    deckNamePanel.add(deckLabel);
    deckNamePanel.add(deckNameTxt);
    deckNamePanel.setMaximumSize(new Dimension(220, 26));

    // Initialize the text field containing the amount to remove
    removeQtyTxt = new JTextField("1");

    // Build the "Remove" button
    removeButton = new JButton(LanguageManager.getString("db_remove"));
    removeButton.setMnemonic('r');
    removeButton.addMouseListener(this);
    removeButton.setEnabled(false);

    // Build the panel containing : "Remove" amount and "Remove" button
    final Box removePanel = Box.createHorizontalBox();
    removePanel.add(removeButton);
    removePanel.add(removeQtyTxt);
    removePanel.setMaximumSize(new Dimension(220, 26));

    // Build the right panel containing : list, available amount, constraints
    final JScrollPane deskListScroller = new JScrollPane(rightList);
    MToolKit.addOverlay(deskListScroller);
    deskListScroller.setBorder(BorderFactory.createLineBorder(Color.GRAY));
    deskListScroller.setMinimumSize(new Dimension(220, 200));
    deskListScroller.setMaximumSize(new Dimension(220, 32000));

    final Box destPanel = Box.createVerticalBox();
    destPanel.add(deckNamePanel);
    destPanel.add(deskListScroller);
    destPanel.add(rightAmount);
    destPanel.add(removePanel);
    destPanel.setMinimumSize(new Dimension(220, 200));
    destPanel.setMaximumSize(new Dimension(220, 32000));

    // Build the panel containing the name of card in picture
    cardPictureNameTxt = new JLabel("<html><i>no selected card</i>");
    final Box cardPictureNamePanel = Box.createHorizontalBox();
    cardPictureNamePanel.add(cardPictureNameTxt);
    cardPictureNamePanel.setMaximumSize(new Dimension(32010, 26));

    // Group the detail panels
    final JPanel viewCard = new JPanel(null);
    viewCard.add(cardPictureNamePanel);
    viewCard.add(CardView.getInstance());
    viewCard.add(tabbedPane);
    viewCard.setLayout(new BoxLayout(viewCard, BoxLayout.Y_AXIS));

    final Box mainPanel = Box.createHorizontalBox();
    mainPanel.add(destPanel);
    mainPanel.add(viewCard);

    // Add the main panel
    getContentPane().add(srcPanel, BorderLayout.WEST);
    getContentPane().add(mainPanel, BorderLayout.CENTER);

    // Size this frame
    getRootPane().setPreferredSize(new Dimension(WINDOW_WIDTH, WINDOW_HEIGHT));
    getRootPane().setMinimumSize(getRootPane().getPreferredSize());
    pack();
}

From source file:metdemo.Finance.SHNetworks.java

/**
 * //  ww w.  j a va2 s .com
 * @param jp
 * @param usersarray
 * @param viphm_hashmap
 */
protected void addBottomControls(final JPanel jp, String[] usersarray) {
    // create the control panel which will hold settings and picked list
    final JPanel control_panel = new JPanel();
    jp.add(control_panel, BorderLayout.SOUTH);
    control_panel.setLayout(new BorderLayout());

    // create the settings panel which will hold all of the settings
    Box settings_box = Box.createVerticalBox();
    settings_box.setBorder(BorderFactory.createTitledBorder("Display Settings"));
    control_panel.add(settings_box, BorderLayout.NORTH);
    JPanel settings_panel = new JPanel(new FlowLayout(FlowLayout.LEFT, 10, 10));

    // add the zoom controls to the settings panel
    JButton plus = new JButton("+");
    plus.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            // call listener in GraphMouse instead of manipulating vv scale
            // directly
            // this is so the crossover from zoom to scale works with the
            // buttons
            // as well as with the mouse wheel
            Dimension d = m_visualizationview.getSize();
            m_graphmouse.mouseWheelMoved(
                    new MouseWheelEvent(m_visualizationview, MouseEvent.MOUSE_WHEEL, System.currentTimeMillis(),
                            0, d.width / 2, d.height / 2, 1, false, MouseWheelEvent.WHEEL_UNIT_SCROLL, 1, 1));
        }
    });
    JButton minus = new JButton(" - ");
    minus.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            // call listener in GraphMouse instead of manipulating vv scale
            // directly
            // this is so the crossover from zoom to scale works with the
            // buttons
            // as well as with the mouse wheel
            Dimension d = m_visualizationview.getSize();
            m_graphmouse.mouseWheelMoved(
                    new MouseWheelEvent(m_visualizationview, MouseEvent.MOUSE_WHEEL, System.currentTimeMillis(),
                            0, d.width / 2, d.height / 2, 1, false, MouseWheelEvent.WHEEL_UNIT_SCROLL, 1, -1));
        }
    });
    Box zoomPanel = Box.createHorizontalBox();
    zoomPanel.setBorder(BorderFactory.createTitledBorder("Zoom"));
    minus.setAlignmentX(Component.LEFT_ALIGNMENT);
    plus.setAlignmentX(Component.RIGHT_ALIGNMENT);
    zoomPanel.add(minus);
    zoomPanel.add(plus);
    settings_panel.add(zoomPanel);

    // add the mouse mode combo box to the settings panel
    JComboBox modeBox = m_graphmouse.getModeComboBox();
    modeBox.setAlignmentX(Component.CENTER_ALIGNMENT);
    m_graphmouse.setMode(ModalGraphMouse.Mode.PICKING);
    JPanel modePanel = new JPanel(new BorderLayout()) {
        public Dimension getMaximumSize() {
            return getPreferredSize();
        }
    };
    modePanel.setBorder(BorderFactory.createTitledBorder("Mouse Mode"));
    modePanel.add(modeBox);
    settings_panel.add(modePanel);

    // add the display type combo box to the settings panel
    String[] layoutTypeStrings = { "OrgChart Layout", "FR Layout" };
    layoutTypeBox = new JComboBox(layoutTypeStrings);
    layoutTypeBox.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            if (layoutTypeBox.getSelectedIndex() == 0)
                moveVertices();//viphm_hashmap);
            else
                m_visualizationview.restart();
        }
    });
    layoutTypeBox.setAlignmentX(Component.CENTER_ALIGNMENT);
    JPanel displayTypePanel = new JPanel(new BorderLayout()) {
        public Dimension getMaximumSize() {
            return getPreferredSize();
        }
    };
    displayTypePanel.setBorder(BorderFactory.createTitledBorder("Display Type"));
    displayTypePanel.add(layoutTypeBox);
    settings_panel.add(displayTypePanel);

    // add user search to the panel - SHLOMO
    JPanel searchPanel = new JPanel(new BorderLayout()) {
        public Dimension getMaximumSize() {
            return getPreferredSize();
        }
    };
    // take the users and organize it sorted
    /*
     * ArrayList<String> ta = new ArrayList<String>(userlist); String []
     * usersarray = (String[]) ta.toArray(new String[ta.size()]);
     */Arrays.sort(usersarray);
    usercombolist = new JComboBox(usersarray);

    usercombolist.insertItemAt("Anyone", 0);
    usercombolist.setSelectedIndex(0);// show only anyone choice
    // lets add all current users to the list

    searchPanel.setBorder(BorderFactory.createTitledBorder("Search User"));
    searchPanel.add(usercombolist);

    //add a check box to show not show labels on all vertices
    m_showLabels = new JCheckBox("Show name?", false);
    settings_panel.add(m_showLabels);

    settings_panel.add(searchPanel);

    usercombolist.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {

            // will need to react to the choice list
            if (usercombolist.getSelectedIndex() == 0) {
                // might have to reset something in case they move back
                PickedState picked_state = m_visualizationview.getPickedState();
                picked_state.clearPickedVertices();

                return;
            }
            String username = (String) usercombolist.getSelectedItem();

            for (Iterator walker = m_layout.getVertexIterator(); walker.hasNext();) {
                VIPVertex V = (VIPVertex) walker.next();

                // Integer indexNum = (Integer)index.getNumber(V);
                String seeName = V.getAcct();// accounts_arraylist.get(indexNum);
                if (username.equals(seeName)) {
                    PickedState picked_state = m_visualizationview.getPickedState();
                    picked_state.clearPickedVertices();
                    picked_state.pick(V, true);
                    /*
                     * int x= (int)m_layout.getX(V); int y=
                     * (int)m_layout.getY(V); //lets trigger the event
                     * m_graphmouse.mousePressed(new
                     * MouseEvent(m_visualizationview,MouseEvent.MOUSE_CLICKED,System.currentTimeMillis(),0,x,y,2,false));
                     */return;
                }
            }

        }
    });

    // add the settings panel to the settings box
    settings_box.add(settings_panel);

    // add the vip table to the control panel
    SortTableModel model = new SortTableModel();
    model.addColumn("Account");
    model.addColumn("ResponseScore");
    model.addColumn("SocialScore");
    m_timeTable = new JTable(model);
    model.addMouseListenerToHeaderInTable(m_timeTable);
    m_timeTable.setRowSelectionAllowed(true);
    m_timeTable.setColumnSelectionAllowed(false);
    m_timeTable.getTableHeader().setReorderingAllowed(false);
    m_timeTable.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    m_timeTable.setDefaultRenderer(model.getColumnClass(1), md5Renderer);
    tablePane = new JScrollPane(m_timeTable);
    tablePane.setPreferredSize(new Dimension(300, 150));
    control_panel.add(tablePane, BorderLayout.SOUTH);
}

From source file:gda.gui.mca.McaGUI.java

/**
 * Constructor/*from   w  ww . j a  v a2s.  c o  m*/
 */
public McaGUI()

{
    this.setLayout(new BoxLayout(this, BoxLayout.Y_AXIS));
    Box vertBox = Box.createVerticalBox();
    vertBox.add(getTimePanel());
    vertBox.add(getAdcPanel());
    Box horiBox = Box.createHorizontalBox();
    horiBox.add(vertBox);
    horiBox.add(getRoiPanel());
    this.add(getNamePanel());

    this.add(horiBox);
    makePlotPanel();
    this.add(plotPanel);

    Thread plotThread = uk.ac.gda.util.ThreadManager.getThread(new PlotUpdateWorker(),
            "MCA Plot Update thread");
    plotThread.start();

    setLabel("Fluorescence Detector Control");
}

From source file:org.intermine.install.swing.ProjectEditor.java

/**
 * Common initialisation: lays out the child components and wires up the necessary
 * event listeners. /*from w  w w  .  j a  v a 2 s . c o  m*/
 */
private void init() {

    setName("Project Editor Frame");
    setTitle(Messages.getMessage("projecteditor.title"));
    setDefaultCloseOperation(WindowConstants.DO_NOTHING_ON_CLOSE);
    addWindowListener(new MyWindowListener());

    modelViewerFrame = new JFrame();
    modelViewerFrame.setName("Model Viewer Frame");

    modelViewer = new ModelViewer();
    modelViewerFrame.setContentPane(modelViewer);
    modelViewerFrame.setTitle(Messages.getMessage("modelviewer.title"));
    modelViewerFrame.setSize(800, 600);

    newMineDialog = new NewMineDialog(this);
    createDatabaseDialog = new CreateDatabaseDialog(this);
    newMineDialog.setCreateDatabaseDialog(createDatabaseDialog);
    createPropertiesDialog = new CreatePropertiesDialog(this);
    createDatabaseDialog.setCreatePropertiesDialog(createPropertiesDialog);
    makeMineDialog = new MakeMineDialog(this);
    createPropertiesDialog.setMakeMineDialog(makeMineDialog);

    addSourceDialog = new AddSourceDialog(this);
    newDerivedSourceDialog = new NewDerivedTypeDialog(this);
    addSourceDialog.setNewDerivedDialog(newDerivedSourceDialog);

    postProcessorDialog = new PostProcessorDialog(this);

    buildProjectDialog = new BuildProjectDialog(this);

    preferencesDialog = new PreferencesDialog(this);

    ProjectListener projectListener = new MyProjectListener();
    addSourceDialog.addProjectListener(projectListener);
    newDerivedSourceDialog.addProjectListener(projectListener);
    postProcessorDialog.addProjectListener(projectListener);
    sourcePanel.addProjectListener(projectListener);
    makeMineDialog.addProjectListener(projectListener);
    addProjectListener(projectListener);

    JMenuBar menuBar = new JMenuBar();
    setJMenuBar(menuBar);

    JMenu fileMenu = new JMenu(Messages.getMessage("file"));
    fileMenu.setMnemonic(KeyEvent.VK_P);
    menuBar.add(fileMenu);

    fileMenu.add(new NewMineAction());
    fileMenu.add(new OpenAction());
    fileMenu.addSeparator();
    fileMenu.add(saveAction);
    fileMenu.addSeparator();
    fileMenu.add(buildProjectAction);

    JMenu editMenu = new JMenu(Messages.getMessage("edit"));
    editMenu.setMnemonic(KeyEvent.VK_E);
    menuBar.add(editMenu);

    editMenu.add(addSourceAction);
    editMenu.add(deleteSourceAction);
    editMenu.addSeparator();
    editMenu.add(postProcessorAction);

    JMenu viewMenu = new JMenu(Messages.getMessage("view"));
    viewMenu.setMnemonic(KeyEvent.VK_M);
    menuBar.add(viewMenu);

    viewMenu.add(new ViewModelAction());

    JMenu toolsMenu = new JMenu(Messages.getMessage("tools"));
    toolsMenu.setMnemonic(KeyEvent.VK_T);
    menuBar.add(toolsMenu);

    toolsMenu.add(new PreferencesAction());

    sourceListModel = new SourceListModel();
    sourceList = new JList(sourceListModel);

    Container cp = getContentPane();
    cp.setLayout(new BorderLayout());

    JSplitPane splitPane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT);
    cp.add(splitPane, BorderLayout.CENTER);

    initButtonPanel();

    Box vbox = Box.createVerticalBox();
    vbox.add(sourcePanel);
    vbox.add(buttonPanel);

    splitPane.setLeftComponent(new JScrollPane(sourceList));
    splitPane.setRightComponent(vbox);

    splitPane.setDividerLocation(200);

    initStatusPanel();
    cp.add(statusPanel, BorderLayout.SOUTH);

    sourceList.setCellRenderer(new SourceListRenderer());
    sourceList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    sourceList.addListSelectionListener(new SourceListSelectionListener());

    statusMessageClearTimer = new Timer(4000, new StatusMessageClearer());
    statusMessageClearTimer.setInitialDelay(4000);
    statusMessageClearTimer.setRepeats(false);

    setSize(800, 600);
}

From source file:TransformExplorer.java

Box refPtPanel() {
    Box panel = new Box(BoxLayout.Y_AXIS);

    panel.add(new LeftAlignComponent(new JLabel("Reference Point Coordinates")));

    // X Ref Pt//w  w  w  .ja v  a  2  s. co m
    FloatLabelJSlider coneRefPtXSlider = new FloatLabelJSlider("X", 0.1f, -2.0f, 2.0f, coneRefPt.x);
    coneRefPtXSlider.setMajorTickSpacing(1.0f);
    coneRefPtXSlider.setPaintTicks(true);
    coneRefPtXSlider.addFloatListener(new FloatListener() {
        public void floatChanged(FloatEvent e) {
            coneRefPt.x = e.getValue();
            useCompoundTransform = true;
            updateUsingCompoundTransform();
            rotAxis.setRefPt(coneRefPt);
        }
    });
    panel.add(coneRefPtXSlider);

    // Y Ref Pt
    FloatLabelJSlider coneRefPtYSlider = new FloatLabelJSlider("Y", 0.1f, -2.0f, 2.0f, coneRefPt.y);
    coneRefPtYSlider.setMajorTickSpacing(1.0f);
    coneRefPtYSlider.setPaintTicks(true);
    coneRefPtYSlider.addFloatListener(new FloatListener() {
        public void floatChanged(FloatEvent e) {
            coneRefPt.y = e.getValue();
            useCompoundTransform = true;
            updateUsingCompoundTransform();
            rotAxis.setRefPt(coneRefPt);
        }
    });
    panel.add(coneRefPtYSlider);

    // Z Ref Pt
    FloatLabelJSlider coneRefPtZSlider = new FloatLabelJSlider("Z", 0.1f, -2.0f, 2.0f, coneRefPt.z);
    coneRefPtZSlider.setMajorTickSpacing(1.0f);
    coneRefPtZSlider.setPaintTicks(true);
    coneRefPtZSlider.addFloatListener(new FloatListener() {
        public void floatChanged(FloatEvent e) {
            coneRefPt.z = e.getValue();
            useCompoundTransform = true;
            updateUsingCompoundTransform();
            rotAxis.setRefPt(coneRefPt);
        }
    });
    panel.add(coneRefPtZSlider);

    return panel;
}

From source file:TransformExplorer.java

Box translationPanel() {
    Box panel = new Box(BoxLayout.Y_AXIS);

    panel.add(new LeftAlignComponent(new JLabel("Translation Offset")));

    // X translation label, slider, and value label
    FloatLabelJSlider coneTranslateXSlider = new FloatLabelJSlider("X", 0.1f, -2.0f, 2.0f, coneTranslation.x);
    coneTranslateXSlider.setMajorTickSpacing(1.0f);
    coneTranslateXSlider.setPaintTicks(true);
    coneTranslateXSlider.addFloatListener(new FloatListener() {
        public void floatChanged(FloatEvent e) {
            coneTranslation.x = e.getValue();
            if (useCompoundTransform) {
                updateUsingCompoundTransform();
            } else {
                setConeTranslation();/* w w  w  .  j a va  2s .c o  m*/
            }
        }
    });
    panel.add(coneTranslateXSlider);

    // Y translation label, slider, and value label
    FloatLabelJSlider coneTranslateYSlider = new FloatLabelJSlider("Y", 0.1f, -2.0f, 2.0f, coneTranslation.y);
    coneTranslateYSlider.setMajorTickSpacing(1.0f);
    coneTranslateYSlider.setPaintTicks(true);
    coneTranslateYSlider.addFloatListener(new FloatListener() {
        public void floatChanged(FloatEvent e) {
            coneTranslation.y = e.getValue();
            if (useCompoundTransform) {
                updateUsingCompoundTransform();
            } else {
                setConeTranslation();
            }
        }
    });
    panel.add(coneTranslateYSlider);

    // Z translation label, slider, and value label
    FloatLabelJSlider coneTranslateZSlider = new FloatLabelJSlider("Z", 0.1f, -2.0f, 2.0f, coneTranslation.z);
    coneTranslateZSlider.setMajorTickSpacing(1.0f);
    coneTranslateZSlider.setPaintTicks(true);
    coneTranslateZSlider.addFloatListener(new FloatListener() {
        public void floatChanged(FloatEvent e) {
            coneTranslation.z = e.getValue();
            if (useCompoundTransform) {
                updateUsingCompoundTransform();
            } else {
                setConeTranslation();
            }
        }
    });
    panel.add(coneTranslateZSlider);

    return panel;
}

From source file:uk.ac.abdn.csd.p2p.server.ServerGUI.java

/**
 * This method prepares all the graphical components that are contained with P2P Visualisation Server.
 *///from   w ww.  ja  v a 2 s .c om
// <editor-fold defaultstate="collapsed" desc="...GUI">
private void initializeComponent() {
    listeningPort = 0;

    JFrame frame = new JFrame();
    BorderLayout layout = new BorderLayout();

    //create a graph
    overlay = new UndirectedSparseGraph<Vertex, Edge>();
    ObservableGraph<Vertex, Edge> og = new ObservableGraph<Vertex, Edge>(overlay);
    /*   og.addGraphEventListener(new GraphEventListener<Vertex, Edge>() {
       @Override
       public void handleGraphEvent(
       GraphEvent<Vertex, Edge> evt) {
    System.err.println("got " + evt);
            
       }
    });*/
    this.overlay = og;
    layout1 = new FRLayout2<Vertex, Edge>(overlay);
    vv = new VisualizationViewer<Vertex, Edge>(layout1, new Dimension(700, 200));
    vv.setGraphMouse(new DefaultModalGraphMouse<Vertex, Edge>());
    vv.getRenderContext().setVertexLabelTransformer(new ToStringLabeller<Vertex>());
    vv.getRenderContext().setEdgeLabelTransformer(new ToStringLabeller<Edge>());
    vv.getRenderer().getVertexLabelRenderer().setPosition(Position.CNTR);
    vv.getRenderContext().setVertexFillPaintTransformer(new VertexPainter());

    DefaultModalGraphMouse gm1 = new DefaultModalGraphMouse();
    gm1.setMode(ModalGraphMouse.Mode.TRANSFORMING);
    gm1.setMode(ModalGraphMouse.Mode.PICKING);
    gm1.add(new MyPopupGraphMousePlugin());
    vv.setGraphMouse(gm1);
    vv.addKeyListener(gm1.getModeKeyListener());

    contentPane = new JPanel(layout);

    displayPanel = new javax.swing.JPanel();

    consoleTextArea = new JTextArea();
    jScrollPane2 = new JScrollPane();
    clearButton = new JButton();
    consolePanel = new JPanel();
    clearButton = new javax.swing.JButton();

    nodeTextArea = new JTextArea();
    jScrollPane1 = new JScrollPane();
    nodePanel = new JPanel();

    linkTextArea = new JTextArea();
    jScrollPane3 = new JScrollPane();
    linkPanel = new JPanel();

    menuBar = new javax.swing.JMenuBar();
    serverMenu = new javax.swing.JMenu();
    startServerMenuItem = new javax.swing.JMenuItem();
    jSeparator1 = new javax.swing.JPopupMenu.Separator();
    exitMenuItem = new javax.swing.JMenuItem();
    editMenu = new javax.swing.JMenu();
    settingMenuItem = new javax.swing.JMenuItem();
    colorSettingMenuItem = new javax.swing.JMenuItem();
    toolMenuItem = new javax.swing.JMenu();
    clearMenuItem = new javax.swing.JMenuItem();
    helpMenu = new javax.swing.JMenu();
    aboutMenuItem = new javax.swing.JMenuItem();
    zoominMenuItem = new javax.swing.JMenuItem();
    zoomoutMenuItem = new javax.swing.JMenuItem();
    layoutSettingMenuItem = new javax.swing.JMenuItem();
    labelPositionMenuItem = new javax.swing.JMenuItem();
    speedSettingMenuItem = new javax.swing.JMenuItem();
    topologySettingMenuItem = new javax.swing.JMenuItem();
    findNodeMenuItem = new javax.swing.JMenuItem();

    serverMenu.setText("Server");
    serverMenu.setToolTipText("Server");

    startServerMenuItem.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_C,
            java.awt.event.InputEvent.ALT_MASK));
    startServerMenuItem.setText("Start Server");
    startServerMenuItem.setToolTipText("Start Server");
    startServerMenuItem.addActionListener(new java.awt.event.ActionListener() {
        @Override
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            startServerMenuItemActionPerformed(evt);
        }
    });
    serverMenu.add(startServerMenuItem);
    serverMenu.add(jSeparator1);

    exitMenuItem.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_X,
            java.awt.event.InputEvent.ALT_MASK));
    exitMenuItem.setText("Exit");
    exitMenuItem.setToolTipText("Exit");
    exitMenuItem.addActionListener(new java.awt.event.ActionListener() {
        @Override
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            exitMenuItemActionPerformed(evt);
        }
    });
    serverMenu.add(exitMenuItem);

    menuBar.add(serverMenu);

    editMenu.setText("Edit");
    editMenu.setToolTipText("Edit");

    settingMenuItem.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_S,
            java.awt.event.InputEvent.ALT_MASK));
    settingMenuItem.setText("Server Settings");
    settingMenuItem.setToolTipText("Server Settings");
    settingMenuItem.addActionListener(new java.awt.event.ActionListener() {
        @Override
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            settingMenuItemActionPerformed(evt);
        }
    });
    editMenu.add(settingMenuItem);

    colorSettingMenuItem.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_M,
            java.awt.event.InputEvent.ALT_MASK));
    colorSettingMenuItem.setText("Colour Settings");
    colorSettingMenuItem.setToolTipText("Colour Settings");
    colorSettingMenuItem.addActionListener(new java.awt.event.ActionListener() {
        @Override
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            colorSettingMenuItemActionPerformed(evt);
        }
    });
    editMenu.add(colorSettingMenuItem);

    layoutSettingMenuItem.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_L,
            java.awt.event.InputEvent.ALT_MASK));
    layoutSettingMenuItem.setText("Layout Settings");
    layoutSettingMenuItem.setToolTipText("Layout Settings");
    layoutSettingMenuItem.addActionListener(new java.awt.event.ActionListener() {
        @Override
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            layoutSettingMenuItemActionPerformed(evt);
        }
    });
    editMenu.add(layoutSettingMenuItem);

    speedSettingMenuItem.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_V,
            java.awt.event.InputEvent.ALT_MASK));
    speedSettingMenuItem.setText("Speed Settings");
    speedSettingMenuItem.setToolTipText("Speed Settings");
    speedSettingMenuItem.addActionListener(new java.awt.event.ActionListener() {
        @Override
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            speedSettingMenuItemActionPerformed(evt);
        }
    });
    editMenu.add(speedSettingMenuItem);

    topologySettingMenuItem.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_T,
            java.awt.event.InputEvent.ALT_MASK));
    topologySettingMenuItem.setText("Topology Settings");
    topologySettingMenuItem.setToolTipText("Topology Settings");
    topologySettingMenuItem.addActionListener(new java.awt.event.ActionListener() {
        @Override
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            topologySettingMenuItemActionPerformed(evt);
        }
    });
    editMenu.add(topologySettingMenuItem);

    menuBar.add(editMenu);

    toolMenuItem.setText("Tools");
    toolMenuItem.setToolTipText("Tools");

    labelPositionMenuItem.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_P,
            java.awt.event.InputEvent.ALT_MASK));
    labelPositionMenuItem.setText("Vertex Label Position");
    labelPositionMenuItem.setToolTipText("Vertex Label Position");
    toolMenuItem.add(labelPositionMenuItem);
    labelPositionMenuItem.addActionListener(new java.awt.event.ActionListener() {
        @Override
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            labelPositionMenuItemActionPerformed(evt);

        }
    });

    final ScalingControl scaler = new CrossoverScalingControl();

    zoominMenuItem.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_I,
            java.awt.event.InputEvent.ALT_MASK));
    zoominMenuItem.setText("Zoom-In");
    zoominMenuItem.setToolTipText("Zoom-In");
    toolMenuItem.add(zoominMenuItem);
    zoominMenuItem.addActionListener(new java.awt.event.ActionListener() {
        @Override
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            scaler.scale(vv, 1.1f, vv.getCenter());
        }
    });
    zoomoutMenuItem.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_O,
            java.awt.event.InputEvent.ALT_MASK));
    zoomoutMenuItem.setText("Zoom-Out");
    zoomoutMenuItem.setToolTipText("Zoom-Out");
    toolMenuItem.add(zoomoutMenuItem);
    zoomoutMenuItem.addActionListener(new java.awt.event.ActionListener() {
        @Override
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            scaler.scale(vv, 0.9f, vv.getCenter());
        }
    });

    findNodeMenuItem.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_F,
            java.awt.event.InputEvent.ALT_MASK));
    findNodeMenuItem.setText("Find Node on Overlay");
    findNodeMenuItem.setToolTipText("Find Node");
    toolMenuItem.add(findNodeMenuItem);
    findNodeMenuItem.addActionListener(new java.awt.event.ActionListener() {
        @Override
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            findNodeMenuItemMenuItemActionPerformed(evt);
        }
    });

    menuBar.add(toolMenuItem);

    helpMenu.setText("Help");
    helpMenu.setToolTipText("Help");

    aboutMenuItem.setText("About");
    aboutMenuItem.setToolTipText("About");
    aboutMenuItem.addActionListener(new java.awt.event.ActionListener() {
        @Override
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            aboutMenuItemActionPerformed(evt);
        }
    });
    helpMenu.add(aboutMenuItem);

    menuBar.add(helpMenu);

    displayPanel.setLayout(new BorderLayout());
    displayPanel.setBorder(new TitledBorder("P2P Overlay"));
    displayPanel.add(vv);
    validate();
    //
    // nodeTextArea
    //
    nodeTextArea.setEditable(false);
    nodeTextArea.setLineWrap(true);

    //
    // jScrollPane1
    //
    jScrollPane1.setViewportView(nodeTextArea);
    //jScrollPane1.setsi
    //
    // nodePanel
    //
    nodePanel.setLayout(new BoxLayout(nodePanel, BoxLayout.X_AXIS));
    nodePanel.add(jScrollPane1, 0);

    nodePanel.setBorder(new TitledBorder("Nodes Active"));
    //
    // linkTextArea
    //
    linkTextArea.setEditable(false);
    linkTextArea.setLineWrap(true);
    //
    // jScrollPane3
    //
    jScrollPane3.setViewportView(linkTextArea);
    //
    // linkPanel
    //
    linkPanel.setLayout(new BoxLayout(linkPanel, BoxLayout.X_AXIS));
    linkPanel.add(jScrollPane3, 0);
    linkPanel.setBorder(new TitledBorder("Node Links"));
    //
    // consoleTextArea
    //
    consoleTextArea.setEditable(false);
    consoleTextArea.setLineWrap(true);
    //
    // jScrollPane2
    //
    jScrollPane2.setViewportView(consoleTextArea);
    //
    // clearButton
    //
    clearButton.setText("Clear");
    clearButton.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            clearButton_actionPerformed(e);
        }

    });
    //
    // consolePanel
    //
    consolePanel.setLayout(new BoxLayout(consolePanel, BoxLayout.X_AXIS));
    consolePanel.add(jScrollPane2, 0);
    consolePanel.add(clearButton, 1);
    consolePanel.setBorder(new TitledBorder("Console"));
    //
    // ServerGUI
    //
    Dimension panelD = new Dimension(700, 330); // display Panel
    Dimension panelD1 = new Dimension(700, 134); // control Panel      
    Dimension panelD2 = new Dimension(350, 140); // nodepanel and linkpanel
    Dimension panelD3 = new Dimension(700, 140); // nodepanel and linkpanel togther
    consolePanel.setPreferredSize(panelD1);
    displayPanel.setPreferredSize(panelD);
    nodePanel.setPreferredSize(panelD2);
    linkPanel.setPreferredSize(panelD2);
    Box box = new Box(BoxLayout.X_AXIS); // put nodepanel and linkpanel in one box
    box.add(nodePanel);
    box.add(linkPanel);
    box.setSize(panelD3);

    //contentPane.add(BorderLayout.NORTH,displayPanel);
    //contentPane.add(BorderLayout.CENTER,box);
    contentPane.add(BorderLayout.NORTH, box);
    contentPane.add(BorderLayout.CENTER, displayPanel);
    contentPane.add(BorderLayout.SOUTH, consolePanel);

    frame.setJMenuBar(menuBar);
    frame.getContentPane().add(contentPane);
    frame.setTitle("P2P Visualisation Server");
    frame.setSize(new Dimension(800, 600));
    frame.setResizable(true);
    // This code has been adapted from http://lookass.ch/?id=4&area=art&art=47
    Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
    Dimension size = frame.getSize();
    screenSize.height = screenSize.height / 2;
    screenSize.width = screenSize.width / 2;
    size.height = size.height / 2;
    size.width = size.width / 2;
    int y = screenSize.height - size.height;
    int x = screenSize.width - size.width;
    frame.setLocation(x, y);
    frame.setVisible(true);

    frame.setDefaultCloseOperation(javax.swing.WindowConstants.DO_NOTHING_ON_CLOSE);
    frame.addWindowListener(new java.awt.event.WindowAdapter() {
        public void windowClosing(java.awt.event.WindowEvent evt) {
            formWindowClosing(evt);
        }
    });
}

From source file:cellularAutomata.analysis.PricingDistributionAnalysis.java

/**
 * Create the panel used to display the pricing statistics.
 *//*w  w  w . ja  v  a 2  s. co m*/
private void createDisplayPanel() {
    int displayWidth = CAFrame.tabbedPaneDimension.width;
    int displayHeight = 600 + (100 * numberOfStates);

    // create the display panel
    if (displayPanel == null) {
        displayPanel = new JPanel(new GridBagLayout());
        displayPanel.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));
        displayPanel.setPreferredSize(new Dimension(displayWidth, displayHeight));
    } else {
        displayPanel.removeAll();
    }

    if (isCompatibleRule && (numberOfStates <= MAX_NUMBER_OF_STATES)) {
        // create a panel that displays messages
        JPanel messagePanel = createMessagePanel();

        // create the labels for the display
        createDataDisplayLabels();
        JLabel generationLabel = new JLabel("Generation:   ");
        JLabel stateLabel = new JLabel("State:");
        JLabel numStateLabel = new JLabel("Number:");
        JLabel percentOccupiedLabel = new JLabel("Kurtosis:");

        // create boxes for each column of the display (a Box uses the
        // BoxLayout, so it is handy for laying out components)
        Box boxOfStateLabels = Box.createVerticalBox();
        Box boxOfNumberLabels = Box.createVerticalBox();
        Box boxOfPercentLabels = Box.createVerticalBox();

        // the amount of vertical space to put between components
        int verticalSpace = 5;

        // add the states to the first vertical box
        boxOfStateLabels.add(stateLabel);
        boxOfStateLabels.add(Box.createVerticalStrut(verticalSpace));
        for (int state = 0; state < numberOfStates; state++) {
            boxOfStateLabels.add(new JLabel("" + state));
            boxOfStateLabels.add(Box.createVerticalStrut(verticalSpace));
        }

        // add the numbers (in each state) to the second vertical box
        boxOfNumberLabels.add(numStateLabel);
        boxOfNumberLabels.add(Box.createVerticalStrut(verticalSpace));
        for (int i = 0; i < numberOfStates; i++) {
            boxOfNumberLabels.add(numberOccupiedByStateDataLabel[i]);
            boxOfNumberLabels.add(Box.createVerticalStrut(verticalSpace));
        }

        // add the percents (in each state) to the third vertical box
        boxOfPercentLabels.add(percentOccupiedLabel);
        boxOfPercentLabels.add(Box.createVerticalStrut(verticalSpace));
        for (int i = 0; i < numberOfStates; i++) {
            boxOfPercentLabels.add(percentOccupiedByStateDataLabel[i]);
            boxOfPercentLabels.add(Box.createVerticalStrut(verticalSpace));
        }

        // create another box that holds all of the label boxes
        Box boxOfLabels = Box.createHorizontalBox();
        boxOfLabels.add(boxOfStateLabels);
        boxOfLabels.add(boxOfNumberLabels);
        boxOfLabels.add(boxOfPercentLabels);
        boxOfLabels.setBorder(BorderFactory.createEmptyBorder(7, 7, 7, 7));

        // put the boxOfLabels in a scrollPane -- with many states, will get
        // very large
        JScrollPane stateScroller = new JScrollPane(boxOfLabels);
        int scrollPaneWidth = (int) (displayWidth * 0.8);
        int scrollPaneHeight = displayHeight / 4;
        stateScroller.setPreferredSize(new Dimension(scrollPaneWidth, scrollPaneHeight));
        stateScroller.setMinimumSize(new Dimension(scrollPaneWidth, scrollPaneHeight));
        stateScroller.setMaximumSize(new Dimension(scrollPaneWidth, scrollPaneHeight));
        stateScroller.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS);

        // create a "plot zero state" check box
        plotZeroStateCheckBox = new JCheckBox(PLOT_ZERO_STATE);
        plotZeroStateCheckBox.setSelected(true);
        plotZeroStateCheckBox.setToolTipText(PLOT_ZERO_STATE_TOOLTIP);
        plotZeroStateCheckBox.setActionCommand(PLOT_ZERO_STATE);
        plotZeroStateCheckBox.addActionListener(this);
        JPanel plotZeroStatePanel = new JPanel(new BorderLayout());
        plotZeroStatePanel.setBorder(BorderFactory.createEmptyBorder(7, 7, 7, 7));
        plotZeroStatePanel.add(BorderLayout.CENTER, plotZeroStateCheckBox);

        // create a "save data" check box
        saveDataCheckBox = new JCheckBox(SAVE_DATA);
        saveDataCheckBox.setToolTipText(SAVE_DATA_TOOLTIP);
        saveDataCheckBox.setActionCommand(SAVE_DATA);
        saveDataCheckBox.addActionListener(this);
        JPanel saveDataPanel = new JPanel(new BorderLayout());
        saveDataPanel.setBorder(BorderFactory.createEmptyBorder(7, 7, 7, 7));
        saveDataPanel.add(BorderLayout.CENTER, saveDataCheckBox);

        // create a panel that plots the data
        plot = new SimplePlot();

        // add all the components to the panel
        int row = 0;
        displayPanel.add(messagePanel, new GBC(1, row).setSpan(4, 1).setFill(GBC.BOTH).setWeight(1.0, 1.0)
                .setAnchor(GBC.WEST).setInsets(1));

        row++;
        displayPanel.add(plot, new GBC(1, row).setSpan(4, 1).setFill(GBC.BOTH).setWeight(10.0, 10.0)
                .setAnchor(GBC.WEST).setInsets(1));

        row++;
        for (int i = 0; i < numberOfStates; i++) {
            timeSeriesPlot[i] = new SimplePlot();
            displayPanel.add(timeSeriesPlot[i], new GBC(1, row).setSpan(4, 1).setFill(GBC.BOTH)
                    .setWeight(10.0, 10.0).setAnchor(GBC.WEST).setInsets(1));

            row++;
        }
        displayPanel.add(plotZeroStatePanel, new GBC(1, row).setSpan(4, 1).setFill(GBC.NONE).setWeight(1.0, 1.0)
                .setAnchor(GBC.CENTER).setInsets(1));

        row++;
        displayPanel.add(generationLabel, new GBC(1, row).setSpan(1, 1).setFill(GBC.NONE).setWeight(1.0, 1.0)
                .setAnchor(GBC.EAST).setInsets(1));
        displayPanel.add(generationDataLabel, new GBC(2, row).setSpan(1, 1).setFill(GBC.NONE)
                .setWeight(1.0, 1.0).setAnchor(GBC.WEST).setInsets(1));

        row++;
        displayPanel.add(stateScroller, new GBC(1, row).setSpan(4, 1).setFill(GBC.BOTH).setWeight(1.0, 1.0)
                .setAnchor(GBC.WEST).setInsets(1));

        row++;
        displayPanel.add(saveDataPanel, new GBC(1, row).setSpan(4, 1).setFill(GBC.NONE).setWeight(1.0, 1.0)
                .setAnchor(GBC.CENTER).setInsets(1));

    } else {
        int row = 0;
        displayPanel.add(createWarningMessagePanel(), new GBC(1, row).setSpan(4, 1).setFill(GBC.BOTH)
                .setWeight(1.0, 1.0).setAnchor(GBC.WEST).setInsets(1));
    }

}

From source file:econtroller.gui.ControllerGUI.java

private void createSenseSlider() {
    Box hbox = Box.createHorizontalBox();
    senseLabel = new JLabel("Sense every ", JLabel.CENTER);
    senseValueLabel = new JLabel(String.valueOf(SENSE_INIT), JLabel.CENTER);
    senseSecondLabel = new JLabel(" (s)", JLabel.CENTER);

    senseSlider = new JSlider(JSlider.HORIZONTAL, SENSE_MIN, SENSE_MAX, SENSE_INIT);
    senseSlider.setMajorTickSpacing(20);
    senseSlider.setMinorTickSpacing(5);// w w  w.  ja  va2s. c o  m
    senseSlider.setPaintLabels(true);
    senseSlider.setPaintTicks(true);
    senseSlider.setPaintTrack(true);

    senseSlider.addChangeListener(new ChangeListener() {
        @Override
        public void stateChanged(ChangeEvent changeEvent) {
            JSlider source = (JSlider) changeEvent.getSource();
            int value = source.getValue();
            senseValueLabel.setText(String.valueOf(value));
        }
    });

    hbox.add(senseLabel);
    hbox.add(senseValueLabel);
    hbox.add(senseSecondLabel);
    controllerDesignPanel.add(hbox);
    controllerDesignPanel.add(senseSlider);
}