Search in sources :

Example 66 with TitledBorder

use of javax.swing.border.TitledBorder in project vcell by virtualcell.

the class ViewJobsPanel method initialize.

private void initialize() {
    try {
        setName("ViewSimulationJobsPanel");
        getRefreshAllButton().addActionListener(eventHandler);
        // ----------------------------------------------------------------------------------
        // filters, buttons
        JPanel top = new JPanel();
        // table with results
        JPanel bottom = new JPanel();
        Border loweredEtchedBorder = BorderFactory.createEtchedBorder(EtchedBorder.LOWERED);
        Border loweredBevelBorder = BorderFactory.createLoweredBevelBorder();
        TitledBorder titleTop = BorderFactory.createTitledBorder(loweredEtchedBorder, " Query Filters ");
        titleTop.setTitleJustification(TitledBorder.LEFT);
        titleTop.setTitlePosition(TitledBorder.TOP);
        TitledBorder titleBottom = BorderFactory.createTitledBorder(loweredEtchedBorder, " Query Results ");
        titleBottom.setTitleJustification(TitledBorder.LEFT);
        titleBottom.setTitlePosition(TitledBorder.TOP);
        top.setBorder(titleTop);
        bottom.setBorder(titleBottom);
        setLayout(new GridBagLayout());
        GridBagConstraints gbc = new GridBagConstraints();
        gbc.gridx = 0;
        gbc.gridy = 0;
        gbc.weightx = 0;
        gbc.weighty = 0;
        gbc.fill = GridBagConstraints.HORIZONTAL;
        // top, left, bottom, right
        gbc.insets = new Insets(5, 2, 2, 3);
        add(top, gbc);
        gbc = new GridBagConstraints();
        gbc.gridx = 0;
        gbc.gridy = 1;
        gbc.weightx = 1.0;
        gbc.weighty = 1.0;
        gbc.fill = GridBagConstraints.BOTH;
        gbc.insets = new Insets(5, 2, 2, 3);
        add(bottom, gbc);
        // --------------------------------------- top panel (filters, button) --------------
        // filters
        JPanel left = new JPanel();
        JPanel center = new SeparatedJPanel();
        // buttons
        JPanel right = new SeparatedJPanel();
        top.setLayout(new GridBagLayout());
        gbc = new GridBagConstraints();
        gbc.gridx = 0;
        gbc.gridy = 0;
        gbc.weightx = 0;
        gbc.weighty = 0;
        gbc.fill = GridBagConstraints.HORIZONTAL;
        gbc.insets = new Insets(5, 2, 2, 3);
        top.add(left, gbc);
        gbc = new GridBagConstraints();
        gbc.gridx = 1;
        gbc.gridy = 0;
        gbc.weightx = 1.0;
        gbc.weighty = 1.0;
        gbc.fill = GridBagConstraints.BOTH;
        gbc.insets = new Insets(5, 2, 2, 3);
        top.add(center, gbc);
        gbc = new GridBagConstraints();
        gbc.gridx = 2;
        gbc.gridy = 0;
        gbc.weightx = 0.0;
        gbc.weighty = 0.0;
        gbc.fill = GridBagConstraints.BOTH;
        gbc.insets = new Insets(5, 2, 2, 3);
        top.add(right, gbc);
        // ------------------------------------ left panel (of top panel) -------------
        left.setLayout(new GridBagLayout());
        gbc = new GridBagConstraints();
        gbc.gridx = 0;
        gbc.gridy = 0;
        gbc.weightx = 0;
        gbc.weighty = 0;
        gbc.fill = GridBagConstraints.HORIZONTAL;
        gbc.insets = new Insets(5, 2, 2, 0);
        left.add(getWaitingButton(), gbc);
        gbc.gridx = 1;
        gbc.gridy = 0;
        gbc.weightx = 0;
        gbc.weighty = 0;
        gbc.fill = GridBagConstraints.HORIZONTAL;
        gbc.insets = new Insets(5, 0, 2, 3);
        JLabel label = new JLabel(waitingIcon);
        left.add(label, gbc);
        gbc.gridx = 2;
        gbc.gridy = 0;
        gbc.weightx = 0;
        gbc.weighty = 0;
        gbc.fill = GridBagConstraints.HORIZONTAL;
        gbc.insets = new Insets(5, 15, 2, 0);
        left.add(getQueuedButton(), gbc);
        gbc.gridx = 3;
        gbc.gridy = 0;
        gbc.weightx = 0;
        gbc.weighty = 0;
        gbc.fill = GridBagConstraints.HORIZONTAL;
        gbc.insets = new Insets(5, 0, 2, 10);
        label = new JLabel(queuedIcon);
        left.add(label, gbc);
        // -------------------------------------
        gbc.gridx = 0;
        gbc.gridy = 1;
        gbc.weightx = 0;
        gbc.weighty = 0;
        gbc.fill = GridBagConstraints.HORIZONTAL;
        gbc.insets = new Insets(5, 2, 2, 0);
        left.add(getDispatchedButton(), gbc);
        gbc.gridx = 1;
        gbc.gridy = 1;
        gbc.weightx = 0;
        gbc.weighty = 0;
        gbc.fill = GridBagConstraints.HORIZONTAL;
        gbc.insets = new Insets(5, 0, 2, 3);
        label = new JLabel(dispatchedIcon);
        left.add(label, gbc);
        gbc.gridx = 2;
        gbc.gridy = 1;
        gbc.weightx = 0;
        gbc.weighty = 0;
        gbc.fill = GridBagConstraints.HORIZONTAL;
        gbc.insets = new Insets(5, 15, 2, 0);
        left.add(getRunningButton(), gbc);
        gbc.gridx = 3;
        gbc.gridy = 1;
        gbc.weightx = 0;
        gbc.weighty = 0;
        gbc.fill = GridBagConstraints.HORIZONTAL;
        gbc.insets = new Insets(5, 0, 2, 10);
        label = new JLabel(runningIcon);
        left.add(label, gbc);
        // -------------------------------------
        gbc.gridx = 0;
        gbc.gridy = 2;
        gbc.weightx = 0;
        gbc.weighty = 0;
        gbc.fill = GridBagConstraints.HORIZONTAL;
        gbc.insets = new Insets(5, 2, 2, 0);
        left.add(getCompletedButton(), gbc);
        gbc.gridx = 1;
        gbc.gridy = 2;
        gbc.weightx = 0;
        gbc.weighty = 0;
        gbc.fill = GridBagConstraints.HORIZONTAL;
        gbc.insets = new Insets(5, 0, 2, 3);
        label = new JLabel(completedIcon);
        left.add(label, gbc);
        gbc.gridx = 2;
        gbc.gridy = 2;
        gbc.weightx = 0;
        gbc.weighty = 0;
        gbc.fill = GridBagConstraints.HORIZONTAL;
        gbc.insets = new Insets(5, 15, 2, 3);
        left.add(getFailedButton(), gbc);
        gbc.gridx = 3;
        gbc.gridy = 2;
        gbc.weightx = 0;
        gbc.weighty = 0;
        gbc.fill = GridBagConstraints.HORIZONTAL;
        gbc.insets = new Insets(5, 0, 2, 10);
        label = new JLabel(failedIcon);
        left.add(label, gbc);
        // -------------------------------------
        gbc.gridx = 0;
        gbc.gridy = 3;
        gbc.weightx = 0;
        gbc.weighty = 0;
        gbc.fill = GridBagConstraints.HORIZONTAL;
        gbc.insets = new Insets(5, 2, 2, 0);
        left.add(getStoppedButton(), gbc);
        gbc.gridx = 1;
        gbc.gridy = 3;
        gbc.weightx = 0;
        gbc.weighty = 0;
        gbc.fill = GridBagConstraints.HORIZONTAL;
        gbc.insets = new Insets(5, 0, 2, 3);
        label = new JLabel(stoppedIcon);
        left.add(label, gbc);
        // ---------------------------------------- center panel (of top panel) ------------
        center.setLayout(new GridBagLayout());
        gbc = new GridBagConstraints();
        gbc.gridx = 0;
        gbc.gridy = 0;
        gbc.anchor = GridBagConstraints.LINE_START;
        gbc.insets = new Insets(4, 15, 4, 4);
        center.add(new JLabel("Max # of results "), gbc);
        textFieldJobsLimit = new JTextField();
        textFieldJobsLimit.addActionListener(eventHandler);
        // textFieldJobsLimit.getDocument().addDocumentListener(eventHandler);
        textFieldJobsLimit.setText(maxRows + "");
        Dimension d = textFieldJobsLimit.getPreferredSize();
        d.width = 80;
        textFieldJobsLimit.setPreferredSize(d);
        textFieldJobsLimit.setMaximumSize(d);
        gbc = new GridBagConstraints();
        gbc.gridx = 1;
        gbc.gridy = 0;
        gbc.anchor = GridBagConstraints.LINE_START;
        gbc.insets = new Insets(4, 0, 4, 4);
        center.add(textFieldJobsLimit, gbc);
        gbc = new GridBagConstraints();
        gbc.gridx = 2;
        gbc.gridy = 0;
        gbc.weightx = 0;
        gbc.weighty = 0;
        gbc.fill = GridBagConstraints.HORIZONTAL;
        gbc.insets = new Insets(5, 15, 2, 3);
        center.add(getOrphanedButton(), gbc);
        // gbc = new GridBagConstraints();
        // gbc.weighty = 1.0;
        // gbc.gridx = 0;
        // gbc.gridy = 2;
        // //			gbc.gridheight = GridBagConstraints.REMAINDER;
        // gbc.anchor = GridBagConstraints.WEST;
        // gbc.fill = java.awt.GridBagConstraints.VERTICAL;
        // gbc.insets = new Insets(4,4,4,4);
        // center.add(new JLabel("---"), gbc);			// fake vertical
        gbc = new GridBagConstraints();
        gbc.gridx = 0;
        gbc.gridy = 2;
        gbc.gridwidth = 3;
        gbc.anchor = GridBagConstraints.WEST;
        gbc.fill = java.awt.GridBagConstraints.BOTH;
        gbc.insets = new Insets(4, 11, 4, 4);
        center.add(getSubmitDatePanel(), gbc);
        gbc = new GridBagConstraints();
        gbc.weightx = 1.0;
        gbc.gridx = 3;
        gbc.gridy = 2;
        gbc.anchor = GridBagConstraints.EAST;
        gbc.fill = java.awt.GridBagConstraints.HORIZONTAL;
        gbc.insets = new Insets(4, 4, 4, 4);
        // fake horizontal
        center.add(new JLabel("-"), gbc);
        // ---------------------------------------- right panel (of top panel) -------------
        right.setLayout(new GridBagLayout());
        gbc = new GridBagConstraints();
        gbc.weighty = 1.0;
        gbc.gridx = 0;
        gbc.gridy = 0;
        gbc.anchor = GridBagConstraints.WEST;
        gbc.fill = java.awt.GridBagConstraints.VERTICAL;
        // fake vertical
        right.add(new JLabel(""), gbc);
        gbc = new GridBagConstraints();
        gbc.gridx = 0;
        gbc.gridy = 1;
        gbc.weightx = 0;
        gbc.weighty = 0;
        gbc.fill = GridBagConstraints.HORIZONTAL;
        gbc.insets = new Insets(4, 12, 4, 8);
        right.add(getRefreshAllButton(), gbc);
        getCompletedButton().setSelected(false);
        getDispatchedButton().setSelected(true);
        getFailedButton().setSelected(true);
        getQueuedButton().setSelected(true);
        getRunningButton().setSelected(true);
        getStoppedButton().setSelected(true);
        getWaitingButton().setSelected(true);
        getOrphanedButton().setSelected(false);
        getSubmitBetweenButton().setSelected(false);
        // ----------------------------------------- bottom panel (the table) -------------------
        table = new EditorScrollTable();
        model = new SimulationJobsTableModel(table, this);
        table.setModel(model);
        table.getSelectionModel().addListSelectionListener(eventHandler);
        table.getModel().addTableModelListener(eventHandler);
        table.addMouseMotionListener(new // add toolTipText for each table cell
        MouseMotionAdapter() {

            public void mouseMoved(MouseEvent e) {
                Point p = e.getPoint();
                int row = table.rowAtPoint(p);
                int column = table.columnAtPoint(p);
                table.setToolTipText(String.valueOf(table.getValueAt(row, column)));
            }
        });
        bottom.setLayout(new GridBagLayout());
        int gridy = 0;
        gbc = new java.awt.GridBagConstraints();
        gbc.gridx = 0;
        gbc.gridy = gridy;
        gbc.weightx = 1.0;
        gbc.weighty = 1.0;
        gbc.gridwidth = 8;
        gbc.fill = GridBagConstraints.BOTH;
        gbc.insets = new Insets(4, 4, 4, 4);
        // table.setPreferredScrollableViewportSize(new Dimension(700,350));	// apparently useless
        bottom.add(table.getEnclosingScrollPane(), gbc);
        gridy++;
        gbc = new GridBagConstraints();
        gbc.gridx = 0;
        gbc.gridy = gridy;
        gbc.anchor = GridBagConstraints.LINE_START;
        gbc.insets = new Insets(4, 4, 4, 4);
        bottom.add(new JLabel("Search "), gbc);
        textFieldSearch = new JTextField(70);
        textFieldSearch.addActionListener(eventHandler);
        textFieldSearch.getDocument().addDocumentListener(eventHandler);
        textFieldSearch.putClientProperty("JTextField.variant", "search");
        gbc = new java.awt.GridBagConstraints();
        gbc.weightx = 1.0;
        gbc.gridx = 1;
        gbc.gridy = gridy;
        gbc.gridwidth = 3;
        gbc.anchor = GridBagConstraints.LINE_START;
        gbc.fill = java.awt.GridBagConstraints.HORIZONTAL;
        gbc.insets = new Insets(4, 0, 4, 4);
        bottom.add(textFieldSearch, gbc);
        gbc = new GridBagConstraints();
        gbc.gridx = 4;
        gbc.gridy = gridy;
        gbc.fill = GridBagConstraints.HORIZONTAL;
        gbc.insets = new Insets(4, 4, 4, 10);
        bottom.add(countLabel, gbc);
        // renderer for the status icon; the tooltip gives the text
        DefaultScrollTableCellRenderer statusCellRenderer = new DefaultScrollTableCellRenderer() {

            @Override
            public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) {
                super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column);
                setText((String) value);
                if (table.getModel() instanceof VCellSortTableModel<?>) {
                    Object selectedObject = null;
                    if (table.getModel() == model) {
                        selectedObject = model.getValueAt(row);
                    }
                    if (selectedObject != null && selectedObject instanceof SimpleJobStatus) {
                        SimpleJobStatus js = (SimpleJobStatus) selectedObject;
                        SchedulerStatus ss1 = js.jobStatus.getSchedulerStatus();
                        switch(ss1) {
                            case WAITING:
                                setIcon(waitingIcon);
                                break;
                            case QUEUED:
                                setIcon(queuedIcon);
                                break;
                            case DISPATCHED:
                                setIcon(dispatchedIcon);
                                break;
                            case RUNNING:
                                setIcon(runningIcon);
                                break;
                            case COMPLETED:
                                setIcon(completedIcon);
                                break;
                            case STOPPED:
                                setIcon(stoppedIcon);
                                break;
                            case FAILED:
                                setIcon(failedIcon);
                                break;
                            default:
                                setIcon(failedIcon);
                                break;
                        }
                        // setText("");
                        setToolTipText(ss1.getDescription());
                        setHorizontalTextPosition(SwingConstants.RIGHT);
                    }
                }
                return this;
            }
        };
        // statusCellRenderer.setHorizontalAlignment(JLabel.RIGHT);
        DefaultScrollTableCellRenderer dateTimeCellRenderer = new DefaultScrollTableCellRenderer() {

            @Override
            public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) {
                super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column);
                setText((String) value);
                if (table.getModel() instanceof VCellSortTableModel<?>) {
                    Object selectedObject = null;
                    if (table.getModel() == model) {
                        selectedObject = model.getValueAt(row);
                    }
                    if (selectedObject != null && selectedObject instanceof SimpleJobStatus) {
                        SimpleJobStatus sjs = (SimpleJobStatus) selectedObject;
                        DateFormat df = new SimpleDateFormat("MM.dd.yyyy HH:MM:SS");
                        Date date = sjs.jobStatus.getStartDate();
                        String str = df.format(date);
                        setToolTipText(str);
                    }
                }
                return this;
            }
        };
        DefaultScrollTableCellRenderer hasDataCellRenderer = new DefaultScrollTableCellRenderer() {

            @Override
            public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) {
                super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column);
                setText((String) value);
                if (table.getModel() instanceof VCellSortTableModel<?>) {
                    Object selectedObject = null;
                    if (table.getModel() == model) {
                        selectedObject = model.getValueAt(row);
                    }
                    if (selectedObject != null && selectedObject instanceof SimpleJobStatus) {
                        SimpleJobStatus sjs = (SimpleJobStatus) selectedObject;
                        if (sjs.jobStatus.hasData()) {
                            setIcon(dataYesIcon);
                        } else {
                            setIcon(dataNoIcon);
                        }
                    }
                }
                return this;
            }
        };
        table.getColumnModel().getColumn(SimulationJobsTableModel.iColStatus).setCellRenderer(statusCellRenderer);
        table.getColumnModel().getColumn(SimulationJobsTableModel.iColSubmitDate).setCellRenderer(dateTimeCellRenderer);
        table.getColumnModel().getColumn(SimulationJobsTableModel.iColHasData).setCellRenderer(hasDataCellRenderer);
        // table.getColumnModel().getColumn(SimulationJobsTableModel.iColDepiction).setMinWidth(400);
        // table.getColumnModel().getColumn(SimulationJobsTableModel.iColStatus).setPreferredWidth(30);
        // table.getColumnModel().getColumn(SimulationJobsTableModel.iColStatus).setMaxWidth(30);
        table.setAutoResizeMode(JTable.AUTO_RESIZE_LAST_COLUMN);
        refreshInterface();
    } catch (java.lang.Throwable ivjExc) {
        handleException(ivjExc);
    }
}
Also used : JPanel(javax.swing.JPanel) GridBagConstraints(java.awt.GridBagConstraints) Insets(java.awt.Insets) GridBagLayout(java.awt.GridBagLayout) TitledBorder(javax.swing.border.TitledBorder) JTextField(javax.swing.JTextField) SimpleJobStatus(cbit.vcell.server.SimpleJobStatus) VCellSortTableModel(cbit.vcell.client.desktop.biomodel.VCellSortTableModel) MouseEvent(java.awt.event.MouseEvent) SchedulerStatus(cbit.vcell.server.SimulationJobStatus.SchedulerStatus) JLabel(javax.swing.JLabel) Dimension(java.awt.Dimension) Point(java.awt.Point) GridBagConstraints(java.awt.GridBagConstraints) Point(java.awt.Point) Date(java.util.Date) JTable(javax.swing.JTable) DateFormat(java.text.DateFormat) SimpleDateFormat(java.text.SimpleDateFormat) DefaultScrollTableCellRenderer(org.vcell.util.gui.DefaultScrollTableCellRenderer) EventObject(java.util.EventObject) EditorScrollTable(org.vcell.util.gui.EditorScrollTable) Border(javax.swing.border.Border) TitledBorder(javax.swing.border.TitledBorder) EtchedBorder(javax.swing.border.EtchedBorder) SimpleDateFormat(java.text.SimpleDateFormat)

Example 67 with TitledBorder

use of javax.swing.border.TitledBorder in project vcell by virtualcell.

the class ComsolConfigurationPanel method initialize.

private void initialize() {
    setLayout(new BorderLayout());
    Border margin = new EmptyBorder(5, 3, 1, 1);
    Border loweredEtchedBorder = BorderFactory.createEtchedBorder(EtchedBorder.LOWERED);
    TitledBorder panelBorder = BorderFactory.createTitledBorder(loweredEtchedBorder, " Comsol Properties ");
    panelBorder.setTitleJustification(TitledBorder.LEFT);
    panelBorder.setTitlePosition(TitledBorder.TOP);
    panelBorder.setTitleFont(getFont().deriveFont(Font.BOLD));
    JPanel jpanel = new JPanel();
    jpanel.setBorder(new CompoundBorder(margin, panelBorder));
    add(jpanel, BorderLayout.CENTER);
    jpanel.setLayout(new GridBagLayout());
    GridBagConstraints gbc = new GridBagConstraints();
    gbc.weighty = 0;
    gbc.fill = GridBagConstraints.HORIZONTAL;
    gbc.anchor = GridBagConstraints.NORTHWEST;
    gbc.gridheight = 1;
    // =============================================================================
    // 
    // comsol root dir
    // 
    // =============================================================================
    int gridy = 0;
    JLabel comsolRootLabel = new JLabel("<html>Comsol Multiphysics directory (requires a local COMSOL Multiphysics installation, see <a href='http://comsol.com'>Comsol.com</a>)</html>");
    gbc.gridx = 0;
    gbc.gridy = gridy;
    gbc.gridwidth = 2;
    gbc.weightx = 0.5;
    // top, left bottom, right
    gbc.insets = new Insets(4, 4, 2, 4);
    jpanel.add(comsolRootLabel, gbc);
    gridy++;
    comsolRootTextField = new JTextField();
    gbc.gridx = 0;
    gbc.gridy = gridy;
    gbc.gridwidth = 1;
    gbc.weightx = 0.5;
    gbc.ipady = 1;
    gbc.insets = new Insets(4, 4, 2, 2);
    jpanel.add(comsolRootTextField, gbc);
    comsolRootTextField.addActionListener((ActionEvent e) -> {
        VCellConfiguration.setFileProperty(PropertyLoader.comsolRootDir, new File(comsolRootTextField.getText()));
    });
    JButton findComsolButton = new JButton("Browse...");
    findComsolButton.addActionListener((ActionEvent e) -> browseComsolDirectory());
    gbc.gridx = 1;
    gbc.gridy = gridy;
    gbc.gridwidth = 1;
    gbc.weightx = 0.0;
    gbc.ipady = 0;
    gbc.insets = new Insets(3, 2, 2, 4);
    jpanel.add(findComsolButton, gbc);
    // gridy += 4;
    // gbc.gridx=0;
    // gbc.gridy=5;
    // gbc.gridwidth=2;
    // jpanel.add(new JSeparator(), gbc);
    // =============================================================================
    // 
    // comsol plugins dir
    // 
    // =============================================================================
    gridy++;
    JLabel comsolJarLabel = new JLabel("Comsol plugins directory (vcell.comsol.jardir)");
    gbc.gridx = 0;
    gbc.gridy = gridy;
    gbc.gridwidth = 2;
    gbc.weightx = 0.5;
    gbc.insets = new Insets(8, 4, 2, 4);
    jpanel.add(comsolJarLabel, gbc);
    gridy++;
    comsolJarTextField = new JTextField();
    gbc.gridx = 0;
    gbc.gridy = gridy;
    gbc.gridwidth = 2;
    gbc.weightx = 0.5;
    gbc.ipady = 1;
    gbc.insets = new Insets(4, 4, 2, 4);
    jpanel.add(comsolJarTextField, gbc);
    gridy++;
    gbc.gridx = 0;
    gbc.gridy = gridy;
    gbc.gridwidth = 3;
    gbc.weightx = 1;
    // fake cell used for filling all the vertical empty space
    gbc.weighty = 1;
    gbc.ipady = 0;
    gbc.anchor = GridBagConstraints.WEST;
    jpanel.add(new JLabel(""), gbc);
    comsolRootTextField.addActionListener((ActionEvent e) -> {
        VCellConfiguration.setFileProperty(PropertyLoader.comsolJarDir, new File(comsolJarTextField.getText()));
    });
    initComsolValues();
}
Also used : JPanel(javax.swing.JPanel) GridBagConstraints(java.awt.GridBagConstraints) Insets(java.awt.Insets) GridBagLayout(java.awt.GridBagLayout) ActionEvent(java.awt.event.ActionEvent) JButton(javax.swing.JButton) JLabel(javax.swing.JLabel) TitledBorder(javax.swing.border.TitledBorder) JTextField(javax.swing.JTextField) BorderLayout(java.awt.BorderLayout) CompoundBorder(javax.swing.border.CompoundBorder) EmptyBorder(javax.swing.border.EmptyBorder) Border(javax.swing.border.Border) CompoundBorder(javax.swing.border.CompoundBorder) EmptyBorder(javax.swing.border.EmptyBorder) TitledBorder(javax.swing.border.TitledBorder) EtchedBorder(javax.swing.border.EtchedBorder) File(java.io.File)

Example 68 with TitledBorder

use of javax.swing.border.TitledBorder in project vcell by virtualcell.

the class PythonConfigurationPanel method initialize.

private void initialize() {
    setLayout(new BorderLayout());
    Border margin = new EmptyBorder(5, 3, 1, 1);
    Border loweredEtchedBorder = BorderFactory.createEtchedBorder(EtchedBorder.LOWERED);
    TitledBorder panelBorder = BorderFactory.createTitledBorder(loweredEtchedBorder, " Python Properties ");
    panelBorder.setTitleJustification(TitledBorder.LEFT);
    panelBorder.setTitlePosition(TitledBorder.TOP);
    panelBorder.setTitleFont(getFont().deriveFont(Font.BOLD));
    JPanel jpanel = new JPanel();
    jpanel.setBorder(new CompoundBorder(margin, panelBorder));
    add(jpanel, BorderLayout.CENTER);
    jpanel.setLayout(new GridBagLayout());
    GridBagConstraints gbc = new GridBagConstraints();
    gbc.weighty = 0;
    gbc.fill = GridBagConstraints.HORIZONTAL;
    gbc.anchor = GridBagConstraints.NORTHWEST;
    gbc.gridheight = 1;
    // CondaSupport.installInBackground();  // or not in background ... ?????
    // =============================================================================
    // 
    // python (anaconda) executable
    // 
    // =============================================================================
    int gridy = 0;
    String managedMiniconda = new File(ResourceUtil.getVcellHome(), "Miniconda").getAbsolutePath();
    String vcellPythonText = "Python is required for parameter estimation and other analysis\n\n" + "VCell manages a dedicated Miniconda python installation \n" + "at " + managedMiniconda + ".  \n" + "For more information about Miniconda, \n" + "see https://www.continuum.io\n\n";
    JTextArea vcellPythonTextArea = new JTextArea(vcellPythonText);
    gbc.gridx = 0;
    gbc.gridy = gridy;
    gbc.gridwidth = 2;
    gbc.weightx = 0.5;
    gbc.weighty = 1;
    // top, left bottom, right
    gbc.insets = new Insets(4, 4, 2, 4);
    jpanel.add(vcellPythonTextArea, gbc);
    gridy++;
    String providedPythonText = "Alternate Anaconda/Miniconda installation directory.";
    JLabel providedPythonLabel = new JLabel(providedPythonText);
    gbc.gridx = 0;
    gbc.gridy = gridy;
    gbc.gridwidth = 2;
    gbc.weightx = 0.5;
    // top, left bottom, right
    gbc.insets = new Insets(4, 4, 1, 4);
    jpanel.add(providedPythonLabel, gbc);
    gridy++;
    pythonExeTextField = new JTextField();
    gbc.gridx = 0;
    gbc.gridy = gridy;
    gbc.gridwidth = 1;
    gbc.weightx = 0.5;
    gbc.weighty = 0.0;
    gbc.ipady = 1;
    gbc.insets = new Insets(0, 4, 2, 2);
    jpanel.add(pythonExeTextField, gbc);
    pythonExeTextField.addActionListener((ActionEvent e) -> {
        VCellConfiguration.setFileProperty(PropertyLoader.pythonExe, new File(pythonExeTextField.getText()));
    });
    JButton findPythonButton = new JButton("Browse...");
    findPythonButton.addActionListener((ActionEvent e) -> browsePythonExe());
    gbc.gridx = 1;
    gbc.gridy = gridy;
    gbc.gridwidth = 1;
    gbc.weightx = 0.0;
    gbc.ipady = 0;
    gbc.insets = new Insets(3, 2, 2, 4);
    jpanel.add(findPythonButton, gbc);
    // gridy += 4;
    // gbc.gridx=0;
    // gbc.gridy=5;
    // gbc.gridwidth=2;
    // jpanel.add(new JSeparator(), gbc);
    pythonExeTextField.addActionListener((ActionEvent e) -> {
        VCellConfiguration.setFileProperty(PropertyLoader.pythonExe, new File(pythonExeTextField.getText()));
    });
    initPythonValues();
}
Also used : JPanel(javax.swing.JPanel) GridBagConstraints(java.awt.GridBagConstraints) JTextArea(javax.swing.JTextArea) Insets(java.awt.Insets) GridBagLayout(java.awt.GridBagLayout) ActionEvent(java.awt.event.ActionEvent) JButton(javax.swing.JButton) JLabel(javax.swing.JLabel) TitledBorder(javax.swing.border.TitledBorder) JTextField(javax.swing.JTextField) BorderLayout(java.awt.BorderLayout) CompoundBorder(javax.swing.border.CompoundBorder) EmptyBorder(javax.swing.border.EmptyBorder) Border(javax.swing.border.Border) CompoundBorder(javax.swing.border.CompoundBorder) TitledBorder(javax.swing.border.TitledBorder) EmptyBorder(javax.swing.border.EmptyBorder) EtchedBorder(javax.swing.border.EtchedBorder) File(java.io.File)

Example 69 with TitledBorder

use of javax.swing.border.TitledBorder in project vcell by virtualcell.

the class BatchRunDetailsPanel method getBottomPanel.

// end of method setupToolBar()
// set up bottom component function
public JPanel getBottomPanel() {
    if (botPanel == null) {
        botPanel = new JPanel();
        botPanel.setLayout(new BorderLayout());
        botPanel.add(getParameterScrollPanel(), BorderLayout.CENTER);
        TitledBorder tb = new TitledBorder(new EtchedBorder(), "Parameters:", TitledBorder.DEFAULT_JUSTIFICATION, TitledBorder.DEFAULT_POSITION, new Font("Tahoma", Font.PLAIN, 11));
        botPanel.setBorder(tb);
    }
    return botPanel;
}
Also used : JPanel(javax.swing.JPanel) EtchedBorder(javax.swing.border.EtchedBorder) BorderLayout(java.awt.BorderLayout) TitledBorder(javax.swing.border.TitledBorder) Font(java.awt.Font)

Example 70 with TitledBorder

use of javax.swing.border.TitledBorder in project languagetool by languagetool-org.

the class FontChooser method initComponents.

private void initComponents() {
    KeyStroke stroke = KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0);
    getRootPane().getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put(stroke, "Hide");
    getRootPane().getActionMap().put("Hide", new AbstractAction() {

        @Override
        public void actionPerformed(ActionEvent e) {
            selectedFont = null;
            setVisible(false);
        }
    });
    this.addWindowListener(new WindowAdapter() {

        @Override
        public void windowClosing(WindowEvent e) {
            selectedFont = null;
            setVisible(false);
        }
    });
    setTitle(messages.getString("FontChooser.title"));
    fontStylesArray = new String[] { messages.getString("FontChooser.style.plain"), messages.getString("FontChooser.style.bold"), messages.getString("FontChooser.style.italic"), messages.getString("FontChooser.style.bold_italic") };
    String[] fontNamesArray = GraphicsEnvironment.getLocalGraphicsEnvironment().getAvailableFontFamilyNames();
    getContentPane().setLayout(new GridBagLayout());
    GridBagConstraints c = new GridBagConstraints();
    c.insets = new Insets(4, 4, 4, 4);
    JPanel fontPanel = new JPanel(new GridBagLayout());
    c.gridx = 0;
    c.gridy = 0;
    c.fill = GridBagConstraints.HORIZONTAL;
    JLabel fontNameLabel = new JLabel(messages.getString("FontChooser.label.name"));
    fontPanel.add(fontNameLabel, c);
    c.gridx = 1;
    c.gridy = 0;
    JLabel fontStyleLabel = new JLabel(messages.getString("FontChooser.label.style"));
    fontPanel.add(fontStyleLabel, c);
    c.gridx = 2;
    c.gridy = 0;
    JLabel fontSizeLabel = new JLabel(messages.getString("FontChooser.label.size"));
    fontPanel.add(fontSizeLabel, c);
    c.gridx = 0;
    c.gridy = 1;
    c.weightx = 1.0;
    c.fill = GridBagConstraints.HORIZONTAL;
    fontNameTextField = new JTextField();
    fontNameTextField.setEnabled(false);
    fontNameTextField.getDocument().addDocumentListener(this);
    fontPanel.add(fontNameTextField, c);
    c.weightx = 0.0;
    c.gridx = 1;
    c.gridy = 1;
    fontStyleTextField = new JTextField();
    fontStyleTextField.setEnabled(false);
    fontStyleTextField.getDocument().addDocumentListener(this);
    fontPanel.add(fontStyleTextField, c);
    c.gridx = 2;
    c.gridy = 1;
    fontSizeTextField = new JTextField();
    fontSizeTextField.setColumns(4);
    fontSizeTextField.getDocument().addDocumentListener(this);
    fontPanel.add(fontSizeTextField, c);
    c.gridx = 0;
    c.gridy = 2;
    c.weightx = 1.0;
    c.weighty = 1;
    c.fill = GridBagConstraints.BOTH;
    fontNameList = new JList<>(fontNamesArray);
    fontNameList.addListSelectionListener(this);
    fontNameList.setVisibleRowCount(5);
    fontNameList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    JScrollPane fontNameListPane = new JScrollPane(fontNameList, JScrollPane.VERTICAL_SCROLLBAR_ALWAYS, JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
    fontPanel.add(fontNameListPane, c);
    c.gridx = 1;
    c.gridy = 2;
    c.weightx = 0.5;
    fontStyleList = new JList<>(fontStylesArray);
    fontStyleList.addListSelectionListener(this);
    fontStyleList.setVisibleRowCount(5);
    fontStyleList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    JScrollPane fontStyleListPane = new JScrollPane(fontStyleList, JScrollPane.VERTICAL_SCROLLBAR_ALWAYS, JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
    fontPanel.add(fontStyleListPane, c);
    c.gridx = 2;
    c.gridy = 2;
    fontSizeList = new JList<>(fontSizesArray);
    fontSizeList.addListSelectionListener(this);
    fontSizeList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    fontSizeList.setVisibleRowCount(5);
    JScrollPane fontSizeListPane = new JScrollPane(fontSizeList, JScrollPane.VERTICAL_SCROLLBAR_ALWAYS, JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
    fontPanel.add(fontSizeListPane, c);
    c.insets = new Insets(8, 8, 4, 8);
    c.gridx = 0;
    c.gridy = 0;
    c.weightx = 0.0;
    c.weighty = 0.4;
    getContentPane().add(fontPanel, c);
    c.insets = new Insets(4, 8, 4, 8);
    c.gridx = 0;
    c.gridy = 1;
    c.weightx = 1.0;
    c.weighty = 0.6;
    previewArea = new JTextArea(messages.getString("FontChooser.pangram"));
    previewArea.setLineWrap(true);
    previewArea.setRows(4);
    JScrollPane pane = new JScrollPane(previewArea);
    TitledBorder border = BorderFactory.createTitledBorder(messages.getString("FontChooser.preview"));
    pane.setBorder(border);
    getContentPane().add(pane, c);
    JPanel buttonPanel = new JPanel(new GridBagLayout());
    c.insets = new Insets(4, 4, 4, 4);
    c.gridx = 0;
    c.gridy = 0;
    c.weightx = 1.0;
    c.weighty = 0.0;
    c.anchor = GridBagConstraints.LINE_START;
    c.fill = GridBagConstraints.NONE;
    JButton resetButton = new JButton(Tools.getLabel(messages.getString("FontChooser.reset")));
    resetButton.setMnemonic(Tools.getMnemonic(messages.getString("FontChooser.reset")));
    resetButton.setActionCommand(ACTION_COMMAND_RESET);
    resetButton.addActionListener(this);
    buttonPanel.add(resetButton, c);
    c.gridx = 1;
    c.gridy = 0;
    c.weightx = 0.0;
    c.weighty = 0.0;
    c.anchor = GridBagConstraints.LINE_END;
    c.fill = GridBagConstraints.NONE;
    JButton cancelButton = new JButton(Tools.getLabel(messages.getString("guiCancelButton")));
    cancelButton.setMnemonic(Tools.getMnemonic(messages.getString("guiCancelButton")));
    cancelButton.setActionCommand(ACTION_COMMAND_CANCEL);
    cancelButton.addActionListener(this);
    buttonPanel.add(cancelButton, c);
    c.gridx = 2;
    c.gridy = 0;
    JButton okButton = new JButton(Tools.getLabel(messages.getString("guiOKButton")));
    okButton.setMnemonic(Tools.getMnemonic(messages.getString("guiOKButton")));
    okButton.setActionCommand(ACTION_COMMAND_OK);
    okButton.addActionListener(this);
    buttonPanel.add(okButton, c);
    c.insets = new Insets(4, 8, 8, 8);
    c.gridx = 0;
    c.gridy = 2;
    c.anchor = GridBagConstraints.LINE_START;
    c.fill = GridBagConstraints.HORIZONTAL;
    getContentPane().add(buttonPanel, c);
    this.defaultFont = previewArea.getFont();
    setDefaultFont();
    getRootPane().setDefaultButton(cancelButton);
    this.applyComponentOrientation(ComponentOrientation.getOrientation(Locale.getDefault()));
    pack();
}
Also used : JScrollPane(javax.swing.JScrollPane) JPanel(javax.swing.JPanel) GridBagConstraints(java.awt.GridBagConstraints) Insets(java.awt.Insets) JTextArea(javax.swing.JTextArea) GridBagLayout(java.awt.GridBagLayout) ActionEvent(java.awt.event.ActionEvent) JButton(javax.swing.JButton) WindowAdapter(java.awt.event.WindowAdapter) JLabel(javax.swing.JLabel) JTextField(javax.swing.JTextField) TitledBorder(javax.swing.border.TitledBorder) WindowEvent(java.awt.event.WindowEvent) KeyStroke(javax.swing.KeyStroke) AbstractAction(javax.swing.AbstractAction)

Aggregations

TitledBorder (javax.swing.border.TitledBorder)143 JPanel (javax.swing.JPanel)94 GridBagConstraints (java.awt.GridBagConstraints)59 GridBagLayout (java.awt.GridBagLayout)50 JLabel (javax.swing.JLabel)50 BorderLayout (java.awt.BorderLayout)45 Insets (java.awt.Insets)43 JScrollPane (javax.swing.JScrollPane)34 Dimension (java.awt.Dimension)30 JButton (javax.swing.JButton)29 EtchedBorder (javax.swing.border.EtchedBorder)28 ActionEvent (java.awt.event.ActionEvent)25 EmptyBorder (javax.swing.border.EmptyBorder)25 Border (javax.swing.border.Border)23 ActionListener (java.awt.event.ActionListener)21 JCheckBox (javax.swing.JCheckBox)19 GridLayout (java.awt.GridLayout)18 JTextField (javax.swing.JTextField)16 Color (java.awt.Color)15 Box (javax.swing.Box)12