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:au.org.ala.delta.intkey.ui.MultiStateInputDialog.java

/**
 * ctor/*from ww  w  . j a  va 2s.com*/
 * 
 * @param owner
 *            Owner frame of dialog
 * @param ch
 *            the character whose states are being set
 * @param initialSelectedStates
 *            initial states that should be selected in the dialog. In
 *            general this should be any states already set for the
 *            character. In the case that this is a controlling character
 *            being set before its dependent character, all states that make
 *            the dependent character applicable should be selected.
 * @param dependentCharacter
 *            the dependent character - if the dialog is being used to set a
 *            controlling character before its dependent character, this
 *            argument should be a reference to the dependent character. In
 *            all other cases it should be null.
 * @param imageSettings
 *            image settings
 * @param displayNumbering
 *            true if numbering should be displayed
 * @param enableImagesButton
 *            the if the images button should be enabled
 * @param imagesStartScaled
 *            true if images should start scaled.
 */
public MultiStateInputDialog(Frame owner, MultiStateCharacter ch, Set<Integer> initialSelectedStates,
        au.org.ala.delta.model.Character dependentCharacter, ImageSettings imageSettings,
        boolean displayNumbering, boolean enableImagesButton, boolean imagesStartScaled, boolean advancedMode) {
    super(owner, ch, imageSettings, displayNumbering, enableImagesButton, imagesStartScaled, advancedMode);

    ResourceMap resourceMap = Application.getInstance().getContext()
            .getResourceMap(MultiStateInputDialog.class);
    resourceMap.injectFields(this);

    setTitle(title);
    setPreferredSize(new Dimension(600, 350));

    if (dependentCharacter != null) {
        _pnlControllingCharacterMessage = new JPanel();
        _pnlControllingCharacterMessage.setFocusable(false);
        _pnlControllingCharacterMessage.setBorder(new EmptyBorder(5, 0, 0, 0));
        _pnlMain.add(_pnlControllingCharacterMessage, BorderLayout.SOUTH);
        _pnlControllingCharacterMessage.setLayout(new BorderLayout(0, 0));

        _lblWarningIcon = new JLabel("");
        _lblWarningIcon.setFocusable(false);
        _lblWarningIcon.setIcon(UIManager.getIcon("OptionPane.warningIcon"));
        _pnlControllingCharacterMessage.add(_lblWarningIcon, BorderLayout.WEST);

        _txtControllingCharacterMessage = new JTextArea();
        _txtControllingCharacterMessage.setText(MessageFormat.format(setControllingCharacterMessage,
                _formatter.formatCharacterDescription(dependentCharacter),
                _formatter.formatCharacterDescription(ch)));
        _txtControllingCharacterMessage.setFocusable(false);
        _txtControllingCharacterMessage.setBorder(new EmptyBorder(0, 5, 0, 0));
        _txtControllingCharacterMessage.setEditable(false);
        _pnlControllingCharacterMessage.add(_txtControllingCharacterMessage);
        _txtControllingCharacterMessage.setWrapStyleWord(true);
        _txtControllingCharacterMessage.setFont(UIManager.getFont("Button.font"));
        _txtControllingCharacterMessage.setLineWrap(true);
        _txtControllingCharacterMessage.setBackground(SystemColor.control);
    }

    _scrollPane = new JScrollPane();
    _pnlMain.add(_scrollPane, BorderLayout.CENTER);

    _list = new JList();
    _scrollPane.setViewportView(_list);

    _listModel = new DefaultListModel();
    for (int i = 0; i < ch.getNumberOfStates(); i++) {
        _listModel.addElement(_formatter.formatState(ch, i + 1));
    }

    _list.setModel(_listModel);

    _list.addMouseListener(new MouseAdapter() {

        @Override
        public void mouseClicked(MouseEvent e) {
            if (e.getClickCount() > 1) {
                // Treat double click on a list item as the ok button being
                // pressed.
                _okPressed = true;
                handleBtnOKClicked();
            }
        }

    });

    // Select the list items that correspond to the initial selected states.
    if (initialSelectedStates != null) {
        List<Integer> listIndiciesToSelect = new ArrayList<Integer>();
        for (int stateNumber : new ArrayList<Integer>(initialSelectedStates)) {
            listIndiciesToSelect.add(stateNumber - 1);
        }

        Integer[] wrappedPrimitivesList = listIndiciesToSelect
                .toArray(new Integer[initialSelectedStates.size()]);
        _list.setSelectedIndices(ArrayUtils.toPrimitive(wrappedPrimitivesList));
    }

    _inputData = new HashSet<Integer>();

}

From source file:de.tor.tribes.ui.views.DSWorkbenchStatsFrame.java

DSWorkbenchStatsFrame() {
    initComponents();// ww w.j a  va 2s . c o m
    centerPanel = new GenericTestPanel();
    jStatsPanel.add(centerPanel, BorderLayout.CENTER);
    centerPanel.setChildComponent(jMainStatPanel);
    buildMenu();
    capabilityInfoPanel1.addActionListener(this);
    KeyStroke bbCopy = KeyStroke.getKeyStroke(KeyEvent.VK_B, ActionEvent.CTRL_MASK, false);
    KeyStroke delete = KeyStroke.getKeyStroke(KeyEvent.VK_DELETE, 0, false);
    jTabbedPane1.registerKeyboardAction(DSWorkbenchStatsFrame.this, "BBCopy", bbCopy,
            JComponent.WHEN_IN_FOCUSED_WINDOW);
    jTribeList.registerKeyboardAction(DSWorkbenchStatsFrame.this, "Delete", delete,
            JComponent.WHEN_IN_FOCUSED_WINDOW);

    jAlwaysOnTopBox.setSelected(GlobalOptions.getProperties().getBoolean("stats.frame.alwaysOnTop"));
    setAlwaysOnTop(jAlwaysOnTopBox.isSelected());

    jAllyList.addListSelectionListener(new ListSelectionListener() {

        @Override
        public void valueChanged(ListSelectionEvent e) {
            List allySelection = jAllyList.getSelectedValuesList();
            jTribeList.clearSelection();
            List<Tribe> tribes = new LinkedList<>();
            for (Object o : allySelection) {
                Tribe[] tribesForAlly = StatManager.getSingleton().getMonitoredTribes((Ally) o);
                for (Tribe t : tribesForAlly) {
                    if (!tribes.contains(t)) {
                        tribes.add(t);
                    }
                }
                Collections.sort(tribes);
                DefaultListModel<Tribe> model = new DefaultListModel<>();
                for (Tribe t : tribes) {
                    model.addElement(t);
                }
                jTribeList.setModel(model);
            }
        }
    });

    jTribeList.addListSelectionListener(new ListSelectionListener() {

        @Override
        public void valueChanged(ListSelectionEvent e) {
            fireUpdateChartEvent(null);
        }
    });

    Calendar c = Calendar.getInstance();
    c.set(Calendar.HOUR_OF_DAY, 0);
    c.set(Calendar.MINUTE, 0);
    c.set(Calendar.SECOND, 0);
    c.set(Calendar.MILLISECOND, 0);
    jStartDate.setDate(c.getTime());
    jEndDate.setDate(c.getTime());
    jStatCreatePanel.setVisible(false);
    // <editor-fold defaultstate="collapsed" desc=" Init HelpSystem ">
    if (!Constants.DEBUG) {
        GlobalOptions.getHelpBroker().enableHelpKey(getRootPane(), "pages.stats_view",
                GlobalOptions.getHelpBroker().getHelpSet());
    }
    // </editor-fold>

    pack();
}

From source file:Creator.WidgetPanel.java

/**
 * Creates new form WidgetPanel/*from  w ww .ja  v  a  2s . c  o  m*/
 *
 * @param mf
 * @param cs
 * @param ws
 */
public WidgetPanel(MainFrame mf, ControlSettings cs, WidgetSettings ws) {
    this.mf = mf;
    this.cs = cs;
    this.widgetList = new TreeMap<>();
    this.ws = ws;
    holderNum = Instant.now().toEpochMilli();
    if (this.ws.wpl != null) {
        this.ws.wpl = ws.wpl;
    } else {
        this.ws.wpl = new WidgetPanelLinks();
    }
    this.listModelWidgetsVars = new DefaultListModel();
    this.listModelCodeWidgets = new DefaultListModel();
    this.listModelMasterMap = new DefaultListModel();
    this.stationID = -1;
    initComponents();
    loadComboBoxPanels();
    _ComboBox_Panels.setSelectedIndex(0);

}

From source file:gtu.zcognos.DimensionUI.java

private void initGUI() {
    try {/*  w  w w  .  j av  a 2 s  .  c o  m*/

        final SwingActionUtil swingUtil = (SwingActionUtil) SwingActionUtil.newInstance(this);
        {
            GroupLayout thisLayout = new GroupLayout((JComponent) getContentPane());
            getContentPane().setLayout(thisLayout);
            this.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
            {
                projectId = new JTextField();
            }
            {
                jLabel1 = new JLabel();
                jLabel1.setText("PROJECT_ID");
            }
            {
                create = new JButton();
                create.setText("create");
                create.addActionListener(new ActionListener() {
                    public void actionPerformed(ActionEvent evt) {
                        swingUtil.invokeAction("create.actionPerformed", evt);
                    }
                });
            }
            {
                reportId = new JTextField();
            }
            {
                jLabel8 = new JLabel();
                jLabel8.setText("report id");
            }
            {
                addDimensionFromDb = new JButton();
                addDimensionFromDb.setText("add from db");
                addDimensionFromDb.addActionListener(new ActionListener() {
                    public void actionPerformed(ActionEvent evt) {
                        swingUtil.invokeAction("addFromDb.actionPerformed", evt);
                    }
                });
            }
            {
                dataSourceTable = new JTextField();
                dataSourceTable.setText("rscdpg0901");
            }
            {
                jLabel7 = new JLabel();
                jLabel7.setText("data source table");
            }
            {
                addDimension = new JButton();
                addDimension.setText("add");
                addDimension.addActionListener(new ActionListener() {
                    public void actionPerformed(ActionEvent evt) {
                        swingUtil.invokeAction("add.actionPerformed", evt);
                    }
                });
            }
            {
                dimensionName = new JTextField();
            }
            {
                jLabel6 = new JLabel();
                jLabel6.setText("dimension chinese name");
            }
            {
                jLabel5 = new JLabel();
                jLabel5.setText("rscdzzzz id index");
            }
            {
                String[] idx = new String[20];
                for (int ii = 0; ii < idx.length; ii++) {
                    idx[ii] = "id" + (ii + 1);
                }
                ComboBoxModel rscdzzzzIdIndexModel = new DefaultComboBoxModel(idx);
                rscdzzzzIdIndex = new JComboBox();
                rscdzzzzIdIndex.setModel(rscdzzzzIdIndexModel);
            }
            {
                jLabel3 = new JLabel();
                jLabel3.setText("Dimension");
            }
            {
                jScrollPane1 = new JScrollPane();
                {
                    DefaultListModel dimensionListModel = new DefaultListModel();
                    dimensionList = new JList();
                    jScrollPane1.setViewportView(dimensionList);
                    dimensionList.setModel(dimensionListModel);
                    dimensionList.addKeyListener(new KeyAdapter() {
                        public void keyPressed(KeyEvent evt) {
                            JListUtil.newInstance(dimensionList).defaultJListKeyPressed(evt);
                        }
                    });
                }
            }
            {
                exportDir = new JButton();
                exportDir.setText("export dir");
                exportDir.addActionListener(new ActionListener() {
                    public void actionPerformed(ActionEvent evt) {
                        swingUtil.invokeAction("exportDir.actionPerformed", evt);
                    }
                });
            }
            {
                category = new JTextField();
            }
            {
                jLabel4 = new JLabel();
                jLabel4.setText("category");
            }
            {
                tableName = new JTextField();
            }
            {
                jLabel2 = new JLabel();
                jLabel2.setText("merge table name");
            }
            thisLayout
                    .setHorizontalGroup(thisLayout.createSequentialGroup().addContainerGap(12, 12)
                            .addGroup(thisLayout.createParallelGroup()
                                    .addComponent(jLabel3, GroupLayout.Alignment.LEADING,
                                            GroupLayout.PREFERRED_SIZE, 196, GroupLayout.PREFERRED_SIZE)
                                    .addGroup(thisLayout.createSequentialGroup().addGap(19).addGroup(thisLayout
                                            .createParallelGroup().addGroup(thisLayout.createSequentialGroup()
                                                    .addComponent(exportDir, GroupLayout.PREFERRED_SIZE, 119,
                                                            GroupLayout.PREFERRED_SIZE)
                                                    .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED)
                                                    .addComponent(
                                                            addDimension, GroupLayout.PREFERRED_SIZE, 119,
                                                            GroupLayout.PREFERRED_SIZE)
                                                    .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED)
                                                    .addGroup(thisLayout.createParallelGroup().addComponent(
                                                            addDimensionFromDb, GroupLayout.Alignment.LEADING,
                                                            GroupLayout.PREFERRED_SIZE, 191,
                                                            GroupLayout.PREFERRED_SIZE)
                                                            .addGroup(thisLayout.createSequentialGroup().addGap(
                                                                    88)
                                                                    .addComponent(create,
                                                                            GroupLayout.PREFERRED_SIZE, 119,
                                                                            GroupLayout.PREFERRED_SIZE))))
                                            .addGroup(thisLayout.createSequentialGroup().addGroup(thisLayout
                                                    .createParallelGroup()
                                                    .addComponent(jLabel6, GroupLayout.Alignment.LEADING,
                                                            GroupLayout.PREFERRED_SIZE, 196,
                                                            GroupLayout.PREFERRED_SIZE)
                                                    .addComponent(jLabel5, GroupLayout.Alignment.LEADING,
                                                            GroupLayout.PREFERRED_SIZE, 196,
                                                            GroupLayout.PREFERRED_SIZE)
                                                    .addComponent(jLabel4, GroupLayout.Alignment.LEADING,
                                                            GroupLayout.PREFERRED_SIZE, 196,
                                                            GroupLayout.PREFERRED_SIZE)
                                                    .addComponent(jLabel8, GroupLayout.Alignment.LEADING,
                                                            GroupLayout.PREFERRED_SIZE, 196,
                                                            GroupLayout.PREFERRED_SIZE)
                                                    .addComponent(jLabel2, GroupLayout.Alignment.LEADING,
                                                            GroupLayout.PREFERRED_SIZE, 196,
                                                            GroupLayout.PREFERRED_SIZE)
                                                    .addComponent(jLabel7, GroupLayout.Alignment.LEADING,
                                                            GroupLayout.PREFERRED_SIZE, 196,
                                                            GroupLayout.PREFERRED_SIZE)
                                                    .addComponent(jLabel1, GroupLayout.Alignment.LEADING,
                                                            GroupLayout.PREFERRED_SIZE, 196,
                                                            GroupLayout.PREFERRED_SIZE))
                                                    .addGap(39)
                                                    .addGroup(thisLayout.createParallelGroup()
                                                            .addComponent(dimensionName,
                                                                    GroupLayout.Alignment.LEADING,
                                                                    GroupLayout.PREFERRED_SIZE, 204,
                                                                    GroupLayout.PREFERRED_SIZE)
                                                            .addComponent(rscdzzzzIdIndex,
                                                                    GroupLayout.Alignment.LEADING,
                                                                    GroupLayout.PREFERRED_SIZE, 204,
                                                                    GroupLayout.PREFERRED_SIZE)
                                                            .addComponent(category,
                                                                    GroupLayout.Alignment.LEADING,
                                                                    GroupLayout.PREFERRED_SIZE, 204,
                                                                    GroupLayout.PREFERRED_SIZE)
                                                            .addComponent(reportId,
                                                                    GroupLayout.Alignment.LEADING,
                                                                    GroupLayout.PREFERRED_SIZE, 204,
                                                                    GroupLayout.PREFERRED_SIZE)
                                                            .addComponent(tableName,
                                                                    GroupLayout.Alignment.LEADING,
                                                                    GroupLayout.PREFERRED_SIZE, 204,
                                                                    GroupLayout.PREFERRED_SIZE)
                                                            .addComponent(dataSourceTable,
                                                                    GroupLayout.Alignment.LEADING,
                                                                    GroupLayout.PREFERRED_SIZE, 204,
                                                                    GroupLayout.PREFERRED_SIZE)
                                                            .addComponent(projectId,
                                                                    GroupLayout.Alignment.LEADING,
                                                                    GroupLayout.PREFERRED_SIZE, 204,
                                                                    GroupLayout.PREFERRED_SIZE)))
                                            .addComponent(jScrollPane1, GroupLayout.Alignment.LEADING,
                                                    GroupLayout.PREFERRED_SIZE, 436,
                                                    GroupLayout.PREFERRED_SIZE))))
                            .addContainerGap(11, 11));
            thisLayout.setVerticalGroup(thisLayout.createSequentialGroup().addContainerGap(12, 12)
                    .addGroup(thisLayout.createParallelGroup(GroupLayout.Alignment.BASELINE)
                            .addComponent(projectId, GroupLayout.Alignment.BASELINE, GroupLayout.PREFERRED_SIZE,
                                    GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
                            .addComponent(jLabel1, GroupLayout.Alignment.BASELINE, GroupLayout.PREFERRED_SIZE,
                                    GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE))
                    .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED)
                    .addGroup(thisLayout.createParallelGroup(GroupLayout.Alignment.BASELINE)
                            .addComponent(dataSourceTable, GroupLayout.Alignment.BASELINE,
                                    GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE,
                                    GroupLayout.PREFERRED_SIZE)
                            .addComponent(jLabel7, GroupLayout.Alignment.BASELINE, GroupLayout.PREFERRED_SIZE,
                                    GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE))
                    .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED)
                    .addComponent(jLabel3, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE,
                            GroupLayout.PREFERRED_SIZE)
                    .addGroup(thisLayout.createParallelGroup(GroupLayout.Alignment.BASELINE)
                            .addComponent(tableName, GroupLayout.Alignment.BASELINE, GroupLayout.PREFERRED_SIZE,
                                    GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
                            .addComponent(jLabel2, GroupLayout.Alignment.BASELINE, GroupLayout.PREFERRED_SIZE,
                                    GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE))
                    .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED)
                    .addGroup(thisLayout.createParallelGroup(GroupLayout.Alignment.BASELINE)
                            .addComponent(reportId, GroupLayout.Alignment.BASELINE, GroupLayout.PREFERRED_SIZE,
                                    GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
                            .addComponent(jLabel8, GroupLayout.Alignment.BASELINE, GroupLayout.PREFERRED_SIZE,
                                    GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE))
                    .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED)
                    .addGroup(thisLayout.createParallelGroup(GroupLayout.Alignment.BASELINE)
                            .addComponent(category, GroupLayout.Alignment.BASELINE, GroupLayout.PREFERRED_SIZE,
                                    GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
                            .addComponent(jLabel4, GroupLayout.Alignment.BASELINE, GroupLayout.PREFERRED_SIZE,
                                    GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE))
                    .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED)
                    .addGroup(thisLayout.createParallelGroup()
                            .addComponent(jLabel5, GroupLayout.Alignment.LEADING, GroupLayout.PREFERRED_SIZE,
                                    GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
                            .addComponent(rscdzzzzIdIndex, GroupLayout.Alignment.LEADING,
                                    GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE,
                                    GroupLayout.PREFERRED_SIZE))
                    .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED)
                    .addGroup(thisLayout.createParallelGroup(GroupLayout.Alignment.BASELINE)
                            .addComponent(dimensionName, GroupLayout.Alignment.BASELINE,
                                    GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE,
                                    GroupLayout.PREFERRED_SIZE)
                            .addComponent(jLabel6, GroupLayout.Alignment.BASELINE, GroupLayout.PREFERRED_SIZE,
                                    GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE))
                    .addPreferredGap(LayoutStyle.ComponentPlacement.UNRELATED)
                    .addGroup(thisLayout.createParallelGroup(GroupLayout.Alignment.BASELINE)
                            .addComponent(addDimension, GroupLayout.Alignment.BASELINE,
                                    GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE,
                                    GroupLayout.PREFERRED_SIZE)
                            .addComponent(exportDir, GroupLayout.Alignment.BASELINE, GroupLayout.PREFERRED_SIZE,
                                    GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
                            .addComponent(addDimensionFromDb, GroupLayout.Alignment.BASELINE,
                                    GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE,
                                    GroupLayout.PREFERRED_SIZE))
                    .addGap(11)
                    .addComponent(jScrollPane1, GroupLayout.PREFERRED_SIZE, 269, GroupLayout.PREFERRED_SIZE)
                    .addGap(12).addComponent(create, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE,
                            GroupLayout.PREFERRED_SIZE)
                    .addContainerGap(9, 9));
        }
        this.setSize(513, 632);

        swingUtil.addAction("exportDir.actionPerformed", new Action() {
            public void action(EventObject evt) throws Exception {
                File file = JFileChooserUtil.newInstance().selectDirectoryOnly().showOpenDialog()
                        .getApproveSelectedFile();
                if (file != null) {
                    baseDir = file;
                }
            }
        });

        swingUtil.addAction("addFromDb.actionPerformed", new Action() {
            public void action(EventObject evt) throws Exception {
                String project = projectId.getText();
                Validate.notEmpty(project, "projectId is null");
                Validate.notEmpty(dataSourceTable.getText(), "dataSourceTable is null");

                DefaultListModel model = (DefaultListModel) dimensionList.getModel();
                for (Dimension_ ddd : InformixDbConn.queryGetDaminsion(dataSourceTable.getText(), project)) {
                    model.addElement(ddd);
                }
            }
        });

        swingUtil.addAction("add.actionPerformed", new Action() {
            public void action(EventObject evt) throws Exception {
                // Validate.notEmpty(tableName.getText(),
                // "tableName is null");
                Validate.notEmpty(category.getText(), "category is null");
                Validate.notEmpty(dimensionName.getText(), "dimensionName is null");
                Validate.notEmpty(dataSourceTable.getText(), "dataSourceTable is null");
                // Validate.notEmpty(reportId.getText(),
                // "reportId is null");

                String report_id = StringUtils.defaultString(reportId.getText(), projectId.getText());

                String tName = tableName.getText();
                if (StringUtils.isEmpty(tName)) {
                    tName = randomTableName();
                }

                DefaultListModel model = (DefaultListModel) dimensionList.getModel();
                model.addElement(new Dimension_(dataSourceTable.getText(), tName, category.getText(),
                        (String) rscdzzzzIdIndex.getSelectedItem(), dimensionName.getText(), report_id));
            }
        });

        swingUtil.addAction("create.actionPerformed", new Action() {
            public void action(EventObject evt) throws Exception {

                String project = projectId.getText();
                Validate.notEmpty(project, "projectId is null");
                Validate.notNull(baseDir, "exportDir is null");

                File destDir = new File(baseDir, project);

                Map<String, Object> map = new HashMap<String, Object>();

                List<Map<String, String>> llist = new ArrayList<Map<String, String>>();

                int idx = 2;
                int categoryId = 1;
                DefaultListModel model = (DefaultListModel) dimensionList.getModel();
                for (Enumeration<?> enu = model.elements(); enu.hasMoreElements();) {
                    Dimension_ di = (Dimension_) enu.nextElement();

                    Map mmm = new HashMap();
                    mmm.put("rscdpg0901", di.dataSourceTable);//
                    mmm.put("rscdpg0901a", di.tableName);//
                    mmm.put("rscdpg0901a_category", di.category);//
                    mmm.put("rscdpg0901a_report_id", di.reportId);//
                    mmm.put("rscdzzzz_id", di.idIndex);//
                    mmm.put("rscdpg0901a_dname", di.dimensionName);//
                    llist.add(mmm);
                }

                map.put("PROJECT_ID", project);
                map.put("RSCDPG0901", llist);
                map.put("rscdpg0901", dataSourceTable.getText());

                ConfigCopy.getInstance().applyBaseDir(baseDir).applyProjectId(project).execute();

                Dimension.getInstance()//
                        .applyDestDir(destDir.getAbsolutePath())//
                        .applyParameter(map)//
                        .execute();

                JOptionPaneUtil.newInstance().iconInformationMessage()
                        .showMessageDialog(project + " create completed!!\r\n dir : " //
                                + destDir.getAbsolutePath(), project);

                Desktop.getDesktop().open(destDir);
            }
        });

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

From source file:com.talent.aio.examples.im.client.ui.JFrameMain.java

/**
 * Creates new form JFrameMain//from   w w  w . ja va2  s. c  o  m
 */
private JFrameMain() {
    listModel = new DefaultListModel<ClientChannelContext<Object, ImPacket, Object>>();
    initComponents();

    //#2ecc71 OK
    //##f1c40f warn
    Color okColor = new Color(0x2e, 0xcc, 0x71);
    Color warnColor = new Color(0xe7, 0x4c, 0x3c);
    clients.setCellRenderer(new ImListCellRenderer(okColor, warnColor));
    try {
        imClientStarter = new ImClientStarter();
    } catch (IOException e) {
        throw new RuntimeException(e);
    }

    new Thread(new Runnable() {
        @Override
        public void run() {
            while (true) {
                updateConnectionCount();
                updateReceivedLabel();
                updateSentLabel();

                if (isNeedUpdateList) {
                    WriteLock writeLock = updatingListLock.writeLock();
                    if (writeLock.tryLock()) {
                        try {
                            isNeedUpdateList = false;
                            clients.updateUI();
                        } catch (Exception e) {
                            log.error(e.toString(), e);
                        } finally {
                            writeLock.unlock();
                        }
                    }
                }

                try {
                    Thread.sleep(100L);
                } catch (InterruptedException e) {
                    log.error(e.toString(), e);
                }
            }
        }

    }, "update ui task").start();
}

From source file:forms.frDados.java

/**
 * L todos os usurios cadastrados no banco e
 * coloca no listbox de usurios.//from   w w w. j a  va 2 s  . com
 */
private void carregarListaUsers() {
    try {
        ArrayList<String> users = ControleAcesso.getUsers();
        DefaultListModel dfm = new DefaultListModel();

        for (String user : users)
            dfm.addElement(user);

        lstUsers.setModel(dfm);
    } catch (Exception erro) {
        Util.ExibirMensagem(Util.EnumTipoMensagem.Erro, erro.getMessage());
    }

}

From source file:edu.ku.brc.af.ui.forms.formatters.UIFormatterListEdtDlg.java

@Override
public void createUI() {
    super.createUI();

    CellConstraints cc = new CellConstraints();

    // get formatters for field
    List<UIFieldFormatterIFace> fmtrs = new Vector<UIFieldFormatterIFace>(uiFieldFormatterMgrCache
            .getFormatterList(fieldInfo.getTableInfo().getClassObj(), fieldInfo.getName()));
    Collections.sort(fmtrs, new Comparator<UIFieldFormatterIFace>() {
        public int compare(UIFieldFormatterIFace o1, UIFieldFormatterIFace o2) {
            return o1.getName().compareTo(o2.getName());
        }/* www.j  a  v  a 2  s  .  c  om*/
    });

    // table and field titles
    PanelBuilder tblInfoPB = new PanelBuilder(
            new FormLayout("r:p,2px,f:p:g", "p,2px,p,2px,p,10px")/*, new FormDebugPanel()*/);

    String typeStr = fieldInfo.getType();
    typeStr = typeStr.indexOf('.') > -1 ? StringUtils.substringAfterLast(fieldInfo.getType(), ".") : typeStr;

    JLabel tableTitleLbl = createLabel(getResourceString("FFE_TABLE") + ":");
    JLabel tableTitleValueLbl = createLabel(fieldInfo.getTableInfo().getTitle());
    tableTitleValueLbl.setBackground(Color.WHITE);
    tableTitleValueLbl.setOpaque(true);

    JLabel fieldTitleLbl = createLabel(getResourceString("FFE_FIELD") + ":");
    JLabel fieldTitleValueLbl = createLabel(fieldInfo.getTitle());
    fieldTitleValueLbl.setBackground(Color.WHITE);
    fieldTitleValueLbl.setOpaque(true);

    //JLabel fieldTypeLbl = createLabel(getResourceString("FFE_TYPE") + ":");
    //JLabel fieldTypeValueLbl = createLabel(typeStr);
    //fieldTypeValueLbl.setBackground(Color.WHITE);
    //fieldTypeValueLbl.setOpaque(true);

    JLabel fieldLengthLbl = createLabel(getResourceString("FFE_LENGTH") + ":");
    JLabel fieldLengthValueLbl = createLabel(Integer.toString(fieldInfo.getLength()));
    fieldLengthValueLbl.setBackground(Color.WHITE);
    fieldLengthValueLbl.setOpaque(true);

    int y = 1;
    tblInfoPB.add(tableTitleLbl, cc.xy(1, y));
    tblInfoPB.add(tableTitleValueLbl, cc.xy(3, y));
    y += 2;
    tblInfoPB.add(fieldTitleLbl, cc.xy(1, y));
    tblInfoPB.add(fieldTitleValueLbl, cc.xy(3, y));
    y += 2;
    //tblInfoPB.add(fieldTypeLbl,        cc.xy(1, y));
    //tblInfoPB.add(fieldTypeValueLbl,   cc.xy(3, y)); y += 2;
    tblInfoPB.add(fieldLengthLbl, cc.xy(1, y));
    tblInfoPB.add(fieldLengthValueLbl, cc.xy(3, y));
    y += 2;

    DefaultListModel listModel = new DefaultListModel();

    // add available formatters
    for (UIFieldFormatterIFace format : fmtrs) {
        listModel.addElement(format);
    }

    formatList = createList(listModel);
    formatList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    //formatList.setCellRenderer(new FmtListRenderer());
    hookFormatListSelectionListener();
    hookFormatListMouseListener();

    ActionListener deleteListener = new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            deleteFormatter();
        }
    };

    ActionListener editListener = new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            editFormatter((UIFieldFormatter) formatList.getSelectedValue(), false);
        }
    };

    ActionListener addListener = new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            addFormatter();
        }
    };

    ActionListener defListener = new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            setAsDefFormatter();
        }
    };

    dedaPanel = new DefEditDeleteAddPanel(defListener, editListener, deleteListener, addListener, "FFE_DEF",
            "FFE_EDT", "FFE_DEL", "FFE_ADD");
    dedaPanel.getAddBtn().setEnabled(true);

    PanelBuilder pb = new PanelBuilder(new FormLayout("f:max(250px;p):g", "p,4px,p,2px,f:p:g,4px,p"));

    y = 1;
    pb.add(tblInfoPB.getPanel(), cc.xy(1, y));
    y += 2;
    pb.add(createI18NLabel("FFE_AVAILABLE_FORMATS", SwingConstants.LEFT), cc.xy(1, y));
    y += 2;
    pb.add(createScrollPane(formatList), cc.xy(1, y));
    y += 2;
    pb.add(dedaPanel, cc.xy(1, y));
    y += 2;

    pb.setDefaultDialogBorder();

    //pb.getPanel().setBorder(BorderFactory.createEmptyBorder(4, 4, 4, 4));
    contentPanel = pb.getPanel();
    mainPanel.add(contentPanel, BorderLayout.CENTER);

    okBtn.setEnabled(false);

    pack();

}

From source file:com.farouk.projectapp.FirstGUI.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./*from w  ww .j  av a2 s . c  om*/
 */
@SuppressWarnings("unchecked")
// <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
private void initComponents() {

    jTabbedPane1 = new javax.swing.JTabbedPane();
    jPanel5 = new javax.swing.JPanel();
    jPanel6 = new javax.swing.JPanel();
    jScrollPane1 = new javax.swing.JScrollPane();
    DefaultTableModel a = new DefaultTableModel();
    jTable2 = new javax.swing.JTable() {
        public boolean isCellEditable(int d, int c) {
            return false;
        }

        @Override
        public Component prepareRenderer(TableCellRenderer renderer, int row, int col) {
            Component comp = super.prepareRenderer(renderer, row, col);
            String value = getModel().getValueAt(row, 0).toString();
            int a = SQLConnect.ifReported(userID, value);
            if (a == 1) {
                comp.setBackground(Color.red);
            } else {
                comp.setBackground(Color.white);
                comp.setForeground(Color.black);
            }

            return comp;
        }
    };
    jButton5 = new javax.swing.JButton();
    jLabel4 = new javax.swing.JLabel();
    jLabel5 = new javax.swing.JLabel();
    jSeparator2 = new javax.swing.JSeparator();
    jButton10 = new javax.swing.JButton();
    jLabel10 = new javax.swing.JLabel();
    jPanel15 = new javax.swing.JPanel();
    jPanel16 = new javax.swing.JPanel();
    jTextField6 = new javax.swing.JTextField();
    jTextField7 = new javax.swing.JTextField();
    jLabel14 = new javax.swing.JLabel();
    jButton13 = new javax.swing.JButton();
    jButton14 = new javax.swing.JButton();
    jButton7 = new javax.swing.JButton();
    jButton3 = new javax.swing.JButton();
    jPanel10 = new javax.swing.JPanel();
    jScrollPane2 = new javax.swing.JScrollPane();
    jEditorPane1 = new javax.swing.JEditorPane();
    jButton15 = new javax.swing.JButton();
    jButton19 = new javax.swing.JButton();
    jTextField4 = new javax.swing.JTextField();
    jPanel1 = new javax.swing.JPanel();
    jPanel2 = new javax.swing.JPanel();
    jTextField1 = new javax.swing.JTextField();
    jPanel3 = new javax.swing.JPanel();
    jButton1 = new javax.swing.JButton();
    jButton2 = new javax.swing.JButton();
    jLabel1 = new javax.swing.JLabel();
    jPanel4 = new javax.swing.JPanel();
    jScrollPane5 = new javax.swing.JScrollPane();
    jTable3 = new javax.swing.JTable() {
        public boolean isCellEditable(int d, int c) {
            return false;
        }
    };
    jButton6 = new javax.swing.JButton();
    jLabel2 = new javax.swing.JLabel();
    jSeparator1 = new javax.swing.JSeparator();
    jPanel8 = new javax.swing.JPanel();
    jScrollPane3 = new javax.swing.JScrollPane();
    DefaultListModel modelCompaniesName = new DefaultListModel();
    try {
        for (String p : SQLConnect.getAllCompaniesNames()) {
            modelCompaniesName.addElement(p);
        }
    } catch (Exception e) {
        e.printStackTrace();
    }
    jList1 = new javax.swing.JList();
    jLabel3 = new javax.swing.JLabel();
    jButton4 = new javax.swing.JButton();
    jButton9 = new javax.swing.JButton();
    jLabel9 = new javax.swing.JLabel();
    jLabel8 = new javax.swing.JLabel();
    jButton8 = new javax.swing.JButton();
    jPanel7 = new javax.swing.JPanel();
    jTextField2 = new javax.swing.JTextField();
    jPasswordField1 = new javax.swing.JPasswordField();
    jButton11 = new javax.swing.JButton();
    jButton12 = new javax.swing.JButton();
    jPanel9 = new javax.swing.JPanel();
    jLabel11 = new javax.swing.JLabel();
    jButton17 = new javax.swing.JButton();
    jLabel12 = new javax.swing.JLabel();
    jButton18 = new javax.swing.JButton();
    jTextField3 = new javax.swing.JTextField();
    jLabel15 = new javax.swing.JLabel();
    jLabel6 = new javax.swing.JLabel();
    jLabel7 = new javax.swing.JLabel();
    jMenuBar1 = new javax.swing.JMenuBar();
    jMenu1 = new javax.swing.JMenu();
    jMenuItem1 = new javax.swing.JMenuItem();
    jMenu2 = new javax.swing.JMenu();
    jMenuItem2 = new javax.swing.JMenuItem();

    setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);

    jTabbedPane1.setToolTipText("");
    jTabbedPane1.setMinimumSize(new java.awt.Dimension(150, 200));
    jTabbedPane1.setPreferredSize(new java.awt.Dimension(200, 200));

    jScrollPane1.setViewportView(jTable2);
    jTable2.setModel(a);
    try {
        UpdatejTable2();
    } catch (Exception e) {
        e.printStackTrace();
    }
    jTable2.addMouseListener(new java.awt.event.MouseAdapter() {
        public void mouseClicked(java.awt.event.MouseEvent evt) {
            jTable2MouseClicked(evt);
        }
    });
    jTable2.addKeyListener(new java.awt.event.KeyAdapter() {
        public void keyReleased(java.awt.event.KeyEvent evt) {
            jTable2KeyReleased(evt);
        }
    });
    jScrollPane1.setViewportView(jTable2);

    jButton5.setText("Refresh My Portfolio");
    jButton5.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            jButton5ActionPerformed(evt);
        }
    });

    jLabel4.setText("   Last Refreshed : ");

    jButton10.setText("Refresh Company");
    jButton10.setVisible(false);
    jButton10.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            jButton10ActionPerformed(evt);
        }
    });

    jLabel10.setText("Total is : " + String.valueOf(total.doubleValue()) + "");

    jTextField6.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            jTextField6ActionPerformed(evt);
        }
    });
    jTextField6.setVisible(false);

    jTextField7.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            jTextField7ActionPerformed(evt);
        }
    });

    jLabel14.setText("N of Actions");

    javax.swing.GroupLayout jPanel16Layout = new javax.swing.GroupLayout(jPanel16);
    jPanel16.setLayout(jPanel16Layout);
    jPanel16Layout.setHorizontalGroup(jPanel16Layout
            .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel16Layout.createSequentialGroup()
                    .addGroup(jPanel16Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(jPanel16Layout.createSequentialGroup()
                                    .addComponent(jTextField7, javax.swing.GroupLayout.PREFERRED_SIZE, 42,
                                            javax.swing.GroupLayout.PREFERRED_SIZE)
                                    .addGap(34, 34, 34).addComponent(jTextField6,
                                            javax.swing.GroupLayout.PREFERRED_SIZE, 10,
                                            javax.swing.GroupLayout.PREFERRED_SIZE))
                            .addComponent(jLabel14))
                    .addGap(0, 3, Short.MAX_VALUE)));
    jPanel16Layout.setVerticalGroup(jPanel16Layout
            .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel16Layout.createSequentialGroup()
                    .addComponent(jLabel14)
                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED,
                            javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addGroup(jPanel16Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(jTextField6, javax.swing.GroupLayout.PREFERRED_SIZE, 30,
                                    javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(jTextField7, javax.swing.GroupLayout.PREFERRED_SIZE, 30,
                                    javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addGap(13, 13, 13)));

    jButton13.setText("Buy");
    jButton13.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            jButton13ActionPerformed(evt);
        }
    });

    jButton14.setText("Sell");
    jButton14.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            jButton14ActionPerformed(evt);
        }
    });

    javax.swing.GroupLayout jPanel15Layout = new javax.swing.GroupLayout(jPanel15);
    jPanel15.setLayout(jPanel15Layout);
    jPanel15Layout
            .setHorizontalGroup(
                    jPanel15Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(jPanel15Layout.createSequentialGroup().addComponent(jButton13)
                                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED,
                                            javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                                    .addComponent(jButton14).addGap(166, 166, 166))
                            .addGroup(jPanel15Layout.createSequentialGroup()
                                    .addComponent(jPanel16, javax.swing.GroupLayout.PREFERRED_SIZE,
                                            javax.swing.GroupLayout.DEFAULT_SIZE,
                                            javax.swing.GroupLayout.PREFERRED_SIZE)
                                    .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)));
    jPanel15Layout
            .setVerticalGroup(jPanel15Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel15Layout.createSequentialGroup()
                            .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                            .addComponent(jPanel16, javax.swing.GroupLayout.PREFERRED_SIZE, 58,
                                    javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                            .addGroup(jPanel15Layout
                                    .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                    .addComponent(jButton14).addComponent(jButton13))));

    jButton7.setText("Get News !");
    jButton7.setVisible(false);
    jButton7.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            jButton7ActionPerformed(evt);
        }
    });

    jButton3.setText("Report");
    jButton3.setVisible(false);
    jButton3.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            jButton3ActionPerformed(evt);
        }
    });

    jPanel10.setVisible(false);

    jScrollPane2.setViewportView(jEditorPane1);

    javax.swing.GroupLayout jPanel10Layout = new javax.swing.GroupLayout(jPanel10);
    jPanel10.setLayout(jPanel10Layout);
    jPanel10Layout.setHorizontalGroup(
            jPanel10Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING).addGroup(
                    jPanel10Layout.createSequentialGroup().addGap(39, 39, 39).addComponent(jScrollPane2,
                            javax.swing.GroupLayout.DEFAULT_SIZE, 423, Short.MAX_VALUE)));
    jPanel10Layout.setVerticalGroup(jPanel10Layout
            .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING).addGroup(jPanel10Layout
                    .createSequentialGroup().addContainerGap().addComponent(jScrollPane2).addContainerGap()));

    jButton15.setText("Automate");
    jButton15.setVisible(false);
    jButton15.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            jButton15ActionPerformed(evt);
        }
    });

    jButton19.setText("Alert");
    jButton19.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            jButton19ActionPerformed(evt);
        }
    });

    jTextField4.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            jTextField4ActionPerformed(evt);
        }
    });

    javax.swing.GroupLayout jPanel6Layout = new javax.swing.GroupLayout(jPanel6);
    jPanel6.setLayout(jPanel6Layout);
    jPanel6Layout.setHorizontalGroup(jPanel6Layout
            .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel6Layout.createSequentialGroup().addContainerGap().addGroup(jPanel6Layout
                    .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING).addComponent(jScrollPane1)
                    .addGroup(jPanel6Layout.createSequentialGroup().addGroup(jPanel6Layout
                            .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(jPanel15, javax.swing.GroupLayout.PREFERRED_SIZE, 131,
                                    javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addGroup(jPanel6Layout.createSequentialGroup().addGroup(jPanel6Layout
                                    .createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
                                    .addComponent(jButton19, javax.swing.GroupLayout.Alignment.LEADING,
                                            javax.swing.GroupLayout.DEFAULT_SIZE,
                                            javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                                    .addComponent(jButton15, javax.swing.GroupLayout.DEFAULT_SIZE,
                                            javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                                    .addComponent(jButton7, javax.swing.GroupLayout.DEFAULT_SIZE,
                                            javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                    .addGroup(jPanel6Layout
                                            .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                            .addComponent(jButton3).addComponent(jTextField4,
                                                    javax.swing.GroupLayout.PREFERRED_SIZE, 68,
                                                    javax.swing.GroupLayout.PREFERRED_SIZE))))
                            .addGroup(jPanel6Layout
                                    .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                    .addGroup(jPanel6Layout.createSequentialGroup()
                                            .addPreferredGap(
                                                    javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                                            .addComponent(jPanel10, javax.swing.GroupLayout.PREFERRED_SIZE,
                                                    javax.swing.GroupLayout.DEFAULT_SIZE,
                                                    javax.swing.GroupLayout.PREFERRED_SIZE)
                                            .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED,
                                                    javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                                            .addGroup(jPanel6Layout
                                                    .createParallelGroup(
                                                            javax.swing.GroupLayout.Alignment.LEADING)
                                                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING,
                                                            jPanel6Layout.createSequentialGroup()
                                                                    .addGroup(jPanel6Layout.createParallelGroup(
                                                                            javax.swing.GroupLayout.Alignment.TRAILING)
                                                                            .addComponent(jLabel10)
                                                                            .addComponent(jButton10))
                                                                    .addPreferredGap(
                                                                            javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                                                                    .addGroup(jPanel6Layout.createParallelGroup(
                                                                            javax.swing.GroupLayout.Alignment.LEADING)
                                                                            .addComponent(jButton5)
                                                                            .addComponent(jLabel4)))
                                                    .addComponent(jLabel5,
                                                            javax.swing.GroupLayout.Alignment.TRAILING,
                                                            javax.swing.GroupLayout.PREFERRED_SIZE, 157,
                                                            javax.swing.GroupLayout.PREFERRED_SIZE)))
                                    .addGroup(jPanel6Layout.createSequentialGroup().addGap(70, 70, 70)
                                            .addComponent(jSeparator2, javax.swing.GroupLayout.PREFERRED_SIZE,
                                                    419, javax.swing.GroupLayout.PREFERRED_SIZE)
                                            .addGap(0, 0, Short.MAX_VALUE)))))
                    .addContainerGap()));

    jPanel6Layout.linkSize(javax.swing.SwingConstants.HORIZONTAL,
            new java.awt.Component[] { jButton3, jTextField4 });

    jPanel6Layout.setVerticalGroup(jPanel6Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel6Layout.createSequentialGroup().addContainerGap()
                    .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 249,
                            javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                    .addGroup(jPanel6Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(jPanel6Layout.createSequentialGroup().addComponent(jButton7)
                                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                    .addGroup(jPanel6Layout
                                            .createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                                            .addComponent(jButton15).addComponent(jButton3))
                                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                    .addGroup(jPanel6Layout
                                            .createParallelGroup(
                                                    javax.swing.GroupLayout.Alignment.LEADING, false)
                                            .addComponent(jButton19)
                                            .addGroup(jPanel6Layout.createSequentialGroup().addGap(1, 1, 1)
                                                    .addComponent(jTextField4)))
                                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED,
                                            javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                                    .addComponent(jPanel15, javax.swing.GroupLayout.PREFERRED_SIZE,
                                            javax.swing.GroupLayout.DEFAULT_SIZE,
                                            javax.swing.GroupLayout.PREFERRED_SIZE)
                                    .addGap(9, 9, 9))
                            .addGroup(jPanel6Layout.createSequentialGroup()
                                    .addComponent(jSeparator2, javax.swing.GroupLayout.PREFERRED_SIZE, 10,
                                            javax.swing.GroupLayout.PREFERRED_SIZE)
                                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                    .addGroup(jPanel6Layout
                                            .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                            .addComponent(jPanel10, javax.swing.GroupLayout.DEFAULT_SIZE,
                                                    javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                                            .addGroup(jPanel6Layout.createSequentialGroup()
                                                    .addGroup(jPanel6Layout
                                                            .createParallelGroup(
                                                                    javax.swing.GroupLayout.Alignment.BASELINE)
                                                            .addComponent(jButton5).addComponent(jButton10))
                                                    .addPreferredGap(
                                                            javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                                    .addGroup(jPanel6Layout
                                                            .createParallelGroup(
                                                                    javax.swing.GroupLayout.Alignment.BASELINE)
                                                            .addComponent(jLabel4).addComponent(jLabel10))
                                                    .addPreferredGap(
                                                            javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                                    .addComponent(jLabel5,
                                                            javax.swing.GroupLayout.PREFERRED_SIZE, 24,
                                                            javax.swing.GroupLayout.PREFERRED_SIZE)
                                                    .addGap(0, 0, Short.MAX_VALUE)))
                                    .addContainerGap()))));

    javax.swing.GroupLayout jPanel5Layout = new javax.swing.GroupLayout(jPanel5);
    jPanel5.setLayout(jPanel5Layout);
    jPanel5Layout.setHorizontalGroup(jPanel5Layout
            .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel5Layout.createSequentialGroup().addContainerGap().addComponent(jPanel6,
                    javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addContainerGap()));
    jPanel5Layout.setVerticalGroup(jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel5Layout.createSequentialGroup().addContainerGap().addComponent(jPanel6,
                    javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addContainerGap()));

    jTabbedPane1.addTab("    My Portfolio    ", jPanel5);

    jTextField1.setCursor(new java.awt.Cursor(java.awt.Cursor.DEFAULT_CURSOR));
    jTextField1.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            jTextField1ActionPerformed(evt);
        }
    });

    jButton1.setText("Search");
    jButton1.setAlignmentY(0.3F);
    jButton1.setAutoscrolls(true);
    jButton1.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            jButton1ActionPerformed(evt);
        }
    });

    jButton2.setText("Clear");
    jButton2.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            jButton2ActionPerformed(evt);
        }
    });

    javax.swing.GroupLayout jPanel3Layout = new javax.swing.GroupLayout(jPanel3);
    jPanel3.setLayout(jPanel3Layout);
    jPanel3Layout.setHorizontalGroup(jPanel3Layout
            .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel3Layout.createSequentialGroup().addGap(2, 2, 2)
                    .addComponent(jButton1, javax.swing.GroupLayout.PREFERRED_SIZE, 82,
                            javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addGap(18, 18, 18).addComponent(jButton2)
                    .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)));
    jPanel3Layout.setVerticalGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel3Layout.createSequentialGroup()
                    .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jButton1, javax.swing.GroupLayout.DEFAULT_SIZE,
                                    javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                            .addComponent(jButton2))
                    .addContainerGap()));

    javax.swing.GroupLayout jPanel2Layout = new javax.swing.GroupLayout(jPanel2);
    jPanel2.setLayout(jPanel2Layout);
    jPanel2Layout.setHorizontalGroup(jPanel2Layout
            .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel2Layout.createSequentialGroup().addContainerGap()
                    .addComponent(jTextField1, javax.swing.GroupLayout.PREFERRED_SIZE, 145,
                            javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 24, Short.MAX_VALUE)
                    .addComponent(jPanel3, javax.swing.GroupLayout.PREFERRED_SIZE,
                            javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addGap(51, 51, 51)));
    jPanel2Layout.setVerticalGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel2Layout.createSequentialGroup()
                    .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(jTextField1).addComponent(jPanel3,
                                    javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE,
                                    Short.MAX_VALUE))
                    .addContainerGap()));

    jLabel1.setText("Name of Company to look for : ");

    jTable3.setModel(a);
    jScrollPane5.setViewportView(jTable3);
    jScrollPane5.setVisible(false);

    jButton6.setText("Refresh Company");
    jButton6.setVisible(false);
    jButton6.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            jButton6ActionPerformed(evt);
        }
    });

    jLabel2.setText(null);
    jLabel2.setVisible(false);

    javax.swing.GroupLayout jPanel4Layout = new javax.swing.GroupLayout(jPanel4);
    jPanel4.setLayout(jPanel4Layout);
    jPanel4Layout.setHorizontalGroup(jPanel4Layout
            .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel4Layout.createSequentialGroup().addContainerGap().addGroup(jPanel4Layout
                    .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING).addComponent(jScrollPane5)
                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING,
                            jPanel4Layout.createSequentialGroup().addGap(0, 0, Short.MAX_VALUE)
                                    .addGroup(jPanel4Layout
                                            .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                            .addComponent(jLabel2).addComponent(jButton6))))
                    .addContainerGap()));
    jPanel4Layout.setVerticalGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING,
                    jPanel4Layout.createSequentialGroup().addGap(5, 5, 5).addComponent(jButton6)
                            .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                            .addComponent(jLabel2)
                            .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED,
                                    javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                            .addComponent(jScrollPane5, javax.swing.GroupLayout.PREFERRED_SIZE, 39,
                                    javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addGap(19, 19, 19)));

    javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
    jPanel1.setLayout(jPanel1Layout);
    jPanel1Layout.setHorizontalGroup(jPanel1Layout
            .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup().addGroup(jPanel1Layout
                    .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel1Layout.createSequentialGroup().addContainerGap().addComponent(jPanel4,
                            javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE,
                            Short.MAX_VALUE))
                    .addGroup(jPanel1Layout.createSequentialGroup().addGap(82, 82, 82)
                            .addGroup(jPanel1Layout
                                    .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                    .addComponent(jPanel2, javax.swing.GroupLayout.PREFERRED_SIZE,
                                            javax.swing.GroupLayout.DEFAULT_SIZE,
                                            javax.swing.GroupLayout.PREFERRED_SIZE)
                                    .addComponent(jLabel1).addComponent(jSeparator1,
                                            javax.swing.GroupLayout.PREFERRED_SIZE, 598,
                                            javax.swing.GroupLayout.PREFERRED_SIZE))
                            .addGap(0, 236, Short.MAX_VALUE)))
                    .addContainerGap()));
    jPanel1Layout.setVerticalGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup().addGap(36, 36, 36).addComponent(jLabel1)
                    .addGap(18, 18, 18)
                    .addComponent(jPanel2, javax.swing.GroupLayout.PREFERRED_SIZE,
                            javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addGap(18, 18, 18)
                    .addComponent(jSeparator1, javax.swing.GroupLayout.PREFERRED_SIZE, 16,
                            javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addGap(18, 18, 18)
                    .addComponent(jPanel4, javax.swing.GroupLayout.PREFERRED_SIZE,
                            javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addContainerGap(210, Short.MAX_VALUE)));

    jTabbedPane1.addTab("    Search    ", jPanel1);

    jList1.setModel(modelCompaniesName);
    jList1.addMouseListener(new java.awt.event.MouseAdapter() {
        public void mouseClicked(java.awt.event.MouseEvent evt) {
            jList1MouseClicked(evt);
        }
    });
    jScrollPane3.setViewportView(jList1);

    jLabel3.setText("  List of Companies (NASDAQ)");

    javax.swing.GroupLayout jPanel8Layout = new javax.swing.GroupLayout(jPanel8);
    jPanel8.setLayout(jPanel8Layout);
    jPanel8Layout
            .setHorizontalGroup(jPanel8Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jScrollPane3, javax.swing.GroupLayout.PREFERRED_SIZE, 0, Short.MAX_VALUE)
                    .addGroup(jPanel8Layout.createSequentialGroup().addComponent(jLabel3).addGap(0, 50,
                            Short.MAX_VALUE)));
    jPanel8Layout.setVerticalGroup(jPanel8Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING,
                    jPanel8Layout.createSequentialGroup().addGap(5, 5, 5).addComponent(jLabel3)
                            .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED).addComponent(
                                    jScrollPane3, javax.swing.GroupLayout.DEFAULT_SIZE, 613, Short.MAX_VALUE)));

    jButton4.setText("Refresh All");
    jButton4.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            jButton4ActionPerformed(evt);
        }
    });

    jButton9.setVisible(false);
    jButton9.setText("Quit");
    jButton9.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            jButton9ActionPerformed(evt);
        }
    });

    jLabel9.setText("All prices are in .");

    jLabel8.setVisible(false);

    jButton8.setText("Stop");
    jButton8.setVisible(false);

    jTextField2.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            jTextField2ActionPerformed(evt);
        }
    });

    jPasswordField1.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            jPasswordField1ActionPerformed(evt);
        }
    });

    jButton11.setText("Log in");
    jButton11.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            jButton11ActionPerformed(evt);
        }
    });

    jButton12.setText("Create account");
    jButton12.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            jButton12ActionPerformed(evt);
        }
    });

    javax.swing.GroupLayout jPanel7Layout = new javax.swing.GroupLayout(jPanel7);
    jPanel7.setLayout(jPanel7Layout);
    jPanel7Layout
            .setHorizontalGroup(jPanel7Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel7Layout.createSequentialGroup()
                            .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                            .addComponent(jTextField2, javax.swing.GroupLayout.PREFERRED_SIZE, 150,
                                    javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                            .addComponent(jPasswordField1, javax.swing.GroupLayout.PREFERRED_SIZE, 138,
                                    javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                            .addGroup(jPanel7Layout
                                    .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                                    .addComponent(jButton11, javax.swing.GroupLayout.PREFERRED_SIZE, 97,
                                            javax.swing.GroupLayout.PREFERRED_SIZE)
                                    .addComponent(jButton12, javax.swing.GroupLayout.DEFAULT_SIZE,
                                            javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                            .addContainerGap()));

    jPanel7Layout.linkSize(javax.swing.SwingConstants.HORIZONTAL,
            new java.awt.Component[] { jPasswordField1, jTextField2 });

    jPanel7Layout.linkSize(javax.swing.SwingConstants.HORIZONTAL,
            new java.awt.Component[] { jButton11, jButton12 });

    jPanel7Layout.setVerticalGroup(jPanel7Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel7Layout.createSequentialGroup().addContainerGap()
                    .addGroup(jPanel7Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jTextField2, javax.swing.GroupLayout.PREFERRED_SIZE, 29,
                                    javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(jPasswordField1, javax.swing.GroupLayout.PREFERRED_SIZE, 30,
                                    javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(jButton11))
                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED,
                            javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(jButton12).addContainerGap()));

    jPanel7Layout.linkSize(javax.swing.SwingConstants.VERTICAL,
            new java.awt.Component[] { jPasswordField1, jTextField2 });

    jLabel11.setFont(new java.awt.Font("Tahoma", 0, 17)); // NOI18N

    jButton17.setText("Log out");
    jButton17.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            jButton17ActionPerformed(evt);
        }
    });

    jButton18.setText("Change Limit");
    jButton18.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            jButton18ActionPerformed(evt);
        }
    });

    jTextField3.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            jTextField3ActionPerformed(evt);
        }
    });

    jPanel9.setVisible(false);

    javax.swing.GroupLayout jPanel9Layout = new javax.swing.GroupLayout(jPanel9);
    jPanel9.setLayout(jPanel9Layout);
    jPanel9Layout.setHorizontalGroup(jPanel9Layout
            .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel9Layout.createSequentialGroup()
                    .addContainerGap(18, Short.MAX_VALUE)
                    .addGroup(jPanel9Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                            .addGroup(jPanel9Layout.createSequentialGroup()
                                    .addComponent(jTextField3, javax.swing.GroupLayout.PREFERRED_SIZE, 39,
                                            javax.swing.GroupLayout.PREFERRED_SIZE)
                                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                                    .addComponent(jButton18))
                            .addGroup(jPanel9Layout.createSequentialGroup()
                                    .addGroup(jPanel9Layout
                                            .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING,
                                                    jPanel9Layout.createSequentialGroup().addComponent(jLabel11)
                                                            .addGap(30, 30, 30))
                                            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING,
                                                    jPanel9Layout.createSequentialGroup().addComponent(jLabel12)
                                                            .addGap(18, 18, 18)))
                                    .addComponent(jButton17)))
                    .addGap(36, 36, 36)));
    jPanel9Layout.setVerticalGroup(jPanel9Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel9Layout.createSequentialGroup().addContainerGap()
                    .addGroup(jPanel9Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(jPanel9Layout.createSequentialGroup().addComponent(jLabel11)
                                    .addGap(18, 18, 18).addComponent(jLabel12))
                            .addComponent(jButton17))
                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED,
                            javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addGroup(
                            jPanel9Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                                    .addComponent(jButton18).addGroup(jPanel9Layout.createSequentialGroup()
                                            .addGap(1, 1, 1).addComponent(jTextField3)))
                    .addContainerGap()));

    jLabel6.setVisible(false);

    jMenu1.setText("File");

    jMenuItem1.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_Q,
            java.awt.event.InputEvent.CTRL_MASK));
    jMenuItem1.setText("Quit");
    jMenuItem1.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            jMenuItem1ActionPerformed(evt);
        }
    });
    jMenu1.add(jMenuItem1);

    jMenuBar1.add(jMenu1);

    jMenu2.setText("Help");

    jMenuItem2.setText("About");
    jMenuItem2.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            jMenuItem2ActionPerformed(evt);
        }
    });
    jMenu2.add(jMenuItem2);

    jMenuBar1.add(jMenu2);

    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().addGroup(layout
                    .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jPanel8, javax.swing.GroupLayout.PREFERRED_SIZE,
                            javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addGroup(layout.createSequentialGroup().addComponent(jButton4)
                            .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                            .addComponent(jButton8)))
                    .addGap(18, 18, 18)
                    .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(layout.createSequentialGroup().addGroup(layout
                                    .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                    .addGroup(layout.createSequentialGroup().addGap(0, 0, Short.MAX_VALUE)
                                            .addComponent(jLabel6)
                                            .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                            .addComponent(jLabel8).addGap(85, 85, 85).addComponent(jLabel7)
                                            .addGap(77, 77, 77).addComponent(jButton9))
                                    .addComponent(jTabbedPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 931,
                                            Short.MAX_VALUE)
                                    .addGroup(layout.createSequentialGroup().addComponent(jLabel9)
                                            .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED,
                                                    javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                                            .addComponent(jPanel9, javax.swing.GroupLayout.PREFERRED_SIZE,
                                                    javax.swing.GroupLayout.DEFAULT_SIZE,
                                                    javax.swing.GroupLayout.PREFERRED_SIZE)
                                            .addGap(53, 53, 53).addComponent(jPanel7,
                                                    javax.swing.GroupLayout.PREFERRED_SIZE,
                                                    javax.swing.GroupLayout.DEFAULT_SIZE,
                                                    javax.swing.GroupLayout.PREFERRED_SIZE)))
                                    .addGap(18, 18, 18))
                            .addGroup(layout.createSequentialGroup().addComponent(jLabel15)
                                    .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)))));
    layout.setVerticalGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING,
                    layout.createSequentialGroup()
                            .addComponent(jPanel8, javax.swing.GroupLayout.DEFAULT_SIZE,
                                    javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                            .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                            .addGroup(layout
                                    .createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                                    .addComponent(jButton9).addComponent(jButton4).addComponent(jLabel8)
                                    .addComponent(jButton8).addComponent(jLabel6).addComponent(jLabel7))
                            .addContainerGap())
            .addGroup(layout.createSequentialGroup().addGap(16, 16, 16).addGroup(layout
                    .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jPanel7, javax.swing.GroupLayout.PREFERRED_SIZE,
                            javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addGroup(layout.createSequentialGroup()
                            .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                    .addGroup(layout.createSequentialGroup().addGap(68, 68, 68)
                                            .addComponent(jLabel9))
                                    .addComponent(jPanel9, javax.swing.GroupLayout.PREFERRED_SIZE,
                                            javax.swing.GroupLayout.DEFAULT_SIZE,
                                            javax.swing.GroupLayout.PREFERRED_SIZE))
                            .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                            .addComponent(jTabbedPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 515,
                                    javax.swing.GroupLayout.PREFERRED_SIZE)))
                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED).addComponent(jLabel15)
                    .addGap(0, 0, Short.MAX_VALUE)));

    jTabbedPane1.getAccessibleContext().setAccessibleName("");

    pack();
}

From source file:gtu._work.ui.PropertyEditUI.java

private void initGUI() {
    try {/*www.j ava  2  s.  c om*/
        setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
        BorderLayout thisLayout = new BorderLayout();
        this.setTitle("PropertyEditUI");
        getContentPane().setLayout(thisLayout);
        {
            jMenuBar1 = new JMenuBar();
            setJMenuBar(jMenuBar1);
            {
                jMenu1 = new JMenu();
                jMenuBar1.add(jMenu1);
                jMenu1.setText("File");
                {
                    jMenuItem1 = new JMenuItem();
                    jMenu1.add(jMenuItem1);
                    jMenuItem1.setText("open directory");
                    jMenuItem1.addActionListener(new ActionListener() {
                        public void actionPerformed(ActionEvent evt) {
                            File file = JCommonUtil._jFileChooser_selectDirectoryOnly();
                            loadCurrentFile(file);
                        }
                    });
                }
                {
                    openDirectoryAndChildren = new JMenuItem();
                    jMenu1.add(openDirectoryAndChildren);
                    openDirectoryAndChildren.setText("open directory and children");
                    openDirectoryAndChildren.addActionListener(new ActionListener() {
                        public void actionPerformed(ActionEvent evt) {
                            System.out.println("openDirectoryAndChildren.actionPerformed, event=" + evt);
                            File file = JCommonUtil._jFileChooser_selectDirectoryOnly();
                            if (file == null) {
                                // file =
                                // PropertiesUtil.getJarCurrentPath(getClass());//XXX
                                file = new File("D:\\my_tool\\english");
                                JCommonUtil._jOptionPane_showMessageDialog_info("load C:\\L-CONFIG !");
                            }
                            DefaultListModel model = new DefaultListModel();
                            List<File> list = new ArrayList<File>();
                            FileUtil.searchFileMatchs(file, ".*\\.properties", list);
                            for (File f : list) {
                                File_ ff = new File_();
                                ff.file = f;
                                model.addElement(ff);
                            }
                            backupFileList = list;
                            fileList.setModel(model);
                        }
                    });
                }
                {
                    jMenuItem2 = new JMenuItem();
                    jMenu1.add(jMenuItem2);
                    jMenuItem2.setText("save");
                    jMenuItem2.addActionListener(new ActionListener() {
                        public void actionPerformed(ActionEvent evt) {
                            System.out.println("jMenu3.actionPerformed, event=" + evt);
                            if (currentFile == null) {
                                return;
                            }
                            if (JCommonUtil._JOptionPane_showConfirmDialog_yesNoOption(
                                    "save to " + currentFile.getName(), "SAVE")) {
                                try {
                                    Properties prop = new Properties();
                                    // try {
                                    // prop.load(new
                                    // FileInputStream(currentFile));
                                    // } catch (Exception e) {
                                    // e.printStackTrace();
                                    // JCommonUtil.handleException(e);
                                    // return;
                                    // }
                                    loadModelToProperties(prop);
                                    prop.store(new FileOutputStream(currentFile), getTitle());
                                } catch (Exception e) {
                                    e.printStackTrace();
                                    JCommonUtil.handleException(e);
                                }
                            }
                        }
                    });
                }
                {
                    jMenuItem3 = new JMenuItem();
                    jMenu1.add(jMenuItem3);
                    jMenuItem3.setText("save to target");
                    jMenuItem3.addActionListener(new ActionListener() {
                        public void actionPerformed(ActionEvent evt) {
                            File file = JFileChooserUtil.newInstance().selectFileOnly().showSaveDialog()
                                    .getApproveSelectedFile();
                            if (file == null) {
                                JCommonUtil._jOptionPane_showMessageDialog_error("file name is not correct!");
                                return;
                            }
                            if (!file.getName().contains(".properties")) {
                                file = new File(file.getParent(), file.getName() + ".properties");
                            }
                            try {
                                Properties prop = new Properties();
                                // try {
                                // prop.load(new
                                // FileInputStream(currentFile));
                                // } catch (Exception e) {
                                // e.printStackTrace();
                                // JCommonUtil.handleException(e);
                                // return;
                                // }
                                loadModelToProperties(prop);
                                prop.store(new FileOutputStream(file), getTitle());
                            } catch (Exception e) {
                                e.printStackTrace();
                                JCommonUtil.handleException(e);
                            }
                        }
                    });
                }
                {
                    jMenuItem4 = new JMenuItem();
                    jMenu1.add(jMenuItem4);
                    jMenuItem4.setText("save file(sorted)");
                    jMenuItem4.addActionListener(new ActionListener() {
                        public void actionPerformed(ActionEvent evt) {
                            if (currentFile == null) {
                                return;
                            }
                            try {
                                BufferedReader reader = new BufferedReader(
                                        new InputStreamReader(new FileInputStream(currentFile)));
                                List<String> sortList = new ArrayList<String>();
                                for (String line = null; (line = reader.readLine()) != null;) {
                                    sortList.add(line);
                                }
                                reader.close();
                                Collections.sort(sortList);
                                StringBuilder sb = new StringBuilder();
                                for (String line : sortList) {
                                    sb.append(line + "\n");
                                }
                                FileUtil.saveToFile(currentFile, sb.toString(), "UTF8");
                            } catch (FileNotFoundException e) {
                                e.printStackTrace();
                            } catch (IOException e) {
                                e.printStackTrace();
                            }
                        }
                    });
                }
                {
                    jMenuItem5 = new JMenuItem();
                    jMenu1.add(jMenuItem5);
                    jMenuItem5.setText("");
                    jMenuItem5.addActionListener(new ActionListener() {
                        private void setMeaning(String meaning, int rowPos) {
                            propTable.getRowSorter().getModel().setValueAt(meaning, rowPos, 2);
                        }

                        private void setMeaningEn1(String english, int rowPos, List<String> errSb) {
                            EnglishTester_Diectory eng = new EnglishTester_Diectory();
                            try {
                                WordInfo wordInfo = eng.parseToWordInfo(english);
                                String meaning = getChs2Big5(wordInfo.getMeaning());
                                if (hasChinese(meaning)) {
                                    setMeaning(meaning, rowPos);
                                } else {
                                    setMeaningEn2(english, rowPos, errSb);
                                }
                            } catch (Exception e) {
                                errSb.add(english);
                                e.printStackTrace();
                            }
                        }

                        private void setMeaningEn2(String english, int rowPos, List<String> errSb) {
                            EnglishTester_Diectory2 eng2 = new EnglishTester_Diectory2();
                            try {
                                WordInfo2 wordInfo = eng2.parseToWordInfo(english);
                                String meaning = getChs2Big5(StringUtils.join(wordInfo.getMeaningList(), ";"));
                                setMeaning(meaning, rowPos);
                            } catch (Exception e) {
                                errSb.add(english);
                                e.printStackTrace();
                            }
                        }

                        private boolean hasChinese(String val) {
                            return new StringUtil_().getChineseWord(val, true).length() > 0;
                        }

                        private Properties loadFromMemoryBank() {
                            try {
                                Properties prop = new Properties();
                                File f1 = new File(
                                        "D:/gtu001_dropbox/Dropbox/Apps/gtu001_test/etc_config/EnglishSearchUI_MemoryBank.properties");
                                File f2 = new File(
                                        "e:/gtu001_dropbox/Dropbox/Apps/gtu001_test/etc_config/EnglishSearchUI_MemoryBank.properties");
                                for (File f : new File[] { f1, f2 }) {
                                    if (f.exists()) {
                                        HermannEbbinghaus_Memory memory = new HermannEbbinghaus_Memory();
                                        memory.init(f);
                                        List<MemData> memLst = memory.getAllMemData(true);
                                        for (MemData d : memLst) {
                                            prop.setProperty(d.getKey(), getChs2Big5(d.getRemark()));
                                        }
                                        break;
                                    }
                                }
                                return prop;
                            } catch (Exception ex) {
                                throw new RuntimeException(ex);
                            }
                        }

                        public void actionPerformed(ActionEvent evt) {
                            if (currentFile == null) {
                                return;
                            }

                            // Properties memoryProp = loadFromMemoryBank();
                            Properties memoryProp = new Properties();

                            List<String> errSb = new ArrayList<String>();
                            for (int row = 0; row < propTable.getModel().getRowCount(); row++) {
                                int rowPos = propTable.getRowSorter().convertRowIndexToModel(row);
                                String english = StringUtils.trimToEmpty(
                                        (String) propTable.getRowSorter().getModel().getValueAt(rowPos, 1))
                                        .toLowerCase();
                                String desc = (String) propTable.getRowSorter().getModel().getValueAt(rowPos,
                                        2);

                                if (memoryProp.containsKey(english)
                                        && StringUtils.isNotBlank(memoryProp.getProperty(english))) {
                                    setMeaning(memoryProp.getProperty(english), rowPos);
                                } else {
                                    if (StringUtils.isBlank(desc) || !hasChinese(desc)) {
                                        if (!english.contains(" ")) {
                                            setMeaningEn1(english, rowPos, errSb);
                                        } else {
                                            setMeaningEn2(english, rowPos, errSb);
                                        }
                                    }
                                }

                                if (StringUtils.trimToEmpty(desc).contains("?")) {
                                    setMeaning("", rowPos);
                                }
                            }
                            if (!errSb.isEmpty()) {
                                JCommonUtil._jOptionPane_showMessageDialog_error(":\n" + errSb);
                            }
                        }
                    });
                }

                {
                    JMenuItem jMenuItem6 = new JMenuItem();
                    jMenu1.add(jMenuItem6);
                    jMenuItem6.setText("");
                    jMenuItem6.addActionListener(new ActionListener() {
                        private void setMeaning(String meaning, int rowPos) {
                            propTable.getRowSorter().getModel().setValueAt(meaning, rowPos, 2);
                        }

                        public void actionPerformed(ActionEvent evt) {
                            for (int row = 0; row < propTable.getModel().getRowCount(); row++) {
                                int rowPos = propTable.getRowSorter().convertRowIndexToModel(row);
                                String english = StringUtils.trimToEmpty(
                                        (String) propTable.getRowSorter().getModel().getValueAt(rowPos, 1))
                                        .toLowerCase();
                                String desc = (String) propTable.getRowSorter().getModel().getValueAt(rowPos,
                                        2);

                                if (StringUtils.trimToEmpty(desc).contains("?")) {
                                    setMeaning("", rowPos);
                                }
                            }
                        }
                    });
                }
            }
        }
        {
            jTabbedPane1 = new JTabbedPane();
            getContentPane().add(jTabbedPane1, BorderLayout.CENTER);
            {
                jPanel2 = new JPanel();
                BorderLayout jPanel2Layout = new BorderLayout();
                jPanel2.setLayout(jPanel2Layout);
                jTabbedPane1.addTab("editor", null, jPanel2, null);
                {
                    jScrollPane1 = new JScrollPane();
                    jPanel2.add(jScrollPane1, BorderLayout.CENTER);
                    jScrollPane1.setPreferredSize(new java.awt.Dimension(550, 314));
                    {
                        TableModel propTableModel = new DefaultTableModel(
                                new String[][] { { "", "", "" }, { "", "", "" } },
                                new String[] { "index", "Key", "value" });
                        propTable = new JTable();
                        JTableUtil.defaultSetting_AutoResize(propTable);
                        jScrollPane1.setViewportView(propTable);
                        propTable.setModel(propTableModel);
                        propTable.addMouseListener(new MouseAdapter() {
                            public void mouseClicked(MouseEvent evt) {
                                JTableUtil xxxxxx = JTableUtil.newInstance(propTable);
                                int[] rows = xxxxxx.getSelectedRows();
                                for (int ii : rows) {
                                    System.out.println(xxxxxx.getModel().getValueAt(ii, 1));
                                }
                                JPopupMenuUtil.newInstance(propTable).applyEvent(evt)
                                        .addJMenuItem(JTableUtil.newInstance(propTable).getDefaultJMenuItems())
                                        .show();
                            }
                        });
                    }
                }
                {
                    queryText = new JTextField();
                    jPanel2.add(queryText, BorderLayout.NORTH);
                    queryText.getDocument()
                            .addDocumentListener(JCommonUtil.getDocumentListener(new HandleDocumentEvent() {

                                @Override
                                public void process(DocumentEvent event) {
                                    if (currentFile == null) {
                                        return;
                                    }
                                    Properties prop = new Properties();
                                    try {
                                        prop.load(new FileInputStream(currentFile));
                                    } catch (Exception e) {
                                        e.printStackTrace();
                                        JCommonUtil.handleException(e);
                                        return;
                                    }
                                    loadPropertiesToModel(prop);
                                    String text = JCommonUtil.getDocumentText(event);
                                    Pattern pattern = null;
                                    try {
                                        pattern = Pattern.compile(text);
                                    } catch (Exception ex) {
                                    }

                                    DefaultTableModel model = JTableUtil.newInstance(propTable).getModel();
                                    for (int ii = 0; ii < model.getRowCount(); ii++) {
                                        String key = (String) model.getValueAt(ii, 1);
                                        String value = (String) model.getValueAt(ii, 2);
                                        if (key.contains(text)) {
                                            continue;
                                        }
                                        if (value.contains(text)) {
                                            continue;
                                        }
                                        if (pattern != null) {
                                            if (pattern.matcher(key).find()) {
                                                continue;
                                            }
                                            if (pattern.matcher(value).find()) {
                                                continue;
                                            }
                                        }
                                        model.removeRow(propTable.convertRowIndexToModel(ii));
                                        ii--;
                                    }
                                }
                            }));
                }
            }
            {
                jPanel3 = new JPanel();
                BorderLayout jPanel3Layout = new BorderLayout();
                jPanel3.setLayout(jPanel3Layout);
                jTabbedPane1.addTab("folder", null, jPanel3, null);
                {
                    jScrollPane2 = new JScrollPane();
                    jPanel3.add(jScrollPane2, BorderLayout.CENTER);
                    jScrollPane2.setPreferredSize(new java.awt.Dimension(550, 314));
                    {
                        fileList = new JList();
                        jScrollPane2.setViewportView(fileList);
                        fileList.addKeyListener(new KeyAdapter() {
                            public void keyPressed(KeyEvent evt) {
                                JListUtil.newInstance(fileList).defaultJListKeyPressed(evt);
                            }
                        });
                        fileList.addMouseListener(new MouseAdapter() {
                            public void mouseClicked(MouseEvent evt) {
                                final File_ file = JListUtil.getLeadSelectionObject(fileList);

                                if (evt.getButton() == MouseEvent.BUTTON1) {
                                    Properties prop = new Properties();
                                    currentFile = file.file;
                                    setTitle(currentFile.getName());
                                    try {
                                        prop.load(new FileInputStream(file.file));
                                    } catch (Exception e) {
                                        e.printStackTrace();
                                    }
                                    loadPropertiesToModel(prop);
                                }

                                if (evt.getButton() == MouseEvent.BUTTON1 && evt.getClickCount() == 2) {
                                    try {
                                        Runtime.getRuntime().exec(String.format("cmd /c \"%s\"", file.file));
                                    } catch (IOException e1) {
                                        e1.printStackTrace();
                                    }
                                }

                                final File parent = file.file.getParentFile();
                                JMenuItem openTargetDir = new JMenuItem();
                                openTargetDir.setText("open : " + parent);
                                openTargetDir.addActionListener(new ActionListener() {
                                    @Override
                                    public void actionPerformed(ActionEvent e) {
                                        try {
                                            Desktop.getDesktop().open(parent);
                                        } catch (IOException e1) {
                                            JCommonUtil.handleException(e1);
                                        }
                                    }
                                });

                                JPopupMenuUtil.newInstance(fileList).addJMenuItem(openTargetDir).applyEvent(evt)
                                        .show();
                            }
                        });
                    }
                }
                {
                    fileQueryText = new JTextField();
                    jPanel3.add(fileQueryText, BorderLayout.NORTH);
                    fileQueryText.getDocument()
                            .addDocumentListener(JCommonUtil.getDocumentListener(new HandleDocumentEvent() {
                                @Override
                                public void process(DocumentEvent event) {
                                    String text = JCommonUtil.getDocumentText(event);
                                    DefaultListModel model = new DefaultListModel();
                                    for (File f : backupFileList) {
                                        if (f.getName().contains(text)) {
                                            File_ ff = new File_();
                                            ff.file = f;
                                            model.addElement(ff);
                                        }
                                    }
                                    fileList.setModel(model);
                                }
                            }));
                }
                {
                    contentQueryText = new JTextField();
                    jPanel3.add(contentQueryText, BorderLayout.SOUTH);
                    contentQueryText.addActionListener(new ActionListener() {

                        void addModel(File f, DefaultListModel model) {
                            File_ ff = new File_();
                            ff.file = f;
                            model.addElement(ff);
                        }

                        public void actionPerformed(ActionEvent evt) {
                            DefaultListModel model = new DefaultListModel();
                            String text = contentQueryText.getText();
                            if (StringUtils.isEmpty(contentQueryText.getText())) {
                                return;
                            }
                            Pattern pattern = Pattern.compile(text);
                            Properties pp = null;
                            for (File f : backupFileList) {
                                pp = new Properties();
                                try {
                                    pp.load(new FileInputStream(f));
                                    for (String key : pp.stringPropertyNames()) {
                                        if (key.isEmpty()) {
                                            continue;
                                        }
                                        if (pp.getProperty(key) == null || pp.getProperty(key).isEmpty()) {
                                            continue;
                                        }
                                        if (key.contains(text)) {
                                            addModel(f, model);
                                            break;
                                        }
                                        if (pp.getProperty(key).contains(text)) {
                                            addModel(f, model);
                                            break;
                                        }
                                        if (pattern.matcher(key).find()) {
                                            addModel(f, model);
                                            break;
                                        }
                                        if (pattern.matcher(pp.getProperty(key)).find()) {
                                            addModel(f, model);
                                            break;
                                        }
                                    }
                                } catch (Exception e) {
                                    e.printStackTrace();
                                }
                            }
                            fileList.setModel(model);
                        }
                    });
                }
            }
        }
        JCommonUtil.setJFrameIcon(this, "resource/images/ico/english.ico");
        JCommonUtil.setJFrameCenter(this);
        pack();
        this.setSize(571, 408);

        loadCurrentFile(null);
    } catch (Exception e) {
        e.printStackTrace();
    }
}

From source file:net.rptools.maptool.client.ui.AddResourceDialog.java

private void downloadLibraryList() {
    if (downloadLibraryListInitiated) {
        return;//w w w  .jav a2 s .  c o m
    }

    // 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 listModel = new DefaultListModel();

            // 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();
}