Package javax.swing

Examples of javax.swing.DefaultListModel


        return wrapper;
    }

    private Component createTemplates() {
        DefaultListModel model = new DefaultListModel();
        model.addElement(createTemplate(0.0, 0.0, 1.0, 1.0));
        model.addElement(createTemplate(0.0, 1.0, 0.0, 1.0));
        model.addElement(createTemplate(0.0, 1.0, 1.0, 1.0));
        model.addElement(createTemplate(0.0, 1.0, 1.0, 0.0));
        model.addElement(createTemplate(1.0, 0.0, 0.0, 1.0));
        model.addElement(createTemplate(1.0, 0.0, 1.0, 1.0));
        model.addElement(createTemplate(1.0, 0.0, 1.0, 0.0));

        JList list = new JList(model);
        list.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
        list.setCellRenderer(new TemplateCellRenderer());
        list.addListSelectionListener(new TemplateSelectionHandler());
View Full Code Here


    /**
     * Initializes the GUI.
     */
    private void initGUI() {
      descriptorList= new JList(new DefaultListModel());
      descriptorList.setCellRenderer(new DescriptorListCellRenderer(descriptorType));
      JScrollPane pane = new JScrollPane(descriptorList);
     
      descriptorList.addMouseListener(new MouseAdapter(){
        @Override
View Full Code Here

          java.awt.EventQueue
              // i dont question the Java API, it works now.
          .invokeLater(() -> {

                final DefaultListModel playListModel = new DefaultListModel();

            final File[] playListFolder = new File(
                Constants.DATA_PATH + "playlist/")
            .listFiles();
            if ((kind == ENTRY_CREATE)
                || ((kind == ENTRY_DELETE)
                    && (playListModel != null) && (playListFolder != null))) {

              for (final File file : playListFolder) {
                playListModel.addElement(file);
              }
              displayList.setModel(playListModel);
                  // / displayList.updateUI();
            }
          });
View Full Code Here

        }
      });
    }

    static ListModel modelWith(Object[] items) {
      DefaultListModel model = new DefaultListModel();
      for (Object item : items) {
        model.addElement(item);
      }
      return model;
    }
View Full Code Here

    }

    // Take the incoming string and wherever there is a newline, break it into a separate item in the list.
    @Override
    protected void importString(JList target, String s) {
      DefaultListModel listModel = (DefaultListModel) target.getModel();
      int index = target.getSelectedIndex();
      // Prevent the user from dropping data back on itself.
      if (rows != null && index >= rows[0] - 1 && index <= rows[rows.length - 1]) {
        rows = null;
        return;
      }
      int max = listModel.getSize();
      if (index < 0) {
        index = max;
      } else {
        index++;
        if (index > max) {
          index = max;
        }
      }
      addIndex = index;
      String[] values = s.split("\n");
      addCount = values.length;
      for (String value : values) {
        listModel.add(index++, value);
      }
    }
View Full Code Here

    // If the remove argument is true, the drop has been successful and it's time to remove the selected items from the
    // list. If the remove argument is false, it was a Copy operation and the original list is left intact.
    @Override
    protected void cleanup(JList source, boolean remove) {
      if (remove && rows != null) {
        DefaultListModel model = (DefaultListModel) source.getModel();
        // If we are moving items around in the same list, we need to adjust the indices accordingly, since those after
        // the insertion point have moved.
        if (addCount > 0) {
          for (int i = 0; i < rows.length; i++) {
            if (rows[i] > addIndex) {
              rows[i] += addCount;
            }
          }
        }
        for (int i = rows.length - 1; i >= 0; i--) {
          model.remove(rows[i]);
        }
      }
    }
View Full Code Here

        Project project = file.getProject();
        FileConnectionMappingManager connectionMappingManager = FileConnectionMappingManager.getInstance(project);
        activeConnection = connectionMappingManager.getActiveConnection(virtualFile);
        currentSchema = connectionMappingManager.getCurrentSchema(virtualFile);

        DefaultListModel connectionListModel = new DefaultListModel();
        List<ConnectionHandler> connectionHandlers = ProjectConnectionBundle.getInstance(project).getConnectionHandlers();
        for (ConnectionHandler connectionHandler : connectionHandlers) {
            connectionListModel.addElement(connectionHandler);
        }

        Module currentModule = ModuleUtil.findModuleForFile(virtualFile, project);
        if (currentModule != null) {
            connectionHandlers = ModuleConnectionBundle.getInstance(currentModule).getConnectionHandlers();
            for (ConnectionHandler connectionHandler : connectionHandlers) {
                connectionListModel.addElement(connectionHandler);
            }
        }

        connectionsList.setModel(connectionListModel);
        if (activeConnection == null) {
View Full Code Here

    }

    private void populateSchemaList() {
        ConnectionHandler selectedConnection = getSelectedConnection();
        if (selectedConnection == null) {
            schemasList.setModel(new DefaultListModel());
        } else {
            List<DBSchema> schemas = selectedConnection.getObjectBundle().getSchemas();
            DefaultListModel model = new DefaultListModel();

            for (DBSchema schema : schemas) {
                model.addElement(schema);
            }
            schemasList.setModel(model);
            DBSchema selectedSchema =
                    activeConnection == selectedConnection ? currentSchema :
                    selectedConnection.getObjectBundle().getUserSchema();
View Full Code Here

        Color bg = new Color(230, 230, 230);
        EmptyBorder border = new EmptyBorder(5, 5, 5, 5);
        Container content = getContentPane();
        content.setLayout(new GridLayout(1, 3));
       
        types = new DefaultListModel();
        typeList = new JList(types);
        typeList.setBorder(border);
        typeList.setBackground(bg);
        typeList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
        typeList.addListSelectionListener(this);
       
        JPanel typePanel = new JPanel();
        typePanel.setLayout(new BorderLayout());
        typePanel.add("North", new JLabel("Types"));
        typePanel.add("Center", new JScrollPane(typeList, JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED, JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED));
        content.add(typePanel);
       
        services = new DefaultListModel();
        serviceList = new JList(services);
        serviceList.setBorder(border);
        serviceList.setBackground(bg);
        serviceList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
        serviceList.addListSelectionListener(this);
View Full Code Here

        headerPanel.add(headerForm.getComponent(), BorderLayout.CENTER);

        hintTextArea.setText(hint);
        hintTextArea.setBackground(mainPanel.getBackground());
        hintTextArea.setFont(mainPanel.getFont());
        DefaultListModel listModel = new DefaultListModel();
        for (VirtualFile virtualFile : virtualFiles) {
            listModel.addElement(virtualFile);
        }
        filesList.setModel(listModel);
        filesList.setCellRenderer(new FileListCellRenderer(project));
        filesList.setSelectedIndex(0);
View Full Code Here

TOP

Related Classes of javax.swing.DefaultListModel

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.