Example usage for javax.swing DefaultListModel DefaultListModel

List of usage examples for javax.swing DefaultListModel DefaultListModel

Introduction

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

Prototype

DefaultListModel

Source Link

Usage

From source file:imageuploader.ImgWindow.java

/**
 * This method is called from within the constructor to initialize the form.
 * WARNING: Do NOT modify this code. The content of this method is always
 * regenerated by the Form Editor.//w w w.j  a va  2s . c om
 */
@SuppressWarnings("unchecked")
// <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
private void initComponents() {

    jFC_Images = new javax.swing.JFileChooser();
    jD_Alert = new javax.swing.JDialog();
    jScrollPane2 = new javax.swing.JScrollPane();
    jList1 = new javax.swing.JList();
    jMenuBar2 = new javax.swing.JMenuBar();
    jMenu3 = new javax.swing.JMenu();
    jMenu4 = new javax.swing.JMenu();
    jMenu5 = new javax.swing.JMenu();
    jMenuItem2 = new javax.swing.JMenuItem();
    jPanel1 = new javax.swing.JPanel();
    jLabel1 = new javax.swing.JLabel();
    jLabel2 = new javax.swing.JLabel();
    jTF_StyleCode = new javax.swing.JTextField();
    jLabel3 = new javax.swing.JLabel();
    jCB_Colors = new javax.swing.JComboBox();
    jLabel4 = new javax.swing.JLabel();
    jB_upload = new javax.swing.JButton();
    jScrollPane3 = new javax.swing.JScrollPane();
    jL_Info = new javax.swing.JList();
    jB_Remove = new javax.swing.JButton();
    jLabel5 = new javax.swing.JLabel();
    jCHBox_MY = new javax.swing.JCheckBox();
    jCHB_CA = new javax.swing.JCheckBox();
    jCHB_AZ = new javax.swing.JCheckBox();
    jMenuBar1 = new javax.swing.JMenuBar();
    jMenu1 = new javax.swing.JMenu();
    jMenu2 = new javax.swing.JMenu();
    jMI_colorFile = new javax.swing.JMenuItem();
    jMenu6 = new javax.swing.JMenu();
    jMenuItem3 = new javax.swing.JMenuItem();

    javax.swing.GroupLayout jD_AlertLayout = new javax.swing.GroupLayout(jD_Alert.getContentPane());
    jD_Alert.getContentPane().setLayout(jD_AlertLayout);
    jD_AlertLayout.setHorizontalGroup(jD_AlertLayout
            .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING).addGap(0, 400, Short.MAX_VALUE));
    jD_AlertLayout.setVerticalGroup(jD_AlertLayout
            .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING).addGap(0, 300, Short.MAX_VALUE));

    jList1.setModel(new javax.swing.AbstractListModel() {
        String[] strings = { "Item 1", "Item 2", "Item 3", "Item 4", "Item 5" };

        public int getSize() {
            return strings.length;
        }

        public Object getElementAt(int i) {
            return strings[i];
        }
    });
    jScrollPane2.setViewportView(jList1);

    jMenu3.setText("File");
    jMenuBar2.add(jMenu3);

    jMenu4.setText("Edit");
    jMenuBar2.add(jMenu4);

    jMenu5.setText("jMenu5");

    jMenuItem2.setText("jMenuItem2");

    setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
    setTitle("Myron Upload Images");
    setResizable(false);

    jLabel1.setFont(new java.awt.Font("Tahoma", 1, 18)); // NOI18N
    jLabel1.setText("Create Images");

    jLabel2.setText("Style Code");

    jLabel3.setText("Color");

    jCB_Colors.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Click in Edit-> Color File" }));
    jCB_Colors.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            jCB_ColorsActionPerformed(evt);
        }
    });

    jLabel4.setText("Upload Images");

    jB_upload.setText("Upload");
    jB_upload.addMouseListener(new java.awt.event.MouseAdapter() {
        public void mouseClicked(java.awt.event.MouseEvent evt) {
            jB_uploadMouseClicked(evt);
        }
    });

    DefaultListModel listModel = new DefaultListModel();
    jL_Info.setModel(listModel);
    jScrollPane3.setViewportView(jL_Info);

    jB_Remove.setFont(new java.awt.Font("Tahoma", 1, 8)); // NOI18N
    jB_Remove.setText("-");
    jB_Remove.addMouseListener(new java.awt.event.MouseAdapter() {
        public void mouseClicked(java.awt.event.MouseEvent evt) {
            jB_RemoveMouseClicked(evt);
        }
    });

    jLabel5.setText("Upload FTP");

    jCHBox_MY.setText("MY");

    jCHB_CA.setText("CA");

    jCHB_AZ.setText("AZ");

    javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
    jPanel1.setLayout(jPanel1Layout);
    jPanel1Layout
            .setHorizontalGroup(
                    jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING).addGroup(
                            javax.swing.GroupLayout.Alignment.TRAILING,
                            jPanel1Layout.createSequentialGroup().addGap(0, 0, Short.MAX_VALUE)
                                    .addComponent(jLabel1).addGap(69, 69, 69))
                            .addGroup(jPanel1Layout
                                    .createSequentialGroup().addGroup(jPanel1Layout.createParallelGroup(
                                            javax.swing.GroupLayout.Alignment.LEADING)
                                            .addGroup(jPanel1Layout.createSequentialGroup().addComponent(
                                                    jScrollPane3, javax.swing.GroupLayout.PREFERRED_SIZE, 251,
                                                    javax.swing.GroupLayout.PREFERRED_SIZE).addPreferredGap(
                                                            javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                                    .addComponent(jB_Remove,
                                                            javax.swing.GroupLayout.PREFERRED_SIZE, 18,
                                                            javax.swing.GroupLayout.PREFERRED_SIZE))
                                            .addGroup(jPanel1Layout
                                                    .createSequentialGroup().addComponent(jLabel4).addGap(18,
                                                            18, 18)
                                                    .addComponent(jB_upload,
                                                            javax.swing.GroupLayout.PREFERRED_SIZE, 145,
                                                            javax.swing.GroupLayout.PREFERRED_SIZE))
                                            .addGroup(jPanel1Layout.createSequentialGroup()
                                                    .addGroup(jPanel1Layout
                                                            .createParallelGroup(
                                                                    javax.swing.GroupLayout.Alignment.LEADING)
                                                            .addGroup(jPanel1Layout.createParallelGroup(
                                                                    javax.swing.GroupLayout.Alignment.TRAILING,
                                                                    false)
                                                                    .addComponent(jLabel3,
                                                                            javax.swing.GroupLayout.Alignment.LEADING,
                                                                            javax.swing.GroupLayout.DEFAULT_SIZE,
                                                                            javax.swing.GroupLayout.DEFAULT_SIZE,
                                                                            Short.MAX_VALUE)
                                                                    .addComponent(jLabel2,
                                                                            javax.swing.GroupLayout.Alignment.LEADING,
                                                                            javax.swing.GroupLayout.DEFAULT_SIZE,
                                                                            javax.swing.GroupLayout.DEFAULT_SIZE,
                                                                            Short.MAX_VALUE))
                                                            .addComponent(jLabel5))
                                                    .addGap(35, 35, 35)
                                                    .addGroup(jPanel1Layout
                                                            .createParallelGroup(
                                                                    javax.swing.GroupLayout.Alignment.LEADING,
                                                                    false)
                                                            .addComponent(jCB_Colors,
                                                                    javax.swing.GroupLayout.PREFERRED_SIZE, 145,
                                                                    javax.swing.GroupLayout.PREFERRED_SIZE)
                                                            .addComponent(jTF_StyleCode,
                                                                    javax.swing.GroupLayout.PREFERRED_SIZE, 145,
                                                                    javax.swing.GroupLayout.PREFERRED_SIZE)
                                                            .addGroup(jPanel1Layout.createSequentialGroup()
                                                                    .addComponent(jCHBox_MY).addGap(18, 18, 18)
                                                                    .addComponent(jCHB_CA)
                                                                    .addPreferredGap(
                                                                            javax.swing.LayoutStyle.ComponentPlacement.RELATED,
                                                                            javax.swing.GroupLayout.DEFAULT_SIZE,
                                                                            Short.MAX_VALUE)
                                                                    .addComponent(jCHB_AZ)))))
                                    .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)));
    jPanel1Layout.setVerticalGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup().addContainerGap().addComponent(jLabel1)
                    .addGap(18, 18, 18)
                    .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jLabel2).addComponent(jTF_StyleCode,
                                    javax.swing.GroupLayout.PREFERRED_SIZE,
                                    javax.swing.GroupLayout.DEFAULT_SIZE,
                                    javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addGap(18, 18, 18)
                    .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jLabel3).addComponent(jCB_Colors,
                                    javax.swing.GroupLayout.PREFERRED_SIZE,
                                    javax.swing.GroupLayout.DEFAULT_SIZE,
                                    javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                    .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jLabel5).addComponent(jCHBox_MY).addComponent(jCHB_CA)
                            .addComponent(jCHB_AZ))
                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 8, Short.MAX_VALUE)
                    .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(jLabel4, javax.swing.GroupLayout.Alignment.TRAILING)
                            .addComponent(jB_upload, javax.swing.GroupLayout.Alignment.TRAILING))
                    .addGap(18, 18, 18)
                    .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(jScrollPane3, javax.swing.GroupLayout.PREFERRED_SIZE,
                                    javax.swing.GroupLayout.DEFAULT_SIZE,
                                    javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(jB_Remove, javax.swing.GroupLayout.PREFERRED_SIZE, 18,
                                    javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addGap(25, 25, 25)));

    jMenu1.setText("File");
    jMenuBar1.add(jMenu1);

    jMenu2.setText("Edit");

    jMI_colorFile.setText("Color File");
    jMI_colorFile.addMouseListener(new java.awt.event.MouseAdapter() {
        public void mouseClicked(java.awt.event.MouseEvent evt) {
            jMI_colorFileMouseClicked(evt);
        }

        public void mouseEntered(java.awt.event.MouseEvent evt) {
            jMI_colorFileMouseEntered(evt);
        }

        public void mousePressed(java.awt.event.MouseEvent evt) {
            jMI_colorFileMousePressed(evt);
        }
    });
    jMenu2.add(jMI_colorFile);

    jMenuBar1.add(jMenu2);

    jMenu6.setText("FTP");

    jMenuItem3.setText("FTP Access");
    jMenuItem3.addMouseListener(new java.awt.event.MouseAdapter() {
        public void mouseClicked(java.awt.event.MouseEvent evt) {
            jMenuItem3MouseClicked(evt);
        }

        public void mouseEntered(java.awt.event.MouseEvent evt) {
            jMenuItem3MouseEntered(evt);
        }

        public void mousePressed(java.awt.event.MouseEvent evt) {
            jMenuItem3MousePressed(evt);
        }
    });
    jMenu6.add(jMenuItem3);

    jMenuBar1.add(jMenu6);

    setJMenuBar(jMenuBar1);

    javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
    getContentPane().setLayout(layout);
    layout.setHorizontalGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup().addContainerGap().addComponent(jPanel1,
                    javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addContainerGap()));
    layout.setVerticalGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup().addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE,
                    javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE).addContainerGap()));

    pack();
}

From source file:com.t3.client.ui.AddResourceDialog.java

private void downloadLibraryList() {
    if (downloadLibraryListInitiated) {
        return;/*from  w ww.  j a v a2  s  .  com*/
    }

    // This pattern is safe because it is only called on the EDT
    downloadLibraryListInitiated = true;

    new SwingWorker<Object, Object>() {
        ListModel model;

        @Override
        protected Object doInBackground() throws Exception {
            String result = null;
            try {
                WebDownloader downloader = new WebDownloader(new URL(LIBRARY_LIST_URL));
                result = downloader.read();
            } finally {
                if (result == null) {
                    model = new MessageListModel(I18N.getText("dialog.addresource.errorDownloading"));
                    return null;
                }
            }
            DefaultListModel<LibraryRow> listModel = new DefaultListModel<LibraryRow>();

            // Create a list to compare against for dups
            List<String> libraryNameList = new ArrayList<String>();
            for (File file : AppPreferences.getAssetRoots()) {
                libraryNameList.add(file.getName());
            }
            // Generate the list
            try {
                BufferedReader reader = new BufferedReader(
                        new InputStreamReader(new ByteArrayInputStream(result.getBytes())));
                String line = null;
                while ((line = reader.readLine()) != null) {
                    LibraryRow row = new LibraryRow(line);

                    // Don't include if we've already got it
                    if (libraryNameList.contains(row.name)) {
                        continue;
                    }
                    listModel.addElement(row);
                }
                model = listModel;
            } catch (Throwable t) {
                log.error("unable to parse library list", t);
                model = new MessageListModel(I18N.getText("dialog.addresource.errorDownloading"));
            }
            return null;
        }

        @Override
        protected void done() {
            getLibraryList().setModel(model);
        }
    }.execute();
}

From source file:gtu._work.mvn.MavenRepositoryUI.java

private void initGUI() {
    try {//  www .  j  a  va  2  s .c o  m
        {
        }
        BorderLayout thisLayout = new BorderLayout();
        getContentPane().setLayout(thisLayout);
        this.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
        {
            jTabbedPane1 = new JTabbedPane();
            getContentPane().add(jTabbedPane1, BorderLayout.CENTER);
            {
                jPanel1 = new JPanel();
                BorderLayout jPanel1Layout = new BorderLayout();
                jPanel1.setLayout(jPanel1Layout);
                scanList = new JList();
                jTabbedPane1.addTab("repository", null, jPanel1, null);
                {
                    scanText = new JTextField();
                    jPanel1.add(scanText, BorderLayout.NORTH);
                }
                {
                    jScrollPane1 = new JScrollPane();
                    jPanel1.add(jScrollPane1, BorderLayout.CENTER);
                    {
                        ListModel scanListModel = new DefaultListModel();
                        jScrollPane1.setViewportView(scanList);
                        scanList.setModel(scanListModel);
                        scanList.addMouseListener(new MouseAdapter() {
                            public void mouseClicked(MouseEvent evt) {
                                defaultJListClick(scanList, evt);
                            }
                        });
                    }
                }
            }
            {
                jPanel4 = new JPanel();
                BorderLayout jPanel4Layout = new BorderLayout();
                jPanel4.setLayout(jPanel4Layout);
                jTabbedPane1.addTab("repository only jar", null, jPanel4, null);
                jPanel4.setPreferredSize(new java.awt.Dimension(520, 298));
                {
                    scanText2 = new JTextField();
                    jPanel4.add(scanText2, BorderLayout.NORTH);
                }
                {
                    jScrollPane3 = new JScrollPane();
                    jPanel4.add(jScrollPane3, BorderLayout.CENTER);
                    {
                        scanList2 = new JList();
                        jScrollPane3.setViewportView(scanList2);
                        ListModel scanList2Model = new DefaultListModel();
                        scanList2.setModel(scanList2Model);
                        scanList2.addMouseListener(new MouseAdapter() {
                            public void mouseClicked(MouseEvent evt) {
                                defaultJListClick(scanList2, evt);
                            }
                        });
                    }
                }
                {
                }
            }
            {
                jPanel2 = new JPanel();
                BorderLayout jPanel2Layout = new BorderLayout();
                jPanel2.setLayout(jPanel2Layout);
                jTabbedPane1.addTab("jar find", null, jPanel2, null);
                {
                    jarFindText = new JTextField();
                    jPanel2.add(jarFindText, BorderLayout.NORTH);
                }
                {
                    jScrollPane2 = new JScrollPane();
                    jPanel2.add(jScrollPane2, BorderLayout.CENTER);
                    {
                        ListModel jarFindListModel = new DefaultListModel();
                        jarFindList = new JList();
                        jScrollPane2.setViewportView(jarFindList);
                        jarFindList.setModel(jarFindListModel);
                        jarFindList.addMouseListener(new MouseAdapter() {
                            public void mouseClicked(MouseEvent evt) {
                                defaultJListClick(jarFindList, evt);
                            }
                        });
                    }
                }
                {
                    jarFindExecute = new JButton();
                    jPanel2.add(jarFindExecute, BorderLayout.SOUTH);
                    jarFindExecute.setText("find");
                    jarFindExecute.addActionListener(new ActionListener() {
                        public void actionPerformed(ActionEvent evt) {
                            String searchtext = jarFindText.getText();
                            if (StringUtils.isEmpty(searchtext) || searchtext.length() < 2) {
                                JOptionPaneUtil.newInstance().iconErrorMessage()
                                        .showMessageDialog("", "error");
                                return;
                            }
                            try {
                                DefaultListModel model = new DefaultListModel();
                                jarFindList.setModel(model);

                                searchtext = searchtext.trim();
                                searchtext = searchtext.replace('/', '.');
                                searchtext = searchtext.replace('\\', '.');

                                if (jarfinder == null) {
                                    jarfinder = JarFinder.newInstance();
                                } else {
                                    jarfinder.clear();
                                }

                                jarfinder.pattern(searchtext);

                                DefaultListModel scanModel = (DefaultListModel) scanList.getModel();
                                PomFile pomFile = null;
                                for (int ii = 0; ii < scanModel.getSize(); ii++) {
                                    pomFile = (PomFile) scanModel.getElementAt(ii);
                                    if (pomFile.jarFile == null) {
                                        continue;
                                    }
                                    jarfinder.setDir(pomFile.jarFile);
                                    if (!jarfinder.execute().isEmpty()) {
                                        model.addElement(pomFile);
                                    }
                                    jarfinder.getMap().clear();
                                }
                            } catch (Exception ex) {
                                JOptionPaneUtil.newInstance().iconErrorMessage()
                                        .showMessageDialog(ex.getMessage(), "error");
                                ex.printStackTrace();
                            }
                        }
                    });
                }
            }
            {
                jPanel5 = new JPanel();
                BorderLayout jPanel5Layout = new BorderLayout();
                jTabbedPane1.addTab("detail", null, jPanel5, null);
                jPanel5.setLayout(jPanel5Layout);
                {
                    jScrollPane4 = new JScrollPane();
                    jPanel5.add(jScrollPane4, BorderLayout.CENTER);
                    {
                        TableModel scanTableModel = new DefaultTableModel();
                        scanTable = new JTable();
                        BorderLayout scanTableLayout = new BorderLayout();
                        scanTable.setLayout(scanTableLayout);
                        jScrollPane4.setViewportView(scanTable);
                        scanTable.setModel(scanTableModel);
                        JTableUtil.defaultSetting(scanTable);

                        scanTable.addMouseListener(new MouseAdapter() {
                            public void mouseClicked(MouseEvent evt) {
                                tableMouseClicked(scanTable, 0, evt);
                            }
                        });
                    }
                }
            }
            {
                jPanel3 = new JPanel();
                jTabbedPane1.addTab("config", null, jPanel3, null);
                GroupLayout jPanel3Layout = new GroupLayout((JComponent) jPanel3);
                jPanel3.setLayout(jPanel3Layout);
                {
                    copyToDir = new JButton();
                    copyToDir.setText("set copy to dir");
                    copyToDir.addActionListener(new ActionListener() {
                        public void actionPerformed(ActionEvent evt) {
                            File file = JFileChooserUtil.newInstance().selectDirectoryOnly().showOpenDialog()
                                    .getApproveSelectedFile();
                            if (file == null || !file.exists() || !file.isDirectory()) {
                                JOptionPaneUtil.newInstance().iconErrorMessage()
                                        .showMessageDialog("dir is not correct!, set default desktop", "error");
                                file = FileUtil.DESKTOP_DIR;
                            }
                            copyTo = file;
                            System.out.println("copyTo: " + copyTo);
                        }
                    });
                }
                {
                    resetM2Dir = new JButton();
                    resetM2Dir.setText("set .m2 dir");
                    resetM2Dir.addActionListener(new ActionListener() {
                        public void actionPerformed(ActionEvent evt) {
                            File file = JFileChooserUtil.newInstance().selectDirectoryOnly().showOpenDialog()
                                    .getApproveSelectedFile();
                            if (file == null || !file.exists() || !file.isDirectory()) {
                                showErrorMsg();
                                repositoryDir = DEFAULT_REPOSITORY_DIR;
                                reloadRepositoryDir();
                                return;
                            }
                            File newRepository = new File(file, "repository");
                            File settings = new File(file, "settings.xml");
                            if (settings.exists() && settings.isFile() && newRepository.exists()
                                    && newRepository.isDirectory()) {
                                repositoryDir = newRepository;
                                reloadRepositoryDir();
                            } else {
                                showErrorMsg();
                            }
                        }

                        void showErrorMsg() {
                            JOptionPaneUtil.newInstance().iconErrorMessage()
                                    .showMessageDialog("dir is not correct!, set default .m2 dir", "error");
                        }
                    });
                }
                {
                    saveCurrentDataBtn = new JButton();
                    saveCurrentDataBtn.setText("save current data");
                    saveCurrentDataBtn.addActionListener(new ActionListener() {
                        public void actionPerformed(ActionEvent evt) {
                            File cfgFile = new File(PropertiesUtil.getJarCurrentPath(MavenRepositoryUI.class),
                                    MavenRepositoryUI.class.getSimpleName() + "_" + DateFormatUtil
                                            .format(System.currentTimeMillis(), "yyyyMMdd_HHmmss") + ".cfg");
                            try {
                                ObjectOutputStream writer = new ObjectOutputStream(
                                        new FileOutputStream(cfgFile));
                                writer.writeObject(pomFileList);
                                writer.writeObject(pomFileJarList);
                                writer.writeObject(pomFileMap);
                                writer.flush();
                                writer.close();
                                JOptionPaneUtil.newInstance().iconInformationMessage()
                                        .showMessageDialog("save completed!\n" + cfgFile, "SUCCESS");
                            } catch (Exception ex) {
                                JCommonUtil.handleException(ex);
                                ex.printStackTrace();
                            }
                        }
                    });
                }
                {
                    loadConfigDataBtn = new JButton();
                    loadConfigDataBtn.setText("load config data");
                    loadConfigDataBtn.addActionListener(new ActionListener() {
                        public void actionPerformed(ActionEvent evt) {
                            File cfgFile = JFileChooserUtil.newInstance().selectFileOnly()
                                    .addAcceptFile("cfg", ".cfg").showOpenDialog().getApproveSelectedFile();
                            if (cfgFile == null) {
                                JOptionPaneUtil.newInstance().iconErrorMessage()
                                        .showMessageDialog("file is not correct!", "ERROR");
                                return;
                            }
                            try {
                                ObjectInputStream reader = new ObjectInputStream(new FileInputStream(cfgFile));
                                pomFileList = (Set<PomFile>) reader.readObject();
                                pomFileJarList = (Set<PomFile>) reader.readObject();
                                pomFileMap = (Map<DependencyKey, PomFile>) reader.readObject();
                                reader.close();
                                resetUIStatus();
                                JOptionPaneUtil.newInstance().iconInformationMessage()
                                        .showMessageDialog("load completed!\n" + cfgFile, "SUCCESS");
                            } catch (Exception ex) {
                                JCommonUtil.handleException(ex);
                                ex.printStackTrace();
                            }
                        }
                    });

                }
                jPanel3Layout.setHorizontalGroup(jPanel3Layout.createSequentialGroup().addContainerGap(24, 24)
                        .addGroup(jPanel3Layout.createParallelGroup()
                                .addGroup(jPanel3Layout.createSequentialGroup().addComponent(loadConfigDataBtn,
                                        GroupLayout.PREFERRED_SIZE, 223, GroupLayout.PREFERRED_SIZE))
                                .addGroup(jPanel3Layout.createSequentialGroup().addComponent(saveCurrentDataBtn,
                                        GroupLayout.PREFERRED_SIZE, 223, GroupLayout.PREFERRED_SIZE))
                                .addGroup(jPanel3Layout.createSequentialGroup().addComponent(copyToDir,
                                        GroupLayout.PREFERRED_SIZE, 223, GroupLayout.PREFERRED_SIZE))
                                .addGroup(jPanel3Layout.createSequentialGroup().addComponent(resetM2Dir,
                                        GroupLayout.PREFERRED_SIZE, 223, GroupLayout.PREFERRED_SIZE))
                                .addGroup(jPanel3Layout.createSequentialGroup().addComponent(getJButton1(),
                                        GroupLayout.PREFERRED_SIZE, 223, GroupLayout.PREFERRED_SIZE)))
                        .addContainerGap(281, Short.MAX_VALUE));
                jPanel3Layout.setVerticalGroup(jPanel3Layout.createSequentialGroup().addContainerGap(25, 25)
                        .addComponent(copyToDir, GroupLayout.PREFERRED_SIZE, 30, GroupLayout.PREFERRED_SIZE)
                        .addGap(22)
                        .addComponent(resetM2Dir, GroupLayout.PREFERRED_SIZE, 30, GroupLayout.PREFERRED_SIZE)
                        .addGap(24)
                        .addComponent(saveCurrentDataBtn, GroupLayout.PREFERRED_SIZE, 31,
                                GroupLayout.PREFERRED_SIZE)
                        .addGap(25)
                        .addComponent(loadConfigDataBtn, GroupLayout.PREFERRED_SIZE, 31,
                                GroupLayout.PREFERRED_SIZE)
                        .addGap(28)
                        .addComponent(getJButton1(), GroupLayout.PREFERRED_SIZE, 31, GroupLayout.PREFERRED_SIZE)
                        .addContainerGap(34, Short.MAX_VALUE));
            }
            {
                jPanel6 = new JPanel();
                BorderLayout jPanel6Layout = new BorderLayout();
                jPanel6.setLayout(jPanel6Layout);
                jTabbedPane1.addTab("pom dency", null, jPanel6, null);
                {
                    openPom = new JButton();
                    jPanel6.add(openPom, BorderLayout.NORTH);
                    openPom.setText("open");
                    openPom.addActionListener(new ActionListener() {
                        public void actionPerformed(ActionEvent evt) {
                            File file = JFileChooserUtil.newInstance().selectFileAndDirectory()
                                    .showDialog("?pom,pom").getApproveSelectedFile();
                            if (file == null) {
                                JOptionPaneUtil.newInstance().iconErrorMessage()
                                        .showMessageDialog("file is not correct!!", "ERROR");
                                return;
                            }
                            List<File> pomList = new ArrayList<File>();
                            if (file.isFile()
                                    && (file.getName().endsWith(".xml") || file.getName().endsWith(".pom"))) {
                                pomList.add(file);
                            } else {
                                FileUtil.searchFileMatchs(file, "pom.xml", pomList);
                            }
                            Set<PomFile> poms = loadPomList(pomList);
                            resetUIStatus();

                            Map<DependencyKey, PomFile> map = new HashMap<DependencyKey, PomFile>();
                            Set<LoadPomListDependency.DependencyKey> errorSet = new HashSet<LoadPomListDependency.DependencyKey>();
                            for (PomFile p : poms) {
                                openPomFetchDependency(p.pom, map, errorSet);
                            }

                            PomFile pfile = null;
                            DefaultTableModel model = JTableUtil.createModel(true, "groupId", "artifactId",
                                    "jar", "pomFile");
                            for (DependencyKey key : map.keySet()) {
                                pfile = map.get(key);
                                model.addRow(new Object[] { pfile.pom.groupId, pfile.pom.artifactId,
                                        (pfile.jarFile == null ? "" : pfile.jarFile.getName()), pfile });
                            }
                            for (LoadPomListDependency.DependencyKey key : errorSet) {
                                model.addRow(new Object[] { key.groupId, key.artifactId, "ERROR" });
                            }
                            pomDenpendencyTable.setModel(model);
                        }
                    });
                }
                {
                    jScrollPane5 = new JScrollPane();
                    jPanel6.add(jScrollPane5, BorderLayout.CENTER);
                    {
                        TableModel pomDenpendencyTableModel = new DefaultTableModel();
                        pomDenpendencyTable = new JTable();
                        jScrollPane5.setViewportView(pomDenpendencyTable);
                        pomDenpendencyTable.setModel(pomDenpendencyTableModel);
                        pomDenpendencyTable.addMouseListener(new MouseAdapter() {
                            public void mouseClicked(MouseEvent evt) {
                                tableMouseClicked(pomDenpendencyTable, 3, evt);
                            }
                        });
                        JTableUtil.defaultSetting(pomDenpendencyTable);
                    }
                }
                {
                    jPanel7 = new JPanel();
                    FlowLayout jPanel7Layout = new FlowLayout();
                    jPanel7Layout.setAlignOnBaseline(true);
                    jPanel6.add(jPanel7, BorderLayout.SOUTH);
                    jPanel7.setLayout(jPanel7Layout);
                    jPanel7.setPreferredSize(new java.awt.Dimension(520, 36));
                    {
                        clipboardListJar = new JButton();
                        jPanel7.add(clipboardListJar);
                        clipboardListJar.setText("jar list to clipboard");
                        clipboardListJar.addActionListener(new ActionListener() {
                            public void actionPerformed(ActionEvent evt) {
                                List<File> list = fetchPomDependencyTableJarList();
                                StringBuilder sb = new StringBuilder();
                                for (File f : list) {
                                    sb.append(f + "\n");
                                }
                                ClipboardUtil.getInstance().setContents(sb);
                                JOptionPaneUtil.newInstance().iconInformationMessage()
                                        .showMessageDialog("clipboard set ok!", "SUCCESS");
                            }
                        });
                    }
                    {
                        pomOutputJarDir = new JButton();
                        jPanel7.add(pomOutputJarDir);
                        pomOutputJarDir.setText("set output jar dir");
                        pomOutputJarDir.addActionListener(new ActionListener() {
                            public void actionPerformed(ActionEvent evt) {
                                File file = JFileChooserUtil.newInstance().selectDirectoryOnly()
                                        .showDialog("?Jar").getApproveSelectedFile();
                                if (file == null) {
                                    JOptionPaneUtil.newInstance().iconErrorMessage()
                                            .showMessageDialog("dir is not correct!!", "ERROR");
                                    return;
                                }
                                pomOutputJarDir_ = file;
                            }
                        });
                    }
                    {
                        exportListJar = new JButton();
                        jPanel7.add(exportListJar);
                        exportListJar.setText("export list jar");
                        exportListJar.setPreferredSize(new java.awt.Dimension(113, 24));
                        exportListJar.addActionListener(new ActionListener() {
                            public void actionPerformed(ActionEvent evt) {
                                List<File> list = fetchPomDependencyTableJarList();
                                if (pomOutputJarDir_ == null || !pomOutputJarDir_.exists()
                                        || !pomOutputJarDir_.isDirectory()) {
                                    JOptionPaneUtil.newInstance().iconErrorMessage()
                                            .showMessageDialog("output dir is not correct!!", "ERROR");
                                    return;
                                }
                                if (JOptionPaneUtil.ComfirmDialogResult.YES_OK_OPTION == JOptionPaneUtil
                                        .newInstance().confirmButtonYesNo().iconWaringMessage()
                                        .showConfirmDialog("are you sure copy list jar count:(" + list.size()
                                                + ") to\n" + pomOutputJarDir_, "WARN")) {
                                    StringBuilder sb = new StringBuilder();
                                    StringBuilder fsb = new StringBuilder();
                                    sb.append("total : " + list.size() + "\n");
                                    int ok = 0;
                                    int noOk = 0;
                                    for (File f : list) {
                                        try {
                                            FileUtil.copyFile(f, new File(pomOutputJarDir_, f.getName()));
                                            ok++;
                                        } catch (IOException e) {
                                            e.printStackTrace();
                                            noOk++;
                                            fsb.append(f + "\n");
                                        }
                                    }
                                    sb.append("success : " + ok + "\n");
                                    sb.append("failed : " + noOk + "\n");
                                    sb.append("Failed jar :\n");
                                    sb.append(fsb);

                                    JOptionPaneUtil.newInstance().iconErrorMessage().showMessageDialog(sb,
                                            "COPY RESULT");
                                }

                            }
                        });
                    }
                }
            }
        }
        this.setSize(541, 365);

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

From source file:br.upe.ecomp.dosa.view.wizard.WizardAction.java

private void initStopConditions() {
    addStopConditions();/* www  . j  av a  2 s .  c  o  m*/
    stopConditionSelectedList.setModel(new DefaultListModel());
    stopConditionDescriptionTextArea.setText("");
    updateStopConditionButtonsStatus();

    stopConditionAvailableList.addListSelectionListener(new ListSelectionListener() {

        @Override
        public void valueChanged(final ListSelectionEvent evt) {
            stopConditionAvailableListSelectionListner();
        }
    });
    stopConditionSelectedList.addListSelectionListener(new ListSelectionListener() {

        @Override
        public void valueChanged(final ListSelectionEvent evt) {
            stopConditionSelectedListSelectionListner();
        }
    });
}

From source file:gg.msn.ui.panel.MainPanel.java

/** This method is called from within the constructor to
 * initialize the form./*from  w w  w .  ja v a  2  s.  com*/
 * WARNING: Do NOT modify this code. The content of this method is
 * always regenerated by the Form Editor.
 */
@SuppressWarnings("unchecked")
// <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
private void initComponents() {

    nickLabel = new javax.swing.JLabel();
    jToolBar1 = new javax.swing.JToolBar();
    selectThemeButton = new javax.swing.JButton();
    chat = new javax.swing.JButton();
    jButton1 = new javax.swing.JButton();
    disconnect = new javax.swing.JButton();
    clientListScrollPane = new javax.swing.JScrollPane();
    clientsList = new javax.swing.JList();
    nickIcon = new javax.swing.JLabel();

    setName("Form"); // NOI18N

    org.jdesktop.application.ResourceMap resourceMap = org.jdesktop.application.Application
            .getInstance(gg.msn.ui.ChatClientApp.class).getContext().getResourceMap(MainPanel.class);
    nickLabel.setFont(resourceMap.getFont("nickLabel.font")); // NOI18N
    nickLabel.setText(resourceMap.getString("nickLabel.text")); // NOI18N
    nickLabel.setName("nickLabel"); // NOI18N

    jToolBar1.setFloatable(false);
    jToolBar1.setBorderPainted(false);
    jToolBar1.setName("jToolBar1"); // NOI18N
    jToolBar1.setOpaque(false);

    javax.swing.ActionMap actionMap = org.jdesktop.application.Application
            .getInstance(gg.msn.ui.ChatClientApp.class).getContext().getActionMap(MainPanel.class, this);
    selectThemeButton.setAction(actionMap.get("showFacebookOptionsDialog")); // NOI18N
    selectThemeButton.setIcon(resourceMap.getIcon("selectThemeButton.icon")); // NOI18N
    selectThemeButton.setText(resourceMap.getString("selectThemeButton.text")); // NOI18N
    selectThemeButton.setToolTipText(resourceMap.getString("selectThemeButton.toolTipText")); // NOI18N
    selectThemeButton.setFocusable(false);
    selectThemeButton.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
    selectThemeButton.setName("selectThemeButton"); // NOI18N
    selectThemeButton.setOpaque(false);
    selectThemeButton.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
    jToolBar1.add(selectThemeButton);

    chat.setAction(actionMap.get("addChatWithSelected")); // NOI18N
    chat.setIcon(resourceMap.getIcon("chat.icon")); // NOI18N
    chat.setToolTipText(resourceMap.getString("chat.toolTipText")); // NOI18N
    chat.setFocusable(false);
    chat.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
    chat.setName("chat"); // NOI18N
    chat.setOpaque(false);
    chat.setPreferredSize(new java.awt.Dimension(59, 59));
    chat.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
    jToolBar1.add(chat);

    jButton1.setAction(actionMap.get("showAboutBox")); // NOI18N
    jButton1.setIcon(resourceMap.getIcon("jButton1.icon")); // NOI18N
    jButton1.setText(resourceMap.getString("jButton1.text")); // NOI18N
    jButton1.setFocusable(false);
    jButton1.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
    jButton1.setName("jButton1"); // NOI18N
    jButton1.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
    jToolBar1.add(jButton1);

    disconnect.setAction(actionMap.get("disconnetti")); // NOI18N
    disconnect.setIcon(resourceMap.getIcon("disconnect.icon")); // NOI18N
    disconnect.setToolTipText(resourceMap.getString("disconnect.toolTipText")); // NOI18N
    disconnect.setFocusable(false);
    disconnect.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
    disconnect.setName("disconnect"); // NOI18N
    disconnect.setOpaque(false);
    disconnect.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
    jToolBar1.add(disconnect);

    clientListScrollPane.setBackground(new Color(255, 255, 255, 100));
    clientListScrollPane.setBorder(null);
    clientListScrollPane
            .setHorizontalScrollBarPolicy(javax.swing.ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);
    clientListScrollPane.setName("clientListScrollPane"); // NOI18N
    clientListScrollPane.setOpaque(false);

    clientsList.setBackground(new Color(255, 255, 255, 100));
    clientsList.setBorder(javax.swing.BorderFactory.createTitledBorder(null,
            resourceMap.getString("clientsList.border.title"), javax.swing.border.TitledBorder.CENTER,
            javax.swing.border.TitledBorder.DEFAULT_POSITION,
            resourceMap.getFont("clientsList.border.titleFont"))); // NOI18N
    clientsList.setModel(new DefaultListModel());
    clientsList.setSelectionMode(javax.swing.ListSelectionModel.SINGLE_SELECTION);
    clientsList.setCellRenderer(new ClientsListCellRenderer());
    clientsList.setFocusable(false);
    clientsList.setInheritsPopupMenu(true);
    clientsList.setName("clientsList"); // NOI18N
    clientsList.setOpaque(false);
    clientsList.setSelectionBackground(new Color(204, 204, 204, 150));
    clientsList.setVisibleRowCount(1);
    clientListScrollPane.setViewportView(clientsList);

    nickIcon.setIcon(resourceMap.getIcon("nickIcon.icon")); // NOI18N
    nickIcon.setName("nickIcon"); // NOI18N

    javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
    this.setLayout(layout);
    layout.setHorizontalGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup().addContainerGap().addGroup(layout
                    .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(layout.createSequentialGroup().addGroup(layout
                            .createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                            .addComponent(clientListScrollPane, javax.swing.GroupLayout.DEFAULT_SIZE, 294,
                                    Short.MAX_VALUE)
                            .addGroup(javax.swing.GroupLayout.Alignment.LEADING,
                                    layout.createSequentialGroup().addComponent(nickIcon)
                                            .addPreferredGap(
                                                    javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                                            .addComponent(nickLabel)))
                            .addContainerGap())
                    .addComponent(jToolBar1, javax.swing.GroupLayout.Alignment.TRAILING,
                            javax.swing.GroupLayout.PREFERRED_SIZE, 140,
                            javax.swing.GroupLayout.PREFERRED_SIZE))));
    layout.setVerticalGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                    .addComponent(jToolBar1, javax.swing.GroupLayout.PREFERRED_SIZE, 34,
                            javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addGap(18, 18, 18)
                    .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                            .addComponent(nickLabel).addComponent(nickIcon,
                                    javax.swing.GroupLayout.PREFERRED_SIZE, 48,
                                    javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                    .addComponent(clientListScrollPane, javax.swing.GroupLayout.DEFAULT_SIZE, 270,
                            Short.MAX_VALUE)
                    .addContainerGap()));
}

From source file:net.sf.taverna.t2.workbench.cagrid.CaGridComponent.java

private void addResultPanel() {
    GridBagConstraints c = new GridBagConstraints();
    c.gridx = 0;/*from   w ww.j a  v  a  2 s.  c  o m*/
    c.gridy = ++row;
    c.fill = GridBagConstraints.BOTH;
    c.weightx = 0.01;
    c.weighty = 0.01;
    c.anchor = GridBagConstraints.SOUTHEAST;
    c.gridwidth = GridBagConstraints.REMAINDER;
    resultPanel = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT);
    resultPanel.setDividerLocation(200);
    resultPanel.setBorder(null);
    runListModel = new DefaultListModel();
    runList = new JList(runListModel);
    runList.setBorder(new EmptyBorder(5, 5, 5, 5));
    runList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    runListPanel = new JPanel(new BorderLayout());
    runListPanel.setBorder(LineBorder.createGrayLineBorder());

    JLabel worklflowRunsLabel = new JLabel("Workflow Runs");
    worklflowRunsLabel.setBorder(new EmptyBorder(5, 5, 5, 5));
    removeCaGridRunsButton = new JButton("Remove"); // button to remove previous workflow runs
    removeCaGridRunsButton.setAlignmentX(JComponent.RIGHT_ALIGNMENT);
    removeCaGridRunsButton.setEnabled(false);
    removeCaGridRunsButton.setToolTipText("Remove caGrid run(s)");
    removeCaGridRunsButton.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            int[] selected = runList.getSelectedIndices();
            for (int i = selected.length - 1; i >= 0; i--) {
                CaGridRun cr = (CaGridRun) runListModel.get(selected[i]);

                //delete the EPR file
                File file = new File(new File(System.getProperty("user.home")), cr.workflowid + ".epr");
                file.delete();
                System.out.println(cr.workflowid + ".epr deleted");
                runListModel.remove(selected[i]);
            }
            // Set the first item as selected - if there is one
            if (runListModel.size() > 0) {
                runList.setSelectedIndex(0);
            } else {
                resultText.setText("");
                resultText.revalidate();

            }
        }
    });
    runListPanel.add(worklflowRunsLabel, BorderLayout.NORTH);
    runListPanel.add(removeCaGridRunsButton, BorderLayout.BEFORE_FIRST_LINE);

    JScrollPane scrollPane = new JScrollPane(runList);
    scrollPane.setBorder(null);
    runListPanel.add(scrollPane, BorderLayout.CENTER);
    // loadWorkflowRunsFromStoredEPRFiles(): add CaGridRun to runList for each EPR
    // add two buttons: remove and refresh status
    runList.addListSelectionListener(new ListSelectionListener() {
        public void valueChanged(ListSelectionEvent e) {
            if (!e.getValueIsAdjusting()) {
                Object selection = runList.getSelectedValue();
                if (selection instanceof CaGridRun) {
                    removeCaGridRunsButton.setEnabled(true);
                    CaGridRun dataflowRun = (CaGridRun) selection;
                    // update status and refresh outputPanel
                    String resultDisplayString = updateResultDisplayString(dataflowRun);
                    resultText.setText(resultDisplayString);
                    resultText.setLineWrap(true);
                    resultText.setEditable(false);
                    outputPanel.revalidate();
                    revalidate();
                } else {
                    removeCaGridRunsButton.setEnabled(false);
                    revalidate();

                }
            }
        }
    });

    resultPanel.setTopComponent(runListPanel);

    //each output should be a (xml) string
    outputPanel = new JScrollPane();

    resultText = new JTextArea();
    outputPanel = new JScrollPane(resultText, JScrollPane.VERTICAL_SCROLLBAR_ALWAYS,
            JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
    //outputPanel = new JPanel(new BorderLayout());
    outputPanel.setBorder(LineBorder.createGrayLineBorder());
    outputPanel.setBackground(Color.WHITE);
    //outputPanel.add(new JLabel("Workflow Execution Outputs shows here.", JLabel.CENTER), null);
    resultPanel.setBottomComponent(outputPanel);
    add(resultPanel, c);

    //add runComponent to the GUI
    ArrayList<CaGridRun> loadedRunList = loadWorkflowRunsFromStoredEPRFiles(null,
            (String) services.getSelectedItem());
    if (loadedRunList != null) {
        for (int m = 0; m < loadedRunList.size(); m++) {
            CaGridRun cr = (CaGridRun) loadedRunList.get(m);
            runListModel.add(0, cr);
        }
        System.out.println(loadedRunList.size() + " EPR loaded.");
        runList.setSelectedIndex(0);
    }

}

From source file:interfaceTisseoWS.ST1.java

private void listeLignesItemStateChanged(java.awt.event.ItemEvent evt) {//GEN-FIRST:event_listeLignesItemStateChanged
    DefaultListModel lm = new DefaultListModel();
    for (int i = 0; i < departs.get(listeLignes.getSelectedIndex() - 1).nbDeparts(); i++) {//remplissage de la lsite avec les prochains dparts
        lm.addElement(departs.get(listeLignes.getSelectedIndex() - 1).toString(i));
    }//from  w  w  w .  j a v  a 2 s .c  om

    horaires.setModel(lm);

}

From source file:edu.ku.brc.specify.utilapps.sp5utils.Sp5Forms.java

/**
 * /*from   ww  w . j  av  a2 s.c o  m*/
 */
protected void createUI() {
    CellConstraints cc = new CellConstraints();
    PanelBuilder pb = new PanelBuilder(new FormLayout("f:p:g,p,p:g", "p,2px,f:p:g,4px,p,2px,p,10px,p"));

    missingFieldsList = new JList(new DefaultListModel());

    formsTable = new JTable(new FormCellModel(forms));
    formsTable.getSelectionModel().addListSelectionListener(new ListSelectionListener() {
        @Override
        public void valueChanged(ListSelectionEvent e) {
            if (formsTable.getSelectedRow() > -1) {
                formSelected();
            }
        }
    });

    fieldsTable = new JTable(fieldsTableModel = new FieldCellModel());

    TableColumn col = fieldsTable.getColumnModel().getColumn(1);
    col.setCellEditor(sp6FieldEditor = new Sp6FieldComboBoxEditor());

    // If the cell should appear like a combobox in its
    // non-editing state, also set the combobox renderer
    //col.setCellRenderer(sp6FieldRenderer = new Sp6FieldComboBoxRenderer());

    calcColumnWidths(formsTable);

    PanelBuilder pbBtn = new PanelBuilder(new FormLayout("f:p:g,p,f:p:g,p,f:p:g,p,f:p:g,p,f:p:g", "p"));
    reportBtn = createButton("Create Form Images");
    showBtn = createButton("Show");
    schemaBtn = createButton("Schema");
    dataCheckerBtn = createButton("Check For Nulls");
    pbBtn.add(reportBtn, cc.xy(2, 1));
    pbBtn.add(schemaBtn, cc.xy(4, 1));
    pbBtn.add(showBtn, cc.xy(6, 1));
    pbBtn.add(dataCheckerBtn, cc.xy(8, 1));

    pb.add(createLabel("Forms", SwingConstants.CENTER), cc.xy(1, 1));
    pb.add(createLabel("Missing Fields", SwingConstants.CENTER), cc.xy(3, 1));

    pb.add(createScrollPane(formsTable), cc.xy(1, 3));
    pb.add(createScrollPane(missingFieldsList), cc.xy(3, 3));

    pb.add(createLabel("Form Fields", SwingConstants.CENTER), cc.xyw(1, 5, 3));
    pb.add(createScrollPane(fieldsTable), cc.xyw(1, 7, 3));

    pb.add(pbBtn.getPanel(), cc.xyw(1, 9, 3));
    pb.setDefaultDialogBorder();

    setContentPane(new JScrollPane(pb.getPanel()));

    showBtn.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            showForm();
        }
    });
    reportBtn.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            doCreateFormImages();
        }
    });
    schemaBtn.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            doSchema();
        }
    });

    dataCheckerBtn.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            TableDataChecker tdc = new TableDataChecker(DBConnection.getInstance().createConnection());
            tdc.doCheckDB();
        }
    });

}

From source file:burlov.ultracipher.swing.MainPanel.java

private void initResultList() {
    if (SwingGuiApplication.getInstance().getDatabase() == null) {
        return;//w w w  . j a v  a2  s  .c om
    }
    List<DataEntry> allEntries = SwingGuiApplication.getInstance().getDatabase().getEntries();
    List<DataEntry> foundedEntries = allEntries;
    if (!StringUtils.isBlank(searchField.getText())) {
        Finder finder = new Finder();
        foundedEntries = finder.findEntries(searchField.getText(), allEntries, Integer.MAX_VALUE);
    }
    searchResultModel = new DefaultListModel();
    for (DataEntry entry : foundedEntries) {
        searchResultModel.addElement(entry);
    }
    searchResults.setModel(searchResultModel);
    if (foundedEntries.size() > 0) {
        searchResults.setSelectedIndex(0);
    }
}

From source file:br.upe.ecomp.dosa.view.wizard.WizardAction.java

private void addStopConditions() {
    stopConditionAvailableList.setModel(new DefaultListModel());
    for (Class<? extends StopCondition> stopCondition : applicationContext.getStopConditionList()) {
        try {/*ww w.ja v a 2 s  .  co  m*/
            ((DefaultListModel) stopConditionAvailableList.getModel())
                    .addElement(stopCondition.getConstructors()[0].newInstance());
        } catch (IllegalArgumentException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        } catch (SecurityException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        } catch (InstantiationException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        } catch (IllegalAccessException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        } catch (InvocationTargetException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
    }
}