List of usage examples for javax.swing JList VERTICAL
int VERTICAL
To view the source code for javax.swing JList VERTICAL.
Click Source Link
From source file:statistic.ca.gui.JCAStatisticPanel.java
private JPanel addPropertiesComponents() { JPanel p = new JPanel(new GridBagLayout()); String[] statisticTypeNames = { "Grundinformationen", "Ausgangsverteilung", "Ankunftskurve", "evakuierte Individuen in Prozent", "maximale Blockadezeit", "durchschnittliche Blockadezeit", "minimale Blockadezeit", "zurckgelegte Distanz", "minimale Distanz zum initialen Ausgang", "minimale Distanz zum nchsten Ausgang", "Distanz ber Zeit", "maximale Zeit bis Safe", "durchschnittliche Zeit bis Safe", "minimale Zeit bis Safe", "maximale Geschwindigkeit ber Zeit", "durschnittliche Geschwindigkeit ber Zeit", "maximale Geschwindigkeit", "durchschnittliche Geschwindigkeit", "Panik ber Zeit", "Erschpfung ber Zeit" }; statisticType = new JComboBox(statisticTypeNames); statisticType.addActionListener(new TypePerformed()); JPanel timeIntervalGroup = new JPanel(); timeInterval = new JLabel("Zeitintervall:"); timeIntervalFrom = new JTextField(4); timeIntervalTo = new JTextField(4); timeIntervalGroup.add(timeInterval); timeIntervalGroup.add(timeIntervalFrom); timeIntervalGroup.add(new JLabel(" - ")); timeIntervalGroup.add(timeIntervalTo); assignmentListModel = new DefaultListModel(); assignmentList = new JList(assignmentListModel); // data has type Object[] assignmentList.getSelectionModel().addListSelectionListener(new AssignmentTypeListSelect()); assignmentList.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION); assignmentList.setLayoutOrientation(JList.VERTICAL); assignmentList.setVisibleRowCount(-1); JScrollPane listScroller = new JScrollPane(assignmentList); listScroller.setPreferredSize(new Dimension(100, 50)); JPanel assignmentButtons = new JPanel(); JButton btn_group = new JButton("Group"); JButton btn_ungroup = new JButton("Ungroup"); btn_group.addActionListener(new GroupPreformed()); btn_ungroup.addActionListener(new UngroupPreformed()); assignmentButtons.add(btn_group);/* w w w. j ava 2 s . c om*/ assignmentButtons.add(btn_ungroup); JButton btn_createDiagram = new JButton("Create Diagram"); btn_createDiagram.addActionListener(new CreateDiagramPerformed()); JButton btn_removeDiagram = new JButton("Remove Diagram"); btn_removeDiagram.addActionListener(new RemovePerformed()); JPanel diagramButtonGroup = new JPanel(); diagramButtonGroup.add(btn_createDiagram); diagramButtonGroup.add(btn_removeDiagram); diagramCategoryListModel = new DefaultListModel(); diagramCategoryList = new JList(diagramCategoryListModel); // data has type // Object[] diagramCategoryList.getSelectionModel().addListSelectionListener(new DiagramCategoryListSelect()); diagramCategoryList.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION); diagramCategoryList.setLayoutOrientation(JList.VERTICAL); diagramCategoryList.setVisibleRowCount(-1); JScrollPane diagramCategoryListScroller = new JScrollPane(diagramCategoryList); diagramCategoryListScroller.setPreferredSize(new Dimension(100, 50)); JPanel buttonGroup = new JPanel(); JButton btn_addToDiagram = new JButton("Add to Diagram"); JButton btn_removeFromDiagram = new JButton("Remove from Diagram"); buttonGroup.add(btn_addToDiagram); buttonGroup.add(btn_removeFromDiagram); btn_addToDiagram.addActionListener(new AddToDiagramPerformed()); btn_removeFromDiagram.addActionListener(new RemoveFromDiagramPerformed()); // Create statisticSource at last because we need the GUI Objects above to initialize // our selection in BatchResultEntryComboBoxModel.setSelectedItem () model = new BatchResultEntryComboBoxModel(); statisticSource = new JComboBox(model); int y = 0; p.add(statisticType, new GridBagConstraints(0, y++, 1, 1, 1.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(5, 5, 5, 5), 0, 0)); p.add(statisticSource, new GridBagConstraints(0, y++, 1, 1, 1.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(5, 5, 5, 5), 0, 0)); p.add(new JSeparator(SwingConstants.HORIZONTAL), new GridBagConstraints(0, y++, 1, 1, 1.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0)); p.add(new JLabel("Belegungen"), new GridBagConstraints(0, y++, 1, 1, 1.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(5, 5, 5, 5), 0, 0)); p.add(listScroller, new GridBagConstraints(0, y++, 1, 1, 1.0, 0.5, GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(5, 5, 5, 5), 0, 0)); p.add(assignmentButtons, new GridBagConstraints(0, y++, 1, 1, 1.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(5, 5, 5, 5), 0, 0)); p.add(new JSeparator(SwingConstants.HORIZONTAL), new GridBagConstraints(0, y++, 1, 1, 1.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0)); p.add(buttonGroup, new GridBagConstraints(0, y++, 1, 1, 1.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(5, 5, 5, 5), 0, 0)); p.add(new JSeparator(SwingConstants.HORIZONTAL), new GridBagConstraints(0, y++, 1, 1, 1.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0)); p.add(diagramCategoryListScroller, new GridBagConstraints(0, y++, 1, 1, 1.0, 0.5, GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(5, 5, 5, 5), 0, 0)); p.add(diagramButtonGroup, new GridBagConstraints(0, y++, 1, 1, 1.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(5, 5, 5, 5), 0, 0)); return p; }
From source file:org.apache.oodt.cas.workflow.gui.perspective.view.impl.DefaultPropView.java
@Override public void refreshView(final ViewState state) { this.removeAll(); tableMenu = new JPopupMenu("TableMenu"); this.add(tableMenu); override = new JMenuItem(OVERRIDE); override.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { int row = DefaultPropView.this.table.getSelectedRow();// rowAtPoint(DefaultPropView.this.table.getMousePosition()); String key = getKey((String) DefaultPropView.this.table.getValueAt(row, 1), state); Metadata staticMet = state.getSelected().getModel().getStaticMetadata(); if (staticMet == null) { staticMet = new Metadata(); }/* w w w . j a v a 2 s. co m*/ if (e.getActionCommand().equals(OVERRIDE)) { if (!staticMet.containsKey(key)) { staticMet.addMetadata(key, (String) DefaultPropView.this.table.getValueAt(row, 2)); String envReplace = (String) DefaultPropView.this.table.getValueAt(row, 3); if (Boolean.valueOf(envReplace)) { staticMet.addMetadata(key + "/envReplace", envReplace); } state.getSelected().getModel().setStaticMetadata(staticMet); DefaultPropView.this.notifyListeners(); } } } }); delete = new JMenuItem(DELETE); delete.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { int row = DefaultPropView.this.table.getSelectedRow();// rowAtPoint(DefaultPropView.this.table.getMousePosition()); String key = getKey((String) DefaultPropView.this.table.getValueAt(row, 1), state); Metadata staticMet = state.getSelected().getModel().getStaticMetadata(); if (staticMet == null) { staticMet = new Metadata(); } staticMet.removeMetadata(key); staticMet.removeMetadata(key + "/envReplace"); state.getSelected().getModel().setStaticMetadata(staticMet); DefaultPropView.this.notifyListeners(); } }); tableMenu.add(override); tableMenu.add(delete); if (state.getSelected() != null) { JPanel masterPanel = new JPanel(); masterPanel.setLayout(new BoxLayout(masterPanel, BoxLayout.Y_AXIS)); masterPanel.add(this.getModelIdPanel(state.getSelected(), state)); masterPanel.add(this.getModelNamePanel(state.getSelected(), state)); if (!state.getSelected().getModel().isParentType()) { masterPanel.add(this.getInstanceClassPanel(state.getSelected(), state)); } masterPanel.add(this.getExecutionTypePanel(state.getSelected(), state)); masterPanel.add(this.getPriorityPanel(state)); masterPanel.add(this.getExecusedIds(state.getSelected())); if (state.getSelected().getModel().getExecutionType().equals("condition")) { masterPanel.add(this.getTimeout(state.getSelected(), state)); masterPanel.add(this.getOptional(state.getSelected(), state)); } JScrollPane scrollPane = new JScrollPane(table = this.createTable(state), JScrollPane.VERTICAL_SCROLLBAR_ALWAYS, JScrollPane.HORIZONTAL_SCROLLBAR_ALWAYS); scrollPane.getHorizontalScrollBar().setUnitIncrement(10); scrollPane.getVerticalScrollBar().setUnitIncrement(10); JPanel panel = new JPanel(); panel.setLayout(new BorderLayout()); panel.setBorder(new EtchedBorder()); final JLabel metLabel = new JLabel("Static Metadata"); metLabel.setAlignmentX(Component.CENTER_ALIGNMENT); final JLabel extendsLabel = new JLabel("<extends>"); extendsLabel.setFont(new Font("Serif", Font.PLAIN, 10)); extendsLabel.setAlignmentX(Component.CENTER_ALIGNMENT); extendsLabel.addMouseListener(new MouseListener() { private JScrollPane availableScroller; private JScrollPane mineScroller; private JList mineList; private JList availableList; private DefaultListModel mineModel; private DefaultListModel availableModel; public void mouseClicked(MouseEvent e) { final JPopupMenu popup = new JPopupMenu(); popup.setLayout(new BorderLayout()); JPanel main = new JPanel(); main.setLayout(new BoxLayout(main, BoxLayout.X_AXIS)); JPanel mine = new JPanel(); mine.setBorder(new EtchedBorder()); mine.setLayout(new BorderLayout()); JLabel mineLabel = new JLabel("Mine"); mineScroller = new JScrollPane(mineList = createJList(mineModel = new DefaultListModel(), state.getSelected().getModel().getExtendsConfig())); mineScroller.setPreferredSize(new Dimension(250, 80)); mine.add(mineLabel, BorderLayout.NORTH); mine.add(mineScroller, BorderLayout.CENTER); JPanel available = new JPanel(); available.setBorder(new EtchedBorder()); available.setLayout(new BorderLayout()); JLabel availableLabel = new JLabel("Available"); Vector<String> availableGroups = new Vector<String>(state.getGlobalConfigGroups().keySet()); availableGroups.removeAll(state.getSelected().getModel().getExtendsConfig()); availableScroller = new JScrollPane(availableList = this .createJList(availableModel = new DefaultListModel(), availableGroups)); availableScroller.setPreferredSize(new Dimension(250, 80)); available.add(availableLabel, BorderLayout.NORTH); available.add(availableScroller, BorderLayout.CENTER); JPanel buttons = new JPanel(); buttons.setLayout(new BoxLayout(buttons, BoxLayout.Y_AXIS)); JButton addButton = new JButton("<---"); addButton.addMouseListener(new MouseListener() { public void mouseClicked(MouseEvent e) { String selected = availableList.getSelectedValue().toString(); Vector<String> extendsConfig = new Vector<String>( state.getSelected().getModel().getExtendsConfig()); extendsConfig.add(selected); state.getSelected().getModel().setExtendsConfig(extendsConfig); availableModel.remove(availableList.getSelectedIndex()); mineModel.addElement(selected); popup.revalidate(); DefaultPropView.this.notifyListeners(); } public void mouseEntered(MouseEvent e) { } public void mouseExited(MouseEvent e) { } public void mousePressed(MouseEvent e) { } public void mouseReleased(MouseEvent e) { } }); JButton removeButton = new JButton("--->"); removeButton.addMouseListener(new MouseListener() { public void mouseClicked(MouseEvent e) { String selected = mineList.getSelectedValue().toString(); Vector<String> extendsConfig = new Vector<String>( state.getSelected().getModel().getExtendsConfig()); extendsConfig.remove(selected); state.getSelected().getModel().setExtendsConfig(extendsConfig); mineModel.remove(mineList.getSelectedIndex()); availableModel.addElement(selected); popup.revalidate(); DefaultPropView.this.notifyListeners(); } public void mouseEntered(MouseEvent e) { } public void mouseExited(MouseEvent e) { } public void mousePressed(MouseEvent e) { } public void mouseReleased(MouseEvent e) { } }); buttons.add(addButton); buttons.add(removeButton); main.add(mine); main.add(buttons); main.add(available); popup.add(main, BorderLayout.CENTER); popup.show(extendsLabel, e.getX(), e.getY()); } public void mouseEntered(MouseEvent e) { extendsLabel.setForeground(Color.blue); } public void mouseExited(MouseEvent e) { extendsLabel.setForeground(Color.black); } public void mousePressed(MouseEvent e) { } public void mouseReleased(MouseEvent e) { } private JList createJList(DefaultListModel model, final List<String> list) { for (String value : list) { model.addElement(value); } JList jList = new JList(model); jList.setSelectionMode(ListSelectionModel.SINGLE_INTERVAL_SELECTION); jList.setLayoutOrientation(JList.VERTICAL); return jList; } }); JLabel metGroupLabel = new JLabel("(Sub-Group: " + (state.getCurrentMetGroup() != null ? state.getCurrentMetGroup() : "<base>") + ")"); metGroupLabel.setAlignmentX(Component.CENTER_ALIGNMENT); JPanel labelPanel = new JPanel(); labelPanel.setLayout(new BoxLayout(labelPanel, BoxLayout.Y_AXIS)); JPanel top = new JPanel(); top.setLayout(new BoxLayout(top, BoxLayout.Y_AXIS)); top.add(extendsLabel); top.add(metLabel); labelPanel.add(top); labelPanel.add(metGroupLabel); panel.add(labelPanel, BorderLayout.NORTH); panel.add(scrollPane, BorderLayout.CENTER); masterPanel.add(panel); this.add(masterPanel); } else { this.add(new JPanel()); } this.revalidate(); }
From source file:org.cloudml.ui.graph.Visu.java
public void createFrame() { final VisualizationViewer<Vertex, Edge> vv = v.getVisualisationViewer(); vv.getRenderContext().setVertexIconTransformer(new Transformer<Vertex, Icon>() { public Icon transform(final Vertex v) { return new Icon() { public int getIconHeight() { return 40; }// w ww . j a v a 2 s .c o m public int getIconWidth() { return 40; } public void paintIcon(java.awt.Component c, Graphics g, int x, int y) { ImageIcon img; if (v.getType() == "node") { img = new ImageIcon(this.getClass().getResource("/server.png")); } else if (v.getType() == "platform") { img = new ImageIcon(this.getClass().getResource("/dbms.png")); } else { img = new ImageIcon(this.getClass().getResource("/soft.png")); } ImageObserver io = new ImageObserver() { public boolean imageUpdate(Image img, int infoflags, int x, int y, int width, int height) { // TODO Auto-generated method stub return false; } }; g.drawImage(img.getImage(), x, y, getIconHeight(), getIconWidth(), io); if (!vv.getPickedVertexState().isPicked(v)) { g.setColor(Color.black); } else { g.setColor(Color.red); properties.setModel(new CPIMTable(v)); runtimeProperties.setModel(new CPSMTable(v)); } g.drawString(v.getName(), x - 10, y + 50); } }; } }); // create a frame to hold the graph final JFrame frame = new JFrame(); Container content = frame.getContentPane(); final GraphZoomScrollPane panel = new GraphZoomScrollPane(vv); content.add(panel, BorderLayout.CENTER); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); final ModalGraphMouse gm = new DefaultModalGraphMouse<Integer, Number>(); vv.setGraphMouse(gm); final ScalingControl scaler = new CrossoverScalingControl(); JButton plus = new JButton("+"); plus.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { scaler.scale(vv, 1.1f, vv.getCenter()); } }); JButton save = new JButton("save"); save.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { JFileChooser fc = new JFileChooser(); int returnVal = fc.showDialog(frame, "save"); File result = fc.getSelectedFile(); JsonCodec codec = new JsonCodec(); OutputStream streamResult; try { streamResult = new FileOutputStream(result); codec.save(dmodel, streamResult); } catch (FileNotFoundException e1) { // TODO Auto-generated catch block e1.printStackTrace(); } } }); JButton saveImage = new JButton("save as image"); saveImage.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { JFileChooser fc = new JFileChooser(); int returnVal = fc.showDialog(frame, "save"); File result = fc.getSelectedFile(); JsonCodec codec = new JsonCodec(); v.writeJPEGImage(result); } }); //WE NEED TO UPDATE THE FACADE AND THE GUI JButton load = new JButton("load"); load.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { JFileChooser fc = new JFileChooser(); int returnVal = fc.showDialog(frame, "load"); File result = fc.getSelectedFile(); JsonCodec codec = new JsonCodec(); try { InputStream stream = new FileInputStream(result); Deployment model = (Deployment) codec.load(stream); dmodel = model; v.setDeploymentModel(dmodel); ArrayList<Vertex> V = v.drawFromDeploymentModel(); nodeTypes.removeAll(); nodeTypes.setModel(fillList()); properties.setModel(new CPIMTable(V.get(0))); runtimeProperties.setModel(new CPSMTable(V.get(0))); CommandFactory fcommand = new CommandFactory(); CloudMlCommand load = fcommand.loadDeployment(result.getPath()); cml.fireAndWait(load); } catch (FileNotFoundException e1) { // TODO Auto-generated catch block e1.printStackTrace(); } } }); JButton minus = new JButton("-"); minus.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { scaler.scale(vv, 1 / 1.1f, vv.getCenter()); } }); JButton deploy = new JButton("Deploy!"); deploy.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { //cad.deploy(dmodel); System.out.println("deploy"); CommandFactory fcommand = new CommandFactory(); CloudMlCommand deploy = fcommand.deploy(); cml.fireAndWait(deploy); } }); //right panel JPanel intermediary = new JPanel(); intermediary.setLayout(new BoxLayout(intermediary, BoxLayout.PAGE_AXIS)); intermediary.setBorder(BorderFactory.createLineBorder(Color.black)); JLabel jlCPIM = new JLabel(); jlCPIM.setText("CPIM"); JLabel jlCPSM = new JLabel(); jlCPSM.setText("CPSM"); properties = new JTable(null); //properties.setAutoResizeMode(JTable.AUTO_RESIZE_ALL_COLUMNS); JTableHeader h = properties.getTableHeader(); JPanel props = new JPanel(); props.setLayout(new BorderLayout()); props.add(new JScrollPane(properties), BorderLayout.CENTER); props.add(h, BorderLayout.NORTH); runtimeProperties = new JTable(null); //runtimeProperties.setAutoResizeMode(JTable.AUTO_RESIZE_ALL_COLUMNS); JTableHeader h2 = runtimeProperties.getTableHeader(); JPanel runProps = new JPanel(); runProps.setLayout(new BorderLayout()); runProps.add(h2, BorderLayout.NORTH); runProps.add(new JScrollPane(runtimeProperties), BorderLayout.CENTER); intermediary.add(jlCPIM); intermediary.add(props); intermediary.add(jlCPSM); intermediary.add(runProps); content.add(intermediary, BorderLayout.EAST); //Left panel JPanel selection = new JPanel(); JLabel nodes = new JLabel(); nodes.setText("Types"); selection.setLayout(new BoxLayout(selection, BoxLayout.PAGE_AXIS)); nodeTypes = new JList(fillList()); nodeTypes.setLayoutOrientation(JList.VERTICAL); nodeTypes.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); nodeTypes.setVisibleRowCount(10); JScrollPane types = new JScrollPane(nodeTypes); types.setPreferredSize(new Dimension(150, 80)); selection.add(nodes); selection.add(types); content.add(selection, BorderLayout.WEST); ((DefaultModalGraphMouse<Integer, Number>) gm) .add(new MyEditingGraphMousePlugin(0, vv, v.getGraph(), nodeTypes, dmodel)); JPanel controls = new JPanel(); controls.add(plus); controls.add(minus); controls.add(save); controls.add(saveImage); controls.add(load); controls.add(deploy); controls.add(((DefaultModalGraphMouse<Integer, Number>) gm).getModeComboBox()); content.add(controls, BorderLayout.SOUTH); frame.pack(); frame.setVisible(true); }