Example usage for javax.swing.event TableModelListener TableModelListener

List of usage examples for javax.swing.event TableModelListener TableModelListener

Introduction

In this page you can find the example usage for javax.swing.event TableModelListener TableModelListener.

Prototype

TableModelListener

Source Link

Usage

From source file:com.jskj.asset.client.panel.slgl.DiZhiYiHaoPinLingYongTuiKuJDialog.java

/**
 * Creates new form GuDingZiChanRuKu/*ww  w . j  av a  2 s.c  o  m*/
 */
public DiZhiYiHaoPinLingYongTuiKuJDialog() {
    super();
    initComponents();

    zc = new ArrayList<ZiChanLieBiaotb>();
    userId = AssetClientApp.getSessionMap().getUsertb().getUserId();
    userName = AssetClientApp.getSessionMap().getUsertb().getUserName();
    department = AssetClientApp.getSessionMap().getDepartment().getDepartmentName();
    kucunmap = new HashMap();

    jTextFieldShenqingren.setText(userName);
    jTextFieldDept.setText(department);

    jTextField1.setText(DanHao.getDanHao("YHTK"));
    jTextField1.setEditable(false);

    jTextField2.setText(dateformate.format(new Date()).toString());
    jTextField2.setEditable(false);

    final BaseTable.SingleEditRowTable editTable = ((BaseTable) jTable1).createSingleEditModel(
            new String[][] { { "dzyhpId", "??" }, { "dzyhpName", "???", "true" },
                    { "dzyhpType", "?" }, { "dzyhpPinpai", "?", "false" },
                    { "dzyhpXinghao", "?" }, { "unitId", "??", "false" },
                    { "quantity", "?", "true" }, { "lylb.price", "", "false" },
                    { "total", "?" }, { "lylb.pihao", "??", "false" } });

    editTable.registerPopup(1, new IPopupBuilder() {
        @Override
        public int getType() {
            return IPopupBuilder.TYPE_POPUP_TABLE;
        }

        @Override
        public String getWebServiceURI() {
            return Constants.HTTP + Constants.APPID + "dizhiyihaopin/findtk";
        }

        @Override
        public String getConditionSQL() {
            int selectedColumn = jTable1.getSelectedColumn();
            int selectedRow = jTable1.getSelectedRow();
            Object newColumnObj = jTable1.getValueAt(selectedRow, selectedColumn);
            String sql = "";
            if (newColumnObj instanceof String && !newColumnObj.toString().trim().equals("")) {
                sql = "(dzyhp_name like \"%" + newColumnObj.toString() + "%\"" + " or zujima like \"%"
                        + newColumnObj.toString().toLowerCase() + "%\")";
            }
            return sql;
        }

        @Override
        public String[][] displayColumns() {
            return new String[][] { { "dzyhpId", "?ID" }, { "dzyhpName", "???" },
                    { "lylb.pihao", "??" } };
        }

        @Override
        public void setBindedMap(HashMap bindedMap) {
            if (bindedMap != null) {
                Object dzyhpId = bindedMap.get("dzyhpId");
                Object dzyhpName = bindedMap.get("dzyhpName");
                Object dzyhpType = bindedMap.get("dzyhpType");
                Object dzyhpPinpai = bindedMap.get("dzyhpPinpai");
                Object gdzcXinghao = bindedMap.get("dzyhpXinghao");
                //                    Object dzyhpValue = bindedMap.get("dzyhpValue");
                Object gdzcDanwei = bindedMap.get("unitId");

                editTable.insertValue(0, dzyhpId);
                editTable.insertValue(1, dzyhpName);
                editTable.insertValue(2, dzyhpType);
                editTable.insertValue(3, dzyhpPinpai);
                editTable.insertValue(4, gdzcXinghao);
                editTable.insertValue(5, gdzcDanwei);

                HashMap map = (HashMap) bindedMap.get("lylb");
                pihao = (String) map.get("pihao");
                saleprice = Float.parseFloat(map.get("price").toString());
                editTable.insertValue(7, saleprice);
                editTable.insertValue(9, pihao);
                Object lycount = bindedMap.get("count");

                //                    ZiChanLieBiaotb zclb = new ZiChanLieBiaotb();
                //                    zclb.setCgsqId(jTextField1.getText());
                //                    zclb.setCgzcId((Integer)dzyhpId);
                //                    zclb.setQuantity(0);
                //                    zc.add(zclb);

                //???
                kucunmap.put(dzyhpId + pihao, lycount);
            }

        }
    });

    jTable1.getModel().addTableModelListener(new TableModelListener() {
        @Override
        public void tableChanged(TableModelEvent e) {

            int col = e.getColumn();
            int row = e.getFirstRow();

            if (col == 6 || col == 7) {
                if ((!(("" + jTable1.getValueAt(row, 6)).equals("")))
                        && (!(("" + jTable1.getValueAt(row, 7)).equals("")))) {
                    int count = Integer.parseInt("" + jTable1.getValueAt(row, 6));
                    float price = Float.parseFloat("" + jTable1.getValueAt(row, 7));
                    jTable1.setValueAt(price * count, row, 8);
                }
                int rows = jTable1.getRowCount();
                total = 0;
                for (int i = 0; i < rows; i++) {
                    if (!(("" + jTable1.getValueAt(i, 8)).equals(""))) {
                        total += Float.parseFloat("" + jTable1.getValueAt(i, 8));
                    }
                }
                totalprice.setText(total + "");
            }
        }

    });
}

From source file:ec.util.chart.swing.JTimeSeriesRendererSupportDemo.java

private Component createSeriesTable(ListSelectionModel seriesSelectionModel) {
    XTable result = new XTable();
    result.setSelectionModel(seriesSelectionModel);
    result.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    result.setModel(new SeriesModel(support.seriesInfos));
    ColorCellRenderer r0 = new ColorCellRenderer(FontAwesome.FA_CIRCLE_O);
    result.setDefaultRenderer(Color.class, r0);
    result.setDefaultEditor(Color.class, new ColorCellEditor(colorSchemeSupport, r0));
    ColorCellRenderer r3 = new ColorCellRenderer(FontAwesome.FA_FONT);
    result.getColumnModel().getColumn(3).setCellRenderer(r3);
    result.getColumnModel().getColumn(3).setCellEditor(new ColorCellEditor(colorSchemeSupport, r3));
    result.setDefaultRenderer(Font.class, FontCellRenderer.INSTANCE);
    result.setDefaultEditor(Font.class, new FontCellEditor());
    result.setDefaultRenderer(Stroke.class, StrokeCellRenderer.INSTANCE);
    result.setDefaultEditor(Stroke.class, new StrokeCellEditor());
    result.getModel().addTableModelListener(new TableModelListener() {
        @Override//w w  w.j  av  a  2 s .c o m
        public void tableChanged(TableModelEvent e) {
            chart.fireChartChanged();
        }
    });
    return ModernUI.withEmptyBorders(new JScrollPane(result));
}

From source file:SampleTableModel.java

private BarChart createBarChart() {
    CategoryAxis xAxis = new CategoryAxis();
    xAxis.setCategories(FXCollections.<String>observableArrayList(tableModel.getColumnNames()));
    xAxis.setLabel("Year");

    double tickUnit = tableModel.getTickUnit();

    NumberAxis yAxis = new NumberAxis();
    yAxis.setTickUnit(tickUnit);//  www. j  a v a 2  s  . c o m
    yAxis.setLabel("Units Sold");

    final BarChart chart = new BarChart(xAxis, yAxis, tableModel.getBarChartData());
    tableModel.addTableModelListener(new TableModelListener() {

        public void tableChanged(TableModelEvent e) {
            if (e.getType() == TableModelEvent.UPDATE) {
                final int row = e.getFirstRow();
                final int column = e.getColumn();
                final Object value = ((SampleTableModel) e.getSource()).getValueAt(row, column);

                Platform.runLater(new Runnable() {
                    public void run() {
                        XYChart.Series<String, Number> s = (XYChart.Series<String, Number>) chart.getData()
                                .get(row);
                        BarChart.Data data = s.getData().get(column);
                        data.setYValue(value);
                    }
                });
            }
        }
    });
    return chart;
}

From source file:com.hp.alm.ali.idea.ui.MultipleItemsDialog.java

public MultipleItemsDialog(Project project, String title, final MultipleItemsDialogModel<K, E> model) {
    super(project, title, true);

    this.model = model;

    mySelectionModel = new MySelectionModel();
    myListSelectionListener = new MyListSelectionListener();

    tooMany = new JLabel("Too many results, narrow your search");
    tooMany.setBorder(BorderFactory.createEtchedBorder());
    tooMany.setVisible(false);//from  w  w  w .  ja  v  a  2 s.  co  m
    selected = new JLabel("Showing currently selected items");
    selected.setVisible(false);
    toggleSelected = new JToggleButton();
    toggleSelected.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            model.setShowingSelected(toggleSelected.isSelected());
            if (!model.isShowingSelected() && !model.getSelectedFields().isEmpty()) {
                updateSelectionFromModel();
            } else if (model.isShowingSelected()) {
                header.getFilterEditor(1).setContent("");
            }
        }
    });
    updateSelected();

    table = new JBTable() {
        @Override
        public void changeSelection(int rowIndex, int columnIndex, boolean toggle, boolean extend) {
            int column = convertColumnIndexToModel(columnIndex);
            mySelectionModel.setFirstColumnEvent(column == 0);
            super.changeSelection(rowIndex, columnIndex, toggle, extend);
        }
    };
    table.setRowSelectionAllowed(true);
    table.setColumnSelectionAllowed(false);
    table.setAutoCreateColumnsFromModel(false);
    table.setModel(model);
    final MyTableRowSorter sorter = new MyTableRowSorter(model);
    table.setRowSorter(sorter);
    table.setDefaultRenderer(Boolean.class, new MyRenderer());
    table.setAutoResizeMode(JTable.AUTO_RESIZE_SUBSEQUENT_COLUMNS);
    table.setSelectionModel(mySelectionModel);

    sorter.setIgnoreAddRowSorterListener(true); // prevent auto-selection (functionality not accessible via proper API)
    header = new TableFilterHeader(table);
    sorter.setIgnoreAddRowSorterListener(false);

    sorter.setSortKeys(Arrays.asList(new RowSorter.SortKey(1, SortOrder.ASCENDING)));
    JPanel panel = new JPanel(new BorderLayout());
    JPanel toolbar = new JPanel(new BorderLayout());
    toolbar.setBorder(BorderFactory.createEtchedBorder());
    panel.add(toolbar, BorderLayout.NORTH);
    toolbar.add(toggleSelected, BorderLayout.EAST);

    if (model.isMultiple()) {
        table.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION);

        table.getColumnModel().addColumn(createColumn(0, model, 45, 45));
        header.getFilterEditor(0).setEditable(false);
        header.getFilterEditor(0).setUserInteractionEnabled(false);

        final LinkListener selectUnselect = new LinkListener() {
            public void linkSelected(LinkLabel aSource, Object aLinkData) {
                if (model.isShowingSelected()) {
                    if (!Boolean.TRUE.equals(aLinkData)) {
                        List<Integer> ixs = new ArrayList<Integer>();
                        for (int i = 0; i < sorter.getViewRowCount(); i++) {
                            ixs.add(sorter.convertRowIndexToModel(i));
                        }
                        // make sure indexes are not affected by removal by starting from the last
                        Collections.sort(ixs);
                        Collections.reverse(ixs);
                        for (int ix : ixs) {
                            model.setValueAt(aLinkData, ix, 0);
                        }
                    }
                } else {
                    if (Boolean.TRUE.equals(aLinkData)) {
                        mySelectionModel.doAddSelectionInterval(0, table.getRowCount() - 1);
                    } else {
                        mySelectionModel.removeSelectionInterval(0, table.getRowCount() - 1);
                    }
                }
            }
        };

        JPanel left = new JPanel(new FlowLayout(FlowLayout.LEFT));
        left.add(new LinkLabel("Select All", IconLoader.getIcon("/actions/selectall.png"), selectUnselect,
                true));
        left.add(new LinkLabel("Unselect All", IconLoader.getIcon("/actions/unselectall.png"), selectUnselect,
                false));
        toolbar.add(left, BorderLayout.WEST);
    } else {
        table.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    }
    table.getColumnModel().addColumn(createColumn(1, model, 450, null));
    table.getSelectionModel().addListSelectionListener(myListSelectionListener);

    model.addTableModelListener(new TableModelListener() {
        @Override
        public void tableChanged(TableModelEvent e) {
            selected.setVisible(model.isShowingSelected());
            tooMany.setVisible(model.hasMore() && !model.isShowingSelected());
            updateSelected();
        }
    });

    JPanel contentPanel = new JPanel(new BorderLayout());
    contentPanel.add(selected, BorderLayout.NORTH);
    contentPanel.add(new JBScrollPane(table), BorderLayout.CENTER);
    contentPanel.add(tooMany, BorderLayout.SOUTH);
    panel.add(contentPanel, BorderLayout.CENTER);
    JPanel buttons = new JPanel();
    okButton = new JButton("OK");
    okButton.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent actionEvent) {
            ok = true;
            close(true);
        }
    });
    buttons.add(okButton);
    JButton cancel = new JButton("Cancel");
    cancel.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent actionEvent) {
            close(false);
        }
    });
    buttons.add(cancel);
    panel.add(buttons, BorderLayout.SOUTH);
    getContentPane().add(panel, BorderLayout.CENTER);

    pack();
    setResizable(false);
    centerOnOwner();

    requestPropertyFilterFocus(header);

    load(true, null);
}

From source file:gov.nij.er.ui.EntityResolutionDemo.java

private void setupWidgetListeners() {
    resolveButton.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent arg0) {
            runResolution();//from ww w  . ja  v a 2s .  co  m
        }
    });

    parametersTableModel.addTableModelListener(new TableModelListener() {
        public void tableChanged(TableModelEvent arg0) {
            updateUIForParameterChange();
        }
    });

    new RecordCountLabelUpdateTreeModelListener(rawDataFilteredTreeModel, rawRecordCountLabel);
    new RecordCountLabelUpdateTreeModelListener(resolvedDataTreeModel, resolvedRecordCountLabel);

    filterForSelectedCheckBox.addActionListener(new ActionListener() {

        public void actionPerformed(ActionEvent e) {
            rawDataFilteredTreeModel.setFiltered(filterForSelectedCheckBox.isSelected());
        }
    });

    resolvedDataTree.addTreeSelectionListener(new TreeSelectionListener() {

        public void valueChanged(TreeSelectionEvent e) {
            TreePath selectedPath = e.getPath();
            Set<String> recordIds = resolvedDataTreeModel.getRecordIdsForPath(selectedPath);
            rawDataFilteredTreeModel.setFilteredRecordIds(recordIds);
        }
    });

}

From source file:hermes.browser.dialog.HermesAdminFactoryConfigPanel.java

public void setConfig(String classPathId, ProviderExtConfig newConfig) {
    this.config = newConfig;

    if (cfComboModel.getIndexOf(ConfigDAOImpl.DEFAULT_PLUGIN) == -1) {
        cfComboModel.addElement(ConfigDAOImpl.DEFAULT_PLUGIN);
    }//from   w  w w  .  j  a va2s.  c  om

    for (Iterator iter = HermesBrowser.getConfigDAO().getAdminFactories().iterator(); iter.hasNext();) {
        String adminFactoryName = (String) iter.next();
        String pluginName = HermesBrowser.getConfigDAO().getPlugInName(adminFactoryName);

        if (cfComboModel.getIndexOf(pluginName) == -1) {
            cfComboModel.addElement(pluginName);
        }
    }

    cfComboModel.setSelectedItem(HermesBrowser.getConfigDAO().getPlugInName(config.getClassName()));

    try {
        ClassLoaderManager classLoaderManager = (ClassLoaderManager) SingletonManager
                .get(ClassLoaderManager.class);
        ClassLoader classLoader = classLoaderManager.getClassLoader(classPathId);
        Thread.currentThread().setContextClassLoader(classLoader);

        bean = (HermesAdminFactory) classLoader.loadClass(config.getClassName()).newInstance();
    } catch (Throwable e) {
        cat.error(e.getMessage(), e);
    }

    try {

        if (config.getProperties() == null) {
            try {
                config.setProperties(HermesBrowser.getBrowser().getConfigDAO().createPropertySet());
            } catch (HermesException ex) {
                throw new HermesRuntimeException(ex);
            }
        }

        propertyTableModel = new PropertySetTableModel(bean, config.getProperties(), new HashSet());
        propertyTable.setModel(propertyTableModel);

        updateCellEditor();

        if (propertyTableModel.getProperties().size() == 0) {
            addItem.setEnabled(false);
            removeItem.setEnabled(false);
        }
    } catch (Throwable ex) {
        cat.error(ex.getMessage(), ex);
    }

    propertyTableModel.addTableModelListener(new TableModelListener() {
        public void tableChanged(TableModelEvent arg0) {
            dialog.setDirty();
        }
    });

}

From source file:ec.util.chart.swing.JTimeSeriesRendererSupportDemo.java

private Component createObsTable(ListSelectionModel seriesSelectionModel) {
    final XTable result = new XTable();
    ColorCellRenderer renderer = new ColorCellRenderer(FontAwesome.FA_CIRCLE_O);
    result.setDefaultRenderer(Color.class, renderer);
    result.setDefaultEditor(Color.class, new ColorCellEditor(colorSchemeSupport, renderer));
    result.setDefaultRenderer(Font.class, FontCellRenderer.INSTANCE);
    result.setDefaultEditor(Font.class, new FontCellEditor());
    result.setDefaultRenderer(Stroke.class, StrokeCellRenderer.INSTANCE);
    result.setDefaultEditor(Stroke.class, new StrokeCellEditor());
    seriesSelectionModel.addListSelectionListener(new ListSelectionListener() {
        @Override/*  ww w.  j  a v a  2 s  . c o m*/
        public void valueChanged(ListSelectionEvent e) {
            if (!e.getValueIsAdjusting()) {
                int index = e.getFirstIndex();
                result.setModel(index != -1 ? new ObsModel(support.seriesInfos[index].obsInfos) : null);
                result.getModel().addTableModelListener(new TableModelListener() {
                    @Override
                    public void tableChanged(TableModelEvent e) {
                        chart.fireChartChanged();
                    }
                });
            }
        }
    });
    return ModernUI.withEmptyBorders(new JScrollPane(result));
}

From source file:org.angnysa.yaba.swing.BudgetFrame.java

private void buildSimulationPanel() {

    simulationPanel = new JPanel();
    SpringLayout springLayout = new SpringLayout();
    simulationPanel.setLayout(springLayout);

    // chart data
    simulationDataset = new SimulationDataset(service);
    simulationDataset.setInitial(0D);/*from  w w  w .  j a  va 2s  .co m*/
    simulationDataset.setStart(new LocalDate());
    simulationDataset.setEnd(new LocalDate().plus(Years.ONE));
    simulationDataset.setPeriod(Period.months(1));
    simulationDataset.updateDataset();
    transactionModel.addTableModelListener(new TableModelListener() {

        @Override
        public void tableChanged(TableModelEvent e) {
            simulationDataset.updateDataset();
        }
    });
    reconciliationModel.addTableModelListener(new TableModelListener() {

        @Override
        public void tableChanged(TableModelEvent e) {
            simulationDataset.updateDataset();
        }
    });

    // initial amount label
    JLabel amountLbl = new JLabel(Messages.getString("simulation.field.initial-amount")); //$NON-NLS-1$
    springLayout.putConstraint(SpringLayout.WEST, amountLbl, 10, SpringLayout.WEST, simulationPanel);
    simulationPanel.add(amountLbl);

    // initial amount field
    amountFld = new JFormattedTextField(
            new DefaultFormatterFactory(new NumberFormatter(NumberFormat.getNumberInstance()),
                    new NumberFormatter(NumberFormat.getCurrencyInstance())));
    amountFld.setColumns(8);
    amountFld.setValue(simulationDataset.getInitial());
    amountFld.addPropertyChangeListener("value", new PropertyChangeListener() { //$NON-NLS-1$

        @Override
        public void propertyChange(PropertyChangeEvent e) {
            simulationDataset.setInitial(((Number) amountFld.getValue()).doubleValue());
            simulationDataset.updateDataset();
        }
    });
    springLayout.putConstraint(SpringLayout.VERTICAL_CENTER, amountLbl, 0, SpringLayout.VERTICAL_CENTER,
            amountFld);
    springLayout.putConstraint(SpringLayout.WEST, amountFld, 0, SpringLayout.EAST, amountLbl);
    springLayout.putConstraint(SpringLayout.NORTH, amountFld, 10, SpringLayout.NORTH, simulationPanel);
    simulationPanel.add(amountFld);

    // start date label
    JLabel fromLbl = new JLabel(Messages.getString("simulation.field.start-date")); //$NON-NLS-1$
    springLayout.putConstraint(SpringLayout.WEST, fromLbl, 10, SpringLayout.EAST, amountFld);
    simulationPanel.add(fromLbl);

    // start date field
    fromFld = new JFormattedTextField(new JodaLocalDateFormat());
    fromFld.setColumns(8);
    fromFld.setValue(simulationDataset.getStart());
    fromFld.addPropertyChangeListener("value", new PropertyChangeListener() { //$NON-NLS-1$

        @Override
        public void propertyChange(PropertyChangeEvent e) {
            simulationDataset.setStart((LocalDate) fromFld.getValue());
            simulationDataset.updateDataset();
        }
    });
    springLayout.putConstraint(SpringLayout.VERTICAL_CENTER, fromLbl, 0, SpringLayout.VERTICAL_CENTER, fromFld);
    springLayout.putConstraint(SpringLayout.WEST, fromFld, 0, SpringLayout.EAST, fromLbl);
    springLayout.putConstraint(SpringLayout.NORTH, fromFld, 10, SpringLayout.NORTH, simulationPanel);
    simulationPanel.add(fromFld);

    // end date label
    JLabel toLbl = new JLabel(Messages.getString("simulation.field.end-date")); //$NON-NLS-1$
    springLayout.putConstraint(SpringLayout.WEST, toLbl, 10, SpringLayout.EAST, fromFld);
    simulationPanel.add(toLbl);

    // end date field
    toFld = new JFormattedTextField(new JodaLocalDateFormat());
    toFld.setColumns(8);
    toFld.setValue(simulationDataset.getEnd());
    toFld.addPropertyChangeListener("value", new PropertyChangeListener() { //$NON-NLS-1$

        @Override
        public void propertyChange(PropertyChangeEvent e) {
            simulationDataset.setEnd((LocalDate) toFld.getValue());
            simulationDataset.updateDataset();
        }
    });
    springLayout.putConstraint(SpringLayout.VERTICAL_CENTER, toLbl, 0, SpringLayout.VERTICAL_CENTER, toFld);
    springLayout.putConstraint(SpringLayout.WEST, toFld, 0, SpringLayout.EAST, toLbl);
    springLayout.putConstraint(SpringLayout.NORTH, toFld, 10, SpringLayout.NORTH, simulationPanel);
    simulationPanel.add(toFld);

    // period label
    JLabel periodLbl = new JLabel(Messages.getString("simulation.field.period")); //$NON-NLS-1$
    springLayout.putConstraint(SpringLayout.WEST, periodLbl, 10, SpringLayout.EAST, toFld);
    simulationPanel.add(periodLbl);

    // period field
    periodFld = new JFormattedTextField(new JodaPeriodFormat());
    periodFld.setColumns(5);
    periodFld.setValue(simulationDataset.getPeriod());
    periodFld.addPropertyChangeListener("value", new PropertyChangeListener() { //$NON-NLS-1$

        @Override
        public void propertyChange(PropertyChangeEvent e) {
            simulationDataset.setPeriod((ReadablePeriod) periodFld.getValue());
            simulationDataset.updateDataset();
        }
    });
    springLayout.putConstraint(SpringLayout.VERTICAL_CENTER, periodLbl, 0, SpringLayout.VERTICAL_CENTER,
            periodFld);
    springLayout.putConstraint(SpringLayout.WEST, periodFld, 0, SpringLayout.EAST, periodLbl);
    springLayout.putConstraint(SpringLayout.NORTH, periodFld, 10, SpringLayout.NORTH, simulationPanel);
    simulationPanel.add(periodFld);

    // chart panel
    JFreeChart chart = ChartFactory.createLineChart("", Messages.getString("simulation.chart.date-axis-label"), //$NON-NLS-1$//$NON-NLS-2$
            Messages.getString("simulation.chart.amount-axis-label"), simulationDataset, //$NON-NLS-1$
            PlotOrientation.VERTICAL, false, true, false);
    CategoryPlot plot = (CategoryPlot) chart.getPlot();
    plot.getDomainAxis().setCategoryLabelPositions(CategoryLabelPositions.UP_45);
    LineAndShapeRenderer renderer = (LineAndShapeRenderer) plot.getRenderer();
    renderer.setBaseShapesFilled(true);
    renderer.setBaseShapesVisible(true);
    renderer.setBaseToolTipGenerator(new SimulationTooltipGenerator(service));
    ChartPanel chartPanel = new ChartPanel(chart);
    chartPanel.setDismissDelay(3600000);
    chartPanel.setInitialDelay(0);
    springLayout.putConstraint(SpringLayout.NORTH, chartPanel, 15, SpringLayout.SOUTH, periodFld);
    springLayout.putConstraint(SpringLayout.WEST, chartPanel, 10, SpringLayout.WEST, simulationPanel);
    springLayout.putConstraint(SpringLayout.SOUTH, chartPanel, -10, SpringLayout.SOUTH, simulationPanel);
    springLayout.putConstraint(SpringLayout.EAST, chartPanel, -10, SpringLayout.EAST, simulationPanel);
    simulationPanel.add(chartPanel);
}

From source file:MainFrame.MainFrame.java

public MainFrame() {
    //Create menu
    this.menuBar = new JMenuBar();
    this.menuProxy = new JMenu("Proxy");
    this.menuBar.add(menuProxy);
    this.cbMenuItem = new JCheckBoxMenuItem("? proxy");
    this.cbMenuItem.setMnemonic(KeyEvent.VK_C);

    ActionListener aListener = new ActionListener() {
        public void actionPerformed(ActionEvent event) {
            AbstractButton aButton = (AbstractButton) event.getSource();
            boolean selected = aButton.getModel().isSelected();
            if (selected) {
                SingleDataHolder.getInstance().isProxyActivated = true;
                SingleDataHolder.getInstance().proxyIpAdress = MainFrame.this.proxyIpAdress.getText();
                SingleDataHolder.getInstance().proxyPort = Integer.parseInt(MainFrame.this.proxyPort.getText());
                SingleDataHolder.getInstance().proxyLogin = MainFrame.this.proxyLogin.getText();
                SingleDataHolder.getInstance().proxyPassword = String
                        .valueOf(MainFrame.this.proxyPassword.getPassword());
            } else {
                SingleDataHolder.getInstance().isProxyActivated = false;
            }/*from   ww  w  .  ja  v  a  2s  .c  o m*/
        }
    };
    this.cbMenuItem.addActionListener(aListener);

    this.proxyIpAdress = new JTextField();
    this.proxyPort = new JTextField();
    this.proxyLogin = new JTextField();
    ;
    this.proxyPassword = new JPasswordField();
    this.menuProxy.add(this.cbMenuItem);
    this.menuProxy.add(new JLabel("IP ?"));
    this.menuProxy.add(this.proxyIpAdress);
    this.menuProxy.add(new JLabel("? "));
    this.menuProxy.add(this.proxyPort);
    this.menuProxy.add(new JLabel(""));
    this.menuProxy.add(this.proxyLogin);
    this.menuProxy.add(new JLabel(""));
    this.menuProxy.add(this.proxyPassword);
    this.setJMenuBar(this.menuBar);

    communicator = new HttpCommunicator();
    myActionListener = new mainFrameActionListener();
    mainPanel = new JPanel(new BorderLayout());
    this.setContentPane(mainPanel);

    JPanel P = new JPanel(new FlowLayout(FlowLayout.LEFT, 15, 5));
    mainPanel.add(P, BorderLayout.NORTH);

    //Create Group label
    labelGroup = new JLabel("");
    P.add(labelGroup);
    //Create Group combo
    comboGroup = new JComboBox();
    comboGroup.addItem("?");
    comboGroup.addActionListener(myActionListener);
    P.add(comboGroup);

    //Create Date label
    labelDate = new JLabel("");
    P.add(labelDate);
    //Create Date combo
    comboDate = new JComboBox();
    comboDate.addItem("?");
    comboDate.addActionListener(myActionListener);
    P.add(comboDate);

    //Create Delete button
    buttonDelete = new JButton("");
    buttonDelete.setEnabled(false);
    buttonDelete.addActionListener(myActionListener);
    P.add(buttonDelete);

    //this.checkConnection = new CheckConnection(buttonDelete);

    buttonPasswordsManager = new JButton(" ");
    buttonPasswordsManager.addActionListener(myActionListener);
    P.add(buttonPasswordsManager);

    try {
        Image img = ImageIO.read(getClass().getResource("resources/table_refresh.png"));
        this.buttonRefresh = new JButton(new ImageIcon(img));
        this.buttonRefresh.addActionListener(myActionListener);
        this.buttonRefresh.setToolTipText(" ");
        P.add(buttonRefresh);
    } catch (IOException ex) {
        Logger.getLogger(MainFrame.class.getName()).log(Level.SEVERE, null, ex);
    }

    //CreateLessonTableModel
    lessonTableModel = new LessonTableModel();

    try {
        communicator.setCombos(comboGroup, comboDate, lessonTableModel);
    } catch (IOException ex) {
        JOptionPane.showMessageDialog(null, " ? ? .");
        Logger.getLogger(MainFrame.class.getName()).log(Level.SEVERE, null, ex);
    }

    //CreateTable
    table = new JTable(lessonTableModel);
    table.setFillsViewportHeight(true);
    table.setAutoCreateRowSorter(true);

    JScrollPane scrollP = new JScrollPane(table);
    mainPanel.add(scrollP, BorderLayout.CENTER);
    //Create Table sorter
    sorter = new TableRowSorter<LessonTableModel>(lessonTableModel);
    table.setRowSorter(sorter);
    table.getModel().addTableModelListener(new TableModelListener() {
        @Override
        public void tableChanged(TableModelEvent e) {
            int row = e.getFirstRow();
            int column = e.getColumn();
            TableModel model = (TableModel) e.getSource();
            for (int i = 0; i < model.getRowCount(); i++) {
                if ((boolean) model.getValueAt(i, 2) == true) {
                    buttonDelete.setEnabled(true);
                    return;
                }
            }
            buttonDelete.setEnabled(false);
        }
    });

    //Standart block
    this.setSize(700, 400);
    this.setTitle(" ");
    this.addWindowListener(new WindowAdapter() {
        @Override
        public void windowClosing(WindowEvent we) {
            System.exit(0);
        }
    });
    try {
        Image img = ImageIO.read(getClass().getResource("resources/appIcon.png"));
        this.setIconImage(img);
    } catch (IOException ex) {
        Logger.getLogger(MainFrame.class.getName()).log(Level.SEVERE, null, ex);
    }

    this.setVisible(true);
}

From source file:com.diversityarrays.kdxplore.vistool.AskForTraitInstances.java

AskForTraitInstances(Window owner, String title, boolean xAndYaxes, String okLabel, TraitNameStyle tns,
        Map<TraitInstance, SimpleStatistics<?>> map, int[] minMax,
        Closure<List<TraitInstance>> onInstancesChosen) {
    super(owner, title, ModalityType.MODELESS);

    this.traitNameStyle = tns;
    this.minInstances = minMax[0];
    this.maxInstances = minMax[1];
    this.onInstancesChosen = onInstancesChosen;

    if (xAndYaxes) {
        tableModel = new TraitInstanceAxisChoiceTableModel();
    } else {/* w  w w .jav a2s.  c o m*/
        tableModel = new TraitInstanceChoiceTableModel();
    }
    table = new JTable(tableModel);

    okAction.putValue(Action.NAME, okLabel);

    traitInstances = new ArrayList<TraitInstance>(map.keySet());
    Collections.sort(traitInstances, TraitHelper.COMPARATOR);

    table.setAutoCreateRowSorter(true);

    Box box = Box.createHorizontalBox();
    box.add(message);
    box.add(Box.createHorizontalGlue());
    box.add(new JButton(okAction));
    box.add(new JButton(cancelAction));

    getContentPane().add(new JScrollPane(table), BorderLayout.CENTER);
    getContentPane().add(box, BorderLayout.SOUTH);

    pack();

    tableModel.addTableModelListener(new TableModelListener() {
        @Override
        public void tableChanged(TableModelEvent e) {
            updateOkButton();
        }
    });
    updateOkButton();
}