Example usage for javax.swing.table DefaultTableModel setColumnIdentifiers

List of usage examples for javax.swing.table DefaultTableModel setColumnIdentifiers

Introduction

In this page you can find the example usage for javax.swing.table DefaultTableModel setColumnIdentifiers.

Prototype

public void setColumnIdentifiers(Object[] newIdentifiers) 

Source Link

Document

Replaces the column identifiers in the model.

Usage

From source file:com.farouk.projectapp.FirstGUI.java

private void UpdatejTable3(Company com) {
    DefaultTableModel modelCompany = new DefaultTableModel();
    modelCompany.setColumnIdentifiers(new String[] { "Name", "Symbol", "Stock Price ()", "Bid Price",
            "Ask Price", "Quantity Bought" });
    modelCompany.addRow(new String[] { com.getName(), com.getSymbol(),
            String.valueOf(com.getStockPrice().doubleValue()), String.valueOf(com.getBidPrice().doubleValue()),
            String.valueOf(com.getAskPrice().doubleValue()), Integer.toString(com.getNumberOwned()) });
    jTable3.setModel(modelCompany);/*from   w  w  w . ja v  a2s.  co  m*/
}

From source file:com.farouk.projectapp.FirstGUI.java

private void UpdatejTable2() {
    DefaultTableModel modelPortfolio = new DefaultTableModel();
    total = new BigDecimal(0);
    modelPortfolio.setColumnIdentifiers(new String[] { "Name", "Symbol", "Stock Price ()", "Bid Price",
            "Ask Price", "Quantity Bought", "Price Paid" });
    for (Company com : SQLConnect.getPortfolioCompanies(userID)) {
        modelPortfolio/*  w w  w  .j a v a 2s.c  o  m*/
                .addRow(new String[] { com.getName(), com.getSymbol(),
                        String.valueOf(com.getStockPrice().doubleValue()),
                        String.valueOf(com.getBidPrice().doubleValue()),
                        String.valueOf(com.getAskPrice().doubleValue()), Integer.toString(com.getNumberOwned()),
                        String.valueOf((com.getStockPrice()
                                .multiply(new BigDecimal(Integer.toString(com.getNumberOwned())))
                                .doubleValue())) });
        String disturbed = Integer.toString(com.getNumberOwned());
        BigDecimal aa = new BigDecimal(disturbed);
        total = total.add(com.getStockPrice().multiply(aa));
    }
    jLabel10.setText("Total is : " + String.valueOf(total.doubleValue()) + "");
    jTable2.setModel(modelPortfolio);

}

From source file:com.SE.myPlayer.MusicPlayerGUI.java

public void tableReferesh(JTable songData_Table, String tableName, String columName) {
        int emptyResultSet = 0;

        try {// w  w  w .j a  va  2 s  .co m
            con = db.getCon();
            stmt = con.createStatement();
            ResultSet rs;

            switch (tableName) {
            case "library":
                rs = stmt.executeQuery("select * from library order by " + columName + "");
                break;
            case "playlist":
                rs = stmt.executeQuery("select * from library order by " + columName + "");
                break;
            default:
                rs = stmt.executeQuery(
                        "Select library.id_songs, library.song_location, library.song_name, library.song_album, library.song_artist, library.genre, library.year, library.time, library.comment from playlist INNER JOIN library ON library.id_songs = playlist.id_songs AND playlist.playlist_name = '"
                                + tableName + "' order by " + columName + "");
                break;
            }

            DefaultTableModel myModel = new DefaultTableModel() {

                @Override
                public boolean isCellEditable(int row, int column) {
                    return false;
                }
            };

            String[] songsColumnsName = { "Location", "Name", "Album", "Artist", "Genre", "Year", "Time",
                    "Comment" };
            myModel.setColumnIdentifiers(songsColumnsName);

            ResultSetMetaData rsmd = rs.getMetaData();
            int colNumbers = rsmd.getColumnCount();

            Object[] objects = new Object[colNumbers];

            while (rs.next()) {
                emptyResultSet = 1;
                for (int i = 0; i < colNumbers - 1; i++) {
                    objects[i] = rs.getObject(i + 2);
                }
                myModel.addRow(objects);
            }

            if (emptyResultSet == 0) {
                myModel.addRow(objects);
            }

            songData_Table.setModel(myModel);

            rs = stmt.executeQuery("select col_name from col_name where col_status = 0");

            while (rs.next()) {
                songData_Table.removeColumn(songData_Table.getColumn(rs.getString(1)));
            }

            songData_Table.getTableHeader().removeMouseListener(ma);
            songData_Table.getTableHeader().addMouseListener(ma);
            songData_Table.setDragEnabled(true);
            songData_Table.setDropTarget(new DropTarget() {
                @Override
                public synchronized void drop(DropTargetDropEvent dtde) {

                    dtde.acceptDrop(DnDConstants.ACTION_COPY_OR_MOVE);
                    Transferable t = dtde.getTransferable();

                    try {
                        if (dtde.isDataFlavorSupported(DataFlavor.javaFileListFlavor)) {
                            Object fileList = t.getTransferData(DataFlavor.javaFileListFlavor);
                            String files = fileList.toString();
                            finalString = convertFileString(files);
                            if (dropControl == 0 && lastOpen.equals("library")) {
                                songAddDB(finalString);
                            } else if (dropControl == 0 && !lastOpen.equals("library")) {
                                songAddPlaylistFromLibrary(lastOpen, finalString);
                                getSongTable(lastOpen);
                            } else {
                                songAddPlaylistFromLibrary(tableName, finalString);
                            }
                        } else if (dtde.isDataFlavorSupported(DataFlavor.stringFlavor)) {
                            Object fileList = t.getTransferData(DataFlavor.stringFlavor);
                            String fileListString = fileList.toString();

                            fileListString = Arrays.toString(fileListString.split("\\n"));

                            String[] splitLocations = fileListString.split(",\\s");

                            for (int i = 0; i < splitLocations.length; i++) {
                                if (i == 0) {
                                    splitLocations[i] = splitLocations[i].substring(1,
                                            splitLocations[i].indexOf(".mp3") + 4);
                                } else {
                                    splitLocations[i] = splitLocations[i].substring(0,
                                            splitLocations[i].indexOf(".mp3") + 4);
                                }
                            }

                            for (int i = 0; i < splitLocations.length; i++) {
                                splitLocations[i] = sd.getLocations(splitLocations[i]);
                            }
                            finalString = Arrays.asList(splitLocations);
                            if (dropControl == 0 && lastOpen.equals("library")) {
                                songAddDB(finalString);
                            } else if (dropControl == 0 && !lastOpen.equals("library")) {
                                songAddPlaylistFromLibrary(lastOpen, finalString);
                                getSongTable(lastOpen);
                            } else {
                                songAddPlaylistFromLibrary(tableName, finalString);
                            }
                        }
                    } catch (UnsupportedFlavorException | IOException | InvalidDataException
                            | UnsupportedTagException ex) {
                        System.out.println("Error in second drop flavour............" + ex);
                    }
                }
            });

            if (con != null) {
                stmt.close();
                con.close();
            }
        } catch (SQLException e) {
            System.out.println("Error in Stmt " + e);
        }
    }

From source file:search2go.UIFrame.java

public void identify(boolean fullProcess) {
    if ("Stop".equals(btnGTermIdent.getText())) {
        identButton.activate();/*from w w  w.j  av a2s . c  om*/
        try {
            if (os.isWindows()) {
                Runtime.getRuntime().exec("cmd /C TaskKill -IM blastx.exe -F");
                Runtime.getRuntime().exec("cmd /C TaskKill -IM blastn.exe -F");
                Runtime.getRuntime().exec("cmd /C TaskKill -IM blastp.exe -F");
            } else {
                Runtime.getRuntime().exec("killAll -KILL blastx");
                Runtime.getRuntime().exec("killAll -KILL blastn");
                Runtime.getRuntime().exec("killAll -KILL blastp");
            }
        } catch (IOException ex) {
            System.out.println("Error closing child processes");
        }
        prgIdentification.setIndeterminate(false);
    } else if (currentProj.checkStage(2)) {
        if (currentProj.isAvaialable()) {
            pnlChartHolder.removeAll();
            lstQueries.clearSelection();
            lstQueries.setModel(new DefaultListModel());
            txtTermInfo.setText("");

            tblGOFreq.clearSelection();
            DefaultTableModel d = new DefaultTableModel();
            d.setColumnCount(2);
            d.setColumnIdentifiers(new String[] { "GO ID", "Frequency" });
            tblGOFreq.setModel(d);

            identSequences = new ArrayList<>();

            resetIdentCount();
            for (int i = 0; i < 3; i++) {
                if (currentProj.getTargetDBString().contains(targetDBs[i])) {
                    JTextArea tempHolder = new JTextArea();
                    ProcessSequence identSequence = new ProcessSequence(currentProj,
                            new ProcessSequenceFiller(tempHolder, Integer.toString(i)) {
                                private final JTextArea sequenceOutput = tempHolder;

                                @Override
                                public void run() {
                                    new Thread(new Runnable() {
                                        @Override
                                        public void run() {
                                            for (String record : sequenceOutput.getText().split("\n")) {
                                                String name = record.split("\t")[0];
                                                GTerm nextGTerm = new GTerm(
                                                        name.substring(0, name.indexOf("[")),
                                                        name.substring(name.indexOf("[")));
                                                nextGTerm.setTopLevel(topLevels[Integer.parseInt(getNotes())]);
                                                nextGTerm.setFrequency(Integer.parseInt(record.split("\t")[1]));
                                                gTerms.addGTerm(nextGTerm);
                                            }
                                            incIdentCount();
                                        }
                                    }).start();
                                }
                            });
                    identSequences.add(identSequence);
                    Process checkFullIdent = new Process(tempHolder);
                    Path checkFullIdentPath = new Path("Processes");
                    checkFullIdentPath.append("gotFullGTerms.py");
                    checkFullIdent.setScriptCommand(checkFullIdentPath.toEscString());
                    checkFullIdent.addParameter("dir", currentProj.getPath().toEscString());
                    checkFullIdent.addParameter("db", targetDBs[i]);
                    identSequence.addProcess(checkFullIdent);
                    ProcessSequenceFiller doFullCheckOutputGetter = new ProcessSequenceFiller(tempHolder,
                            targetDBs[i]) {
                        @Override
                        public void run() {
                            if (this.getOutBox().getText().contains("false")) {
                                this.getOutBox().setText("");
                                Process mapSequenceGO = new Process(this.getOutBox());
                                Path mapSequenceGOPath = new Path("Processes");
                                mapSequenceGOPath.append("mapSequenceGO.py");
                                mapSequenceGO.setScriptCommand(mapSequenceGOPath.toEscString());
                                mapSequenceGO.addParameter("dir", currentProj.getPath().toEscString());
                                mapSequenceGO.addParameter("db", this.getNotes());
                                this.getParentSequence(0).addProcess(mapSequenceGO);

                                Process parseConverts = new Process(this.getOutBox());
                                Path parseConvertsPath = new Path("Processes");
                                parseConvertsPath.append("parseConvertedIDs.py");
                                parseConverts.setScriptCommand(parseConvertsPath.toEscString());
                                parseConverts.addParameter("dir", currentProj.getPath().toEscString());
                                parseConverts.addParameter("db", this.getNotes());
                                this.getParentSequence(0).addProcess(parseConverts);

                                identSequence.addProcess(new ProcessSequenceFiller(tempHolder) {
                                    @Override
                                    public void run() {
                                        tempHolder.setText("");
                                        try {
                                            this.finish();
                                        } catch (IOException ex) {
                                            System.out.println("Error finishing identification process filler");
                                        }
                                    }

                                });
                            }
                            this.getOutBox().setText("");
                            Process getMatchedQueryFreq = new Process(this.getOutBox());
                            Path getMatchedQueryFreqPath = new Path("Processes");
                            getMatchedQueryFreqPath.append("getMatchedQueryFreq.py");
                            getMatchedQueryFreq.setScriptCommand(getMatchedQueryFreqPath.toEscString());
                            getMatchedQueryFreq.addParameter("dir", currentProj.getPath().toEscString());
                            getMatchedQueryFreq.addParameter("db", this.getNotes());
                            this.getParentSequence(0).addProcess(getMatchedQueryFreq);
                            try {
                                this.finish();
                            } catch (IOException ex) {
                                System.out.println("Error finishing identification process filler");
                            }
                        }
                    };

                    identSequence.addProcess(doFullCheckOutputGetter);
                    try {
                        gTerms.getGTerms().clear();
                        identSequence.start();
                        identButton.setStopTargets(
                                identSequences.toArray(new ProcessSequence[identSequences.size()]));
                        if (currentProj.willDoCC())
                            currentProj.setStage(0, 2);
                        if (currentProj.willDoBP())
                            currentProj.setStage(1, 2);
                        if (currentProj.willDoBP())
                            currentProj.setStage(2, 2);
                        prgIdentification.setIndeterminate(true);
                    } catch (IOException ex) {
                        Logger.getLogger(UIFrame.class.getName()).log(Level.SEVERE, null, ex);
                    }
                }
            }
            identButton.activate();
        } else
            javax.swing.JOptionPane.showMessageDialog(this,
                    "Another function is currently being performed on this project, please wait until completion or manually stop the process.");
    } else {
        System.out.println(currentProj.getStage());
        javax.swing.JOptionPane.showMessageDialog(this,
                "Mapping data unavailable. Please complete mapping step or switch to a project with completed mapping to continue.");
    }

}

From source file:jp.massbank.spectrumsearch.SearchPage.java

/**
 * ?//from   w ww.ja  v  a  2 s. c om
 */
private void createWindow() {

    // ??
    ToolTipManager ttm = ToolTipManager.sharedInstance();
    ttm.setInitialDelay(50);
    ttm.setDismissDelay(8000);

    // Search?
    JPanel mainPanel = new JPanel();
    mainPanel.setLayout(new BorderLayout());
    Border border = BorderFactory.createCompoundBorder(BorderFactory.createEtchedBorder(),
            new EmptyBorder(1, 1, 1, 1));
    mainPanel.setBorder(border);

    // *********************************************************************
    // User File Query
    // *********************************************************************
    DefaultTableModel fileDm = new DefaultTableModel();
    fileSorter = new TableSorter(fileDm, TABLE_QUERY_FILE);
    queryFileTable = new JTable(fileSorter) {
        @Override
        public boolean isCellEditable(int row, int column) {
            //            super.isCellEditable(row, column);
            // ??????
            return false;
        }
    };
    queryFileTable.addMouseListener(new TblMouseListener());
    fileSorter.setTableHeader(queryFileTable.getTableHeader());
    queryFileTable.setRowSelectionAllowed(true);
    queryFileTable.setColumnSelectionAllowed(false);
    queryFileTable.setAutoResizeMode(JTable.AUTO_RESIZE_OFF);

    String[] col = { COL_LABEL_NO, COL_LABEL_NAME, COL_LABEL_ID };
    ((DefaultTableModel) fileSorter.getTableModel()).setColumnIdentifiers(col);
    (queryFileTable.getColumn(queryFileTable.getColumnName(0))).setPreferredWidth(44);
    (queryFileTable.getColumn(queryFileTable.getColumnName(1))).setPreferredWidth(LEFT_PANEL_WIDTH - 44);
    (queryFileTable.getColumn(queryFileTable.getColumnName(2))).setPreferredWidth(70);

    ListSelectionModel lm = queryFileTable.getSelectionModel();
    lm.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    lm.addListSelectionListener(new LmFileListener());
    queryFilePane = new JScrollPane(queryFileTable);
    queryFilePane.addMouseListener(new PaneMouseListener());
    queryFilePane.setPreferredSize(new Dimension(300, 300));

    // *********************************************************************
    // Result
    // *********************************************************************
    DefaultTableModel resultDm = new DefaultTableModel();
    resultSorter = new TableSorter(resultDm, TABLE_RESULT);
    resultTable = new JTable(resultSorter) {
        @Override
        public String getToolTipText(MouseEvent me) {
            //            super.getToolTipText(me);
            // ?????
            Point pt = me.getPoint();
            int row = rowAtPoint(pt);
            if (row < 0) {
                return null;
            } else {
                int nameCol = getColumnModel().getColumnIndex(COL_LABEL_NAME);
                return " " + getValueAt(row, nameCol) + " ";
            }
        }

        @Override
        public boolean isCellEditable(int row, int column) {
            //            super.isCellEditable(row, column);
            // ??????
            return false;
        }
    };
    resultTable.addMouseListener(new TblMouseListener());
    resultSorter.setTableHeader(resultTable.getTableHeader());

    JPanel dbPanel = new JPanel();
    dbPanel.setLayout(new BorderLayout());
    resultPane = new JScrollPane(resultTable);
    resultPane.addMouseListener(new PaneMouseListener());

    resultTable.setRowSelectionAllowed(true);
    resultTable.setColumnSelectionAllowed(false);
    resultTable.setAutoResizeMode(JTable.AUTO_RESIZE_OFF);

    String[] col2 = { COL_LABEL_NAME, COL_LABEL_SCORE, COL_LABEL_HIT, COL_LABEL_ID, COL_LABEL_ION,
            COL_LABEL_CONTRIBUTOR, COL_LABEL_NO };

    resultDm.setColumnIdentifiers(col2);
    (resultTable.getColumn(resultTable.getColumnName(0))).setPreferredWidth(LEFT_PANEL_WIDTH - 180);
    (resultTable.getColumn(resultTable.getColumnName(1))).setPreferredWidth(70);
    (resultTable.getColumn(resultTable.getColumnName(2))).setPreferredWidth(20);
    (resultTable.getColumn(resultTable.getColumnName(3))).setPreferredWidth(70);
    (resultTable.getColumn(resultTable.getColumnName(4))).setPreferredWidth(20);
    (resultTable.getColumn(resultTable.getColumnName(5))).setPreferredWidth(70);
    (resultTable.getColumn(resultTable.getColumnName(6))).setPreferredWidth(50);

    ListSelectionModel lm2 = resultTable.getSelectionModel();
    lm2.addListSelectionListener(new LmResultListener());

    resultPane.setPreferredSize(new Dimension(LEFT_PANEL_WIDTH, 200));
    dbPanel.add(resultPane, BorderLayout.CENTER);

    // *********************************************************************
    // DB Query
    // *********************************************************************
    DefaultTableModel dbDm = new DefaultTableModel();
    querySorter = new TableSorter(dbDm, TABLE_QUERY_DB);
    queryDbTable = new JTable(querySorter) {
        @Override
        public boolean isCellEditable(int row, int column) {
            //            super.isCellEditable(row, column);
            // ??????
            return false;
        }
    };
    queryDbTable.addMouseListener(new TblMouseListener());
    querySorter.setTableHeader(queryDbTable.getTableHeader());
    queryDbPane = new JScrollPane(queryDbTable);
    queryDbPane.addMouseListener(new PaneMouseListener());

    int h = (int) Toolkit.getDefaultToolkit().getScreenSize().getHeight();
    queryDbPane.setPreferredSize(new Dimension(LEFT_PANEL_WIDTH, h));
    queryDbTable.setRowSelectionAllowed(true);
    queryDbTable.setColumnSelectionAllowed(false);
    queryDbTable.setAutoResizeMode(JTable.AUTO_RESIZE_OFF);

    String[] col3 = { COL_LABEL_ID, COL_LABEL_NAME, COL_LABEL_CONTRIBUTOR, COL_LABEL_NO };
    DefaultTableModel model = (DefaultTableModel) querySorter.getTableModel();
    model.setColumnIdentifiers(col3);

    // 
    queryDbTable.getColumn(queryDbTable.getColumnName(0)).setPreferredWidth(70);
    queryDbTable.getColumn(queryDbTable.getColumnName(1)).setPreferredWidth(LEFT_PANEL_WIDTH - 70);
    queryDbTable.getColumn(queryDbTable.getColumnName(2)).setPreferredWidth(70);
    queryDbTable.getColumn(queryDbTable.getColumnName(3)).setPreferredWidth(50);

    ListSelectionModel lm3 = queryDbTable.getSelectionModel();
    lm3.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    lm3.addListSelectionListener(new LmQueryDbListener());

    // ?
    JPanel btnPanel = new JPanel();
    btnName.addActionListener(new BtnSearchNameListener());
    btnAll.addActionListener(new BtnAllListener());
    btnPanel.add(btnName);
    btnPanel.add(btnAll);

    parentPanel2 = new JPanel();
    parentPanel2.setLayout(new BoxLayout(parentPanel2, BoxLayout.PAGE_AXIS));
    parentPanel2.add(btnPanel);
    parentPanel2.add(queryDbPane);

    // ?
    JPanel dispModePanel = new JPanel();
    isDispSelected = dispSelected.isSelected();
    isDispRelated = dispRelated.isSelected();
    if (isDispSelected) {
        resultTable.getSelectionModel().setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION);
    } else if (isDispRelated) {
        resultTable.getSelectionModel().setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    }
    Object[] retRadio = new Object[] { dispSelected, dispRelated };
    for (int i = 0; i < retRadio.length; i++) {
        ((JRadioButton) retRadio[i]).addActionListener(new ActionListener() {
            public void actionPerformed(ActionEvent arg0) {
                if (isDispSelected != dispSelected.isSelected() || isDispRelated != dispRelated.isSelected()) {

                    isDispSelected = dispSelected.isSelected();
                    isDispRelated = dispRelated.isSelected();

                    // ??
                    resultTable.clearSelection();
                    resultPlot.clear();
                    compPlot.setPeaks(null, 1);
                    resultPlot.setPeaks(null, 0);
                    setAllPlotAreaRange();
                    pkgView.initResultRecInfo();

                    if (isDispSelected) {
                        resultTable.getSelectionModel()
                                .setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION);
                    } else if (isDispRelated) {
                        resultTable.getSelectionModel().setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
                    }
                }
            }
        });
    }
    ButtonGroup disGroup = new ButtonGroup();
    disGroup.add(dispSelected);
    disGroup.add(dispRelated);
    dispModePanel.add(lbl2);
    dispModePanel.add(dispSelected);
    dispModePanel.add(dispRelated);

    JPanel paramPanel = new JPanel();
    paramPanel.add(etcPropertyButton);
    etcPropertyButton.setMargin(new Insets(0, 10, 0, 10));
    etcPropertyButton.addActionListener(new ActionListener() {
        private ParameterSetWindow ps = null;

        public void actionPerformed(ActionEvent e) {
            // ??????????
            if (!isSubWindow) {
                ps = new ParameterSetWindow(getParentFrame());
            } else {
                ps.requestFocus();
            }
        }
    });

    JPanel optionPanel = new JPanel();
    optionPanel.setLayout(new BoxLayout(optionPanel, BoxLayout.Y_AXIS));
    optionPanel.add(dispModePanel);
    optionPanel.add(paramPanel);

    // PackageView?????
    pkgView = new PackageViewPanel();
    pkgView.initAllRecInfo();

    queryTabPane.addTab("DB", parentPanel2);
    queryTabPane.setToolTipTextAt(TAB_ORDER_DB, "Query from DB.");
    queryTabPane.addTab("File", queryFilePane);
    queryTabPane.setToolTipTextAt(TAB_ORDER_FILE, "Query from user file.");
    queryTabPane.setSelectedIndex(TAB_ORDER_DB);
    queryTabPane.setFocusable(false);
    queryTabPane.addChangeListener(new ChangeListener() {
        public void stateChanged(ChangeEvent e) {

            // ?
            queryPlot.clear();
            compPlot.clear();
            resultPlot.clear();
            queryPlot.setPeaks(null, 0);
            compPlot.setPeaks(null, 1);
            resultPlot.setPeaks(null, 0);

            // PackageView?
            pkgView.initAllRecInfo();

            // DB Hit?
            if (resultTabPane.getTabCount() > 0) {
                resultTabPane.setSelectedIndex(0);
            }
            DefaultTableModel dataModel = (DefaultTableModel) resultSorter.getTableModel();
            dataModel.setRowCount(0);
            hitLabel.setText(" ");

            // DB?User File??????
            queryTabPane.update(queryTabPane.getGraphics());
            if (queryTabPane.getSelectedIndex() == TAB_ORDER_DB) {
                parentPanel2.update(parentPanel2.getGraphics());
                updateSelectQueryTable(queryDbTable);
            } else if (queryTabPane.getSelectedIndex() == TAB_ORDER_FILE) {
                queryFilePane.update(queryFilePane.getGraphics());
                updateSelectQueryTable(queryFileTable);
            }
        }
    });

    //       
    JPanel queryPanel = new JPanel();
    queryPanel.setLayout(new BorderLayout());
    queryPanel.add(queryTabPane, BorderLayout.CENTER);
    queryPanel.add(optionPanel, BorderLayout.SOUTH);
    queryPanel.setMinimumSize(new Dimension(0, 170));

    JPanel jtp2Panel = new JPanel();
    jtp2Panel.setLayout(new BorderLayout());
    jtp2Panel.add(dbPanel, BorderLayout.CENTER);
    jtp2Panel.add(hitLabel, BorderLayout.SOUTH);
    jtp2Panel.setMinimumSize(new Dimension(0, 70));
    Color colorGreen = new Color(0, 128, 0);
    hitLabel.setForeground(colorGreen);

    resultTabPane.addTab("Result", jtp2Panel);
    resultTabPane.setToolTipTextAt(TAB_RESULT_DB, "Result of DB hit.");
    resultTabPane.setFocusable(false);

    queryPlot.setMinimumSize(new Dimension(0, 100));
    compPlot.setMinimumSize(new Dimension(0, 120));
    resultPlot.setMinimumSize(new Dimension(0, 100));
    int height = initAppletHight / 3;
    JSplitPane jsp_cmp2db = new JSplitPane(JSplitPane.VERTICAL_SPLIT, compPlot, resultPlot);
    JSplitPane jsp_qry2cmp = new JSplitPane(JSplitPane.VERTICAL_SPLIT, queryPlot, jsp_cmp2db);
    jsp_cmp2db.setDividerLocation(height);
    jsp_qry2cmp.setDividerLocation(height - 25);
    jsp_qry2cmp.setMinimumSize(new Dimension(190, 0));

    viewTabPane.addTab("Compare View", jsp_qry2cmp);
    viewTabPane.addTab("Package View", pkgView);
    viewTabPane.setToolTipTextAt(TAB_VIEW_COMPARE, "Comparison of query and result spectrum.");
    viewTabPane.setToolTipTextAt(TAB_VIEW_PACKAGE, "Package comparison of query and result spectrum.");
    viewTabPane.setSelectedIndex(TAB_VIEW_COMPARE);
    viewTabPane.setFocusable(false);

    JSplitPane jsp = new JSplitPane(JSplitPane.VERTICAL_SPLIT, queryPanel, resultTabPane);
    jsp.setDividerLocation(310);
    jsp.setMinimumSize(new Dimension(180, 0));
    jsp.setOneTouchExpandable(true);

    JSplitPane jsp2 = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, jsp, viewTabPane);
    int divideSize = (int) (initAppletWidth * 0.4);
    divideSize = (divideSize >= 180) ? divideSize : 180;
    jsp2.setDividerLocation(divideSize);
    jsp2.setOneTouchExpandable(true);

    mainPanel.add(jsp2, BorderLayout.CENTER);
    add(mainPanel);

    queryPlot.setSearchPage(this);
    compPlot.setSearchPage(this);
    resultPlot.setSearchPage(this);

    setJMenuBar(MenuBarGenerator.generateMenuBar(this));
}

From source file:interfazGrafica.loginInterface.java

private void vehiculosDispVenderItemStateChanged(java.awt.event.ItemEvent evt) {//GEN-FIRST:event_vehiculosDispVenderItemStateChanged
    // TODO add your handling code here:
    panelConsultas.removeAll();//from ww w  .j  av  a2s . c om
    panelContenedor.setVisible(true);
    String consultaSQL = "SELECT id_vehiculo, marca_vehiculo, modelo_vehiculo, color_vehiculo, "
            + "nuevo_vehiculo, valor_vehiculo, id_sede FROM vehiculos WHERE marca_vehiculo = '"
            + (String) vehiculosDispVender.getSelectedItem() + "' AND cantidad_disponible_vehiculo = 1;";
    ResultSet tabla = new OperacionesBD().consultas(consultaSQL);
    DefaultTableModel dtm = new DefaultTableModel(0, 0);

    try {
        int count = 0;
        while (tabla.next()) {
            count++;
        }

        String[][] data = new String[count][7];
        int i = 0;
        tabla = new OperacionesBD().consultas(consultaSQL);
        while (tabla.next()) {
            data[i][0] = "" + tabla.getInt("id_vehiculo");
            data[i][1] = tabla.getString("marca_vehiculo");
            data[i][2] = tabla.getString("modelo_vehiculo");
            data[i][3] = tabla.getString("color_vehiculo");
            data[i][4] = tabla.getString("nuevo_vehiculo");
            data[i][5] = tabla.getString("valor_vehiculo");
            data[i][6] = tabla.getString("id_sede");
            i++;
        }
        String[] nombreColumnas = { "Codigo", "Marca", "Modelo", "Color", "Nuevo", "Valor", "Sede" };
        dtm.setColumnIdentifiers(nombreColumnas);
        tableCrearCot1.setModel(dtm);
        for (int j = 0; j < count; j++) {
            dtm.addRow(data[j]);
        }

    } catch (SQLException exc) {
        JOptionPane.showMessageDialog(null, "Error al acceder a la base de datos");
        exc.printStackTrace();
    }
}

From source file:interfazGrafica.loginInterface.java

private void vehiculosDispCrearCotItemStateChanged(java.awt.event.ItemEvent evt) {//GEN-FIRST:event_vehiculosDispCrearCotItemStateChanged
    // TODO add your handling code here:
    panelConsultas.removeAll();//from  w w w.j  av a 2  s .  c o  m
    panelContenedor.setVisible(true);
    String consultaSQL = "SELECT id_vehiculo, marca_vehiculo, modelo_vehiculo, color_vehiculo, "
            + "nuevo_vehiculo, valor_vehiculo, id_sede FROM vehiculos WHERE marca_vehiculo = '"
            + (String) vehiculosDispCrearCot.getSelectedItem() + "' AND cantidad_disponible_vehiculo = 1;";
    ResultSet tabla = new OperacionesBD().consultas(consultaSQL);
    DefaultTableModel dtm = new DefaultTableModel(0, 0);

    try {
        int count = 0;
        while (tabla.next()) {
            count++;
        }

        String[][] data = new String[count][7];
        int i = 0;
        tabla = new OperacionesBD().consultas(consultaSQL);
        while (tabla.next()) {
            data[i][0] = "" + tabla.getInt("id_vehiculo");
            data[i][1] = tabla.getString("marca_vehiculo");
            data[i][2] = tabla.getString("modelo_vehiculo");
            data[i][3] = tabla.getString("color_vehiculo");
            data[i][4] = tabla.getString("nuevo_vehiculo");
            data[i][5] = tabla.getString("valor_vehiculo");
            data[i][6] = tabla.getString("id_sede");
            i++;
        }
        String[] nombreColumnas = { "Codigo", "Marca", "Modelo", "Color", "Nuevo", "Valor", "Sede" };
        dtm.setColumnIdentifiers(nombreColumnas);
        tableCrearCot.setModel(dtm);
        for (int j = 0; j < count; j++) {
            dtm.addRow(data[j]);
        }

    } catch (SQLException exc) {
        JOptionPane.showMessageDialog(null, "Error al acceder a la base de datos");
        exc.printStackTrace();
    }
}

From source file:org.ops4j.pax.idea.runner.forms.OsgiConfigEditorForm.java

public OsgiConfigEditorForm(final ConfigBean config) {
    String[] columnNames = { "Property", "Value" };
    DefaultTableModel tableModel = new DefaultTableModel();
    tableModel.setColumnIdentifiers(columnNames);
    m_bundleProperties.setModel(tableModel);
    m_bundleProperties.setShowGrid(true);
    m_bundleProperties.setEnabled(false);
    config.addBundleObserver(this);
    m_bundleModel = new DefaultListModel();
    m_bundles.setModel(m_bundleModel);/*  www  . j  av  a  2s  . c  o m*/
}

From source file:org.ops4j.pax.idea.runner.forms.OsgiConfigEditorForm.java

private void updateSystemPropertiesTable(ConfigBean data) {
    String[] columnNames = { "Property", "Value" };
    DefaultTableModel tableModel2 = new DefaultTableModel();
    tableModel2.setColumnIdentifiers(columnNames);
    Set<Map.Entry<String, String>> entries = data.getSystemProperties().entrySet();
    for (Map.Entry<String, String> entry : entries) {
        String key = entry.getKey();
        String value = entry.getValue();
        tableModel2.addRow(new String[] { key, value });
    }//from w w  w.  j a  v  a 2s .  co  m
    m_systemProperties.setModel(tableModel2);
    m_systemProperties.setEnabled(true);
}

From source file:sms.Form1Exams.java

public void findUsers() {
    String[] Subjects = findSubjectid();
    String[] Subjectsnames = findSubjectname();
    int subjectCount = Subjects.length;
    //JOptionPane.showMessageDialog(null, subjectCount);

    ArrayList<ExamDbDataHolder> users = ListUsers(this.sid.getText());
    DefaultTableModel model = new DefaultTableModel();

    //    String [] subjectsIdentifiers={"Maths","Eng","Kisw","Phy","Chem","Bio","Hist","Geo","Cre","Hre","Agri","Home Scie","Arts","Comp",
    //                                      "B/c","Wood","Metal","Music","French","German","Arabic","Business"};
    //    for(int y=0;y<Subjects.length;y++){
    //        //from  w ww. jav  a 2s  .com
    //    }
    //    String []toCol;
    String col[] = { "Adm", "Uniq" };

    // String [] subjectsIdentifiers={}
    String[] both = (String[]) ArrayUtils.addAll(col, Subjectsnames);

    model.setColumnIdentifiers(both);
    Object[] row = new Object[subjectCount + 4];
    for (int i = 0; i < users.size(); i++) {

        row[0] = ((ExamDbDataHolder) users.get(i)).getSid();

        row[1] = ((ExamDbDataHolder) users.get(i)).getUnique();

        int c = 2;
        for (int s = 0; s < Subjects.length; s++) {

            if (Subjects[s].equals("s1")) {
                row[c] = ((ExamDbDataHolder) users.get(i)).getMathematics();
                c++;
            } else if (Subjects[s].equals("s2")) {
                row[c] = ((ExamDbDataHolder) users.get(i)).getEnglish();
                c++;
            } else if (Subjects[s].equals("s3")) {
                row[c] = ((ExamDbDataHolder) users.get(i)).getKiswahili();
                c++;
            } else if (Subjects[s].equals("s4")) {
                row[c] = ((ExamDbDataHolder) users.get(i)).getPhysics();
                c++;
            } else if (Subjects[s].equals("s5")) {
                row[c] = ((ExamDbDataHolder) users.get(i)).getChemistry();
                c++;
            } else if (Subjects[s].equals("s6")) {
                row[c] = ((ExamDbDataHolder) users.get(i)).getBiology();
                c++;
            } else if (Subjects[s].equals("s7")) {
                row[c] = ((ExamDbDataHolder) users.get(i)).getHistory();
                c++;
            } else if (Subjects[s].equals("s8")) {
                row[c] = ((ExamDbDataHolder) users.get(i)).getGeography();
                c++;
            } else if (Subjects[s].equals("s9")) {
                row[c] = ((ExamDbDataHolder) users.get(i)).getCre();
                c++;
            } else if (Subjects[s].equals("s10")) {
                row[c] = ((ExamDbDataHolder) users.get(i)).getIre();
                c++;
            } else if (Subjects[s].equals("s11")) {
                row[c] = ((ExamDbDataHolder) users.get(i)).getHre();
                c++;
            } else if (Subjects[s].equals("s12")) {
                row[c] = ((ExamDbDataHolder) users.get(i)).getAgriculture();
                c++;
            } else if (Subjects[s].equals("s13")) {
                row[c] = ((ExamDbDataHolder) users.get(i)).getHomescience();
                c++;
            } else if (Subjects[s].equals("s14")) {
                row[c] = ((ExamDbDataHolder) users.get(i)).getArtdesign();
                c++;
            } else if (Subjects[s].equals("s15")) {
                row[c] = ((ExamDbDataHolder) users.get(i)).getComputer();
                c++;

            } else if (Subjects[s].equals("s16")) {
                row[c] = ((ExamDbDataHolder) users.get(i)).getBuilding();
                c++;
            } else if (Subjects[s].equals("s17")) {
                row[c] = ((ExamDbDataHolder) users.get(i)).getWoodwork();
                c++;
            } else if (Subjects[s].equals("s18")) {
                row[c] = ((ExamDbDataHolder) users.get(i)).getMetalwork();
                c++;
            } else if (Subjects[s].equals("s19")) {
                row[c] = ((ExamDbDataHolder) users.get(i)).getMusic();
                c++;
            } else if (Subjects[s].equals("s20")) {
                row[c] = ((ExamDbDataHolder) users.get(i)).getFrench();
                c++;
            } else if (Subjects[s].equals("s21")) {
                row[c] = ((ExamDbDataHolder) users.get(i)).getGerman();
                c++;
            } else if (Subjects[s].equals("s22")) {
                row[c] = ((ExamDbDataHolder) users.get(i)).getArabic();
                c++;
            } else if (Subjects[s].equals("s23")) {
                row[c] = ((ExamDbDataHolder) users.get(i)).getBusiness();
                c++;
            }
        }

        //      row[2] = ((ExamDbDataHolder)users.get(i)).getMathematics();
        //      row[3] = ((ExamDbDataHolder)users.get(i)).getEng();
        //      row[4] = ((ExamDbDataHolder)users.get(i)).getKiswa();
        //      row[5] = ((ExamDbDataHolder)users.get(i)).getPhy();
        //      row[6] = ((ExamDbDataHolder)users.get(i)).getChem();
        //      row[7] = ((ExamDbDataHolder)users.get(i)).getBio();
        //      row[8] = ((ExamDbDataHolder)users.get(i)).getHist();
        //      row[9] = ((ExamDbDataHolder)users.get(i)).getGeo();
        //      row[10] = ((ExamDbDataHolder)users.get(i)).getCre();
        //      row[11] = ((ExamDbDataHolder)users.get(i)).getAgri();
        //      row[12] = ((ExamDbDataHolder)users.get(i)).getBs();

        model.addRow(row);
    }
    this.table.setModel(model);
}