Java Code Examples for javax.swing.DefaultListModel#set()

The following examples show how to use javax.swing.DefaultListModel#set() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ListSelectionPanel.java    From nextreports-designer with Apache License 2.0 6 votes vote down vote up
@SuppressWarnings("unchecked")
private void sort(DefaultListModel model) {
	// we need a List for sorting
	int size = model.getSize();
	ArrayList list = new ArrayList();
	for (int x = 0; x < size; ++x) {
		Object o = model.get(x);
		list.add(o);
	}

	if (comp != null) {
	   Collections.sort(list, comp);
	} else {
	   Collections.sort(list);
	}
	// update the model with a sorted List
	for (int x = 0; x < size; ++x) {
		Object obj = list.get(x);			
		if ((model.getElementAt(x) != null) && !model.getElementAt(x).equals(obj)) {
			model.set(x, obj);
		}
	}
}
 
Example 2
Source File: ListTransferHandler.java    From marathonv5 with Apache License 2.0 5 votes vote down vote up
@Override
public boolean importData(TransferHandler.TransferSupport info) {
    if (!info.isDrop()) {
        return false;
    }

    JList list = (JList) info.getComponent();
    DefaultListModel listModel = (DefaultListModel) list.getModel();
    JList.DropLocation dl = (JList.DropLocation) info.getDropLocation();
    int index = dl.getIndex();
    boolean insert = dl.isInsert();

    // Get the string that is being dropped.
    Transferable t = info.getTransferable();
    String data;
    try {
        data = (String) t.getTransferData(DataFlavor.stringFlavor);
    } catch (Exception e) {
        return false;
    }

    // Perform the actual import.
    if (insert) {
        listModel.add(index, data);
    } else {
        listModel.set(index, data);
    }
    return true;
}
 
Example 3
Source File: BreakpointNestedGroupsDialog.java    From netbeans with Apache License 2.0 5 votes vote down vote up
private void moveUpButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_moveUpButtonActionPerformed
    int[] indexes = displayedGroupsList.getSelectedIndices();
    DefaultListModel displayedModel = (DefaultListModel) displayedGroupsList.getModel();
    for (int index : indexes) {
        Object down = displayedModel.get(index - 1);
        Object up = displayedModel.get(index);
        displayedModel.set(index, down);
        displayedModel.set(index - 1, up);
    }
    for (int i = 0; i < indexes.length; i++) {
        indexes[i]--;
    }
    displayedGroupsList.setSelectedIndices(indexes);
}
 
Example 4
Source File: BreakpointNestedGroupsDialog.java    From netbeans with Apache License 2.0 5 votes vote down vote up
private void moveDownButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_moveDownButtonActionPerformed
    int[] indexes = displayedGroupsList.getSelectedIndices();
    DefaultListModel displayedModel = (DefaultListModel) displayedGroupsList.getModel();
    for (int index : indexes) {
        Object down = displayedModel.get(index);
        Object up = displayedModel.get(index + 1);
        displayedModel.set(index + 1, down);
        displayedModel.set(index, up);
    }
    for (int i = 0; i < indexes.length; i++) {
        indexes[i]++;
    }
    displayedGroupsList.setSelectedIndices(indexes);
}
 
Example 5
Source File: ClassPathFormImpl.java    From beast-mcmc with GNU Lesser General Public License v2.1 5 votes vote down vote up
public void actionPerformed(ActionEvent e) {
	int x = _classpathList.getSelectedIndex();
	if (x < 1) {
		return;
	}
	DefaultListModel model = (DefaultListModel) _classpathList.getModel();
	Object o = model.get(x - 1);
	model.set(x - 1, model.get(x));
	model.set(x, o);
	_classpathList.setSelectedIndex(x - 1);
}
 
Example 6
Source File: ClassPathFormImpl.java    From beast-mcmc with GNU Lesser General Public License v2.1 5 votes vote down vote up
public void actionPerformed(ActionEvent e) {
	DefaultListModel model = (DefaultListModel) _classpathList.getModel();
	int x = _classpathList.getSelectedIndex();
	if (x == -1 || x >= model.getSize() - 1) {
		return;
	}
	Object o = model.get(x + 1);
	model.set(x + 1, model.get(x));
	model.set(x, o);
	_classpathList.setSelectedIndex(x + 1);
}
 
Example 7
Source File: ClassPathFormImpl.java    From magarena with GNU General Public License v3.0 5 votes vote down vote up
public void actionPerformed(ActionEvent e) {
	int x = _classpathList.getSelectedIndex();
	if (x < 1) {
		return;
	}
	DefaultListModel model = (DefaultListModel) _classpathList.getModel();
	Object o = model.get(x - 1);
	model.set(x - 1, model.get(x));
	model.set(x, o);
	_classpathList.setSelectedIndex(x - 1);
}
 
Example 8
Source File: ClassPathFormImpl.java    From magarena with GNU General Public License v3.0 5 votes vote down vote up
public void actionPerformed(ActionEvent e) {
	DefaultListModel model = (DefaultListModel) _classpathList.getModel();
	int x = _classpathList.getSelectedIndex();
	if (x == -1 || x >= model.getSize() - 1) {
		return;
	}
	Object o = model.get(x + 1);
	model.set(x + 1, model.get(x));
	model.set(x, o);
	_classpathList.setSelectedIndex(x + 1);
}
 
Example 9
Source File: ClassPathFormImpl.java    From PyramidShader with GNU General Public License v3.0 5 votes vote down vote up
public void actionPerformed(ActionEvent e) {
	int x = _classpathList.getSelectedIndex();
	if (x < 1) {
		return;
	}
	DefaultListModel model = (DefaultListModel) _classpathList.getModel();
	Object o = model.get(x - 1);
	model.set(x - 1, model.get(x));
	model.set(x, o);
	_classpathList.setSelectedIndex(x - 1);
}
 
Example 10
Source File: ClassPathFormImpl.java    From PyramidShader with GNU General Public License v3.0 5 votes vote down vote up
public void actionPerformed(ActionEvent e) {
	DefaultListModel model = (DefaultListModel) _classpathList.getModel();
	int x = _classpathList.getSelectedIndex();
	if (x == -1 || x >= model.getSize() - 1) {
		return;
	}
	Object o = model.get(x + 1);
	model.set(x + 1, model.get(x));
	model.set(x, o);
	_classpathList.setSelectedIndex(x + 1);
}
 
Example 11
Source File: ClassPathFormImpl.java    From jmkvpropedit with BSD 2-Clause "Simplified" License 5 votes vote down vote up
public void actionPerformed(ActionEvent e) {
	int x = _classpathList.getSelectedIndex();
	if (x < 1) {
		return;
	}
	DefaultListModel model = (DefaultListModel) _classpathList.getModel();
	Object o = model.get(x - 1);
	model.set(x - 1, model.get(x));
	model.set(x, o);
	_classpathList.setSelectedIndex(x - 1);
}
 
Example 12
Source File: ClassPathFormImpl.java    From jmkvpropedit with BSD 2-Clause "Simplified" License 5 votes vote down vote up
public void actionPerformed(ActionEvent e) {
	DefaultListModel model = (DefaultListModel) _classpathList.getModel();
	int x = _classpathList.getSelectedIndex();
	if (x == -1 || x >= model.getSize() - 1) {
		return;
	}
	Object o = model.get(x + 1);
	model.set(x + 1, model.get(x));
	model.set(x, o);
	_classpathList.setSelectedIndex(x + 1);
}
 
Example 13
Source File: RelativeOrderingPanel.java    From netbeans with Apache License 2.0 4 votes vote down vote up
private void exchange(DefaultListModel model, int x) {
    Object tmp1 = model.get(x);
    Object tmp2 = model.get(x+1);
    model.set(x, tmp2);
    model.set(x+1, tmp1);
}
 
Example 14
Source File: DrawerEditor.java    From brModelo with GNU General Public License v3.0 4 votes vote down vote up
@Override
    public boolean AceitaEdicao(InspectorProperty propriedade, String valor) {
        try {
            switch (propriedade.property) {
//#Removido o "Medida".
//# Talvez, no futuro ele volte. Atualmente considerado inadequado e trabalhoso. Talvez possa usar a régua como base para o futuro desenho.
//# Código permanece em baseDrawerItem! //??: TO-DO: Remover códigos!
//#                case "setLeft":
//#                    Selecionado.setLeft(Integer.valueOf(valor));
//#                    break;
//#                case "setTop":
//#                    Selecionado.setTop(Integer.valueOf(valor));
//#                    break;
//#                case "setWidth":
//#                    Selecionado.setWidth(Integer.valueOf(valor));
//#                    break;
//#                case "setHeight":
//#                    Selecionado.setHeight(Integer.valueOf(valor));
//#                    break;
                case "SetTipo":
                    Selecionado.SetTipo(Integer.valueOf(valor));
                    DefaultListModel dlm = (DefaultListModel) Lista.getModel();
                    dlm.set(Lista.getSelectedIndex(),
                            Integer.toString(Lista.getSelectedIndex()) + " "
                            + Editor.fromConfiguracao.getValor("Inspector.lst.basedraweritem." + Selecionado.getTipo().name().toLowerCase()));
                    break;
                case "setPath":
                    Selecionado.setPath(valor);
                    break;
                case "setFill":
                    Selecionado.setFill(Boolean.valueOf(valor));
                    break;
//#                case "setInvertido":
//#                    Selecionado.setInvertido(Boolean.valueOf(valor));
//#                    break;
                case "setRecivePaint":
                    Selecionado.setRecivePaint(Boolean.valueOf(valor));
                    break;
                case "setCor":
                    Selecionado.setCor(util.Utilidades.StringToColor(valor));
                    break;
                case "setRetangulo":
                    Selecionado.setRetangulo(valor);
                    break;
                case "setElipse":
                    Selecionado.setElipse(valor);
                    break;
                case "setCurva":
                    Selecionado.setCurva(valor);
                    break;
                case "setArco":
                    Selecionado.setArco(valor);
                    break;
                case "setPosiImagem":
                    Selecionado.setPosiImagem(valor);
                    break;
                case "setVertical":
                    Selecionado.setVertical(Boolean.valueOf(valor));
                    break;
                case "setGradiente":
                    Selecionado.setGradiente(Boolean.valueOf(valor));
                    break;
                case "setGradienteStartColor":
                    Selecionado.setGradienteStartColor(util.Utilidades.StringToColor(valor));
                    break;
                case "setGradienteEndColor":
                    Selecionado.setGradienteEndColor(util.Utilidades.StringToColor(valor));
                    break;
                case "setDirecaogradiente":
                    Selecionado.setDirecaogradiente(Integer.valueOf(valor));
                    break;

            }
        } catch (Exception e) {
            BrLogger.Logger("AceitaEdicao", e.getMessage());
            PerformInspectorFor();
            Item.InvalidateArea();
            return false;
        }
        PerformInspectorFor();
        Item.DoMuda();
        Item.InvalidateArea();
        return true;
    }