private static String getFieldForColour(SimpleFeatureSource source) throws Exception { String selectedField = new String(); String[] fieldNames = new String[source.getSchema().getAttributeCount()]; int k = 0; for (AttributeDescriptor desc : source.getSchema().getAttributeDescriptors()) { fieldNames[k++] = desc.getLocalName(); } selectedField = JOptionPane.showInputDialog( null, "Choose an attribute for colouring", "Feature attribute", JOptionPane.PLAIN_MESSAGE, null, fieldNames, fieldNames[0]) .toString(); return selectedField; }