List of usage examples for javax.swing.event ListSelectionListener ListSelectionListener
ListSelectionListener
From source file:SimpleTableSelectionDemo.java
public SimpleTableSelectionDemo() { super(new GridLayout(1, 0)); final String[] columnNames = { "First Name", "Last Name", "Sport", "# of Years", "Vegetarian" }; final Object[][] data = { { "Mary", "Campione", "Snowboarding", new Integer(5), new Boolean(false) }, { "Alison", "Huml", "Rowing", new Integer(3), new Boolean(true) }, { "Kathy", "Walrath", "Knitting", new Integer(2), new Boolean(false) }, { "Sharon", "Zakhour", "Speed reading", new Integer(20), new Boolean(true) }, { "Philip", "Milne", "Pool", new Integer(10), new Boolean(false) } }; final JTable table = new JTable(data, columnNames); table.setPreferredScrollableViewportSize(new Dimension(500, 70)); table.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); if (ALLOW_ROW_SELECTION) { // true by default ListSelectionModel rowSM = table.getSelectionModel(); rowSM.addListSelectionListener(new ListSelectionListener() { public void valueChanged(ListSelectionEvent e) { //Ignore extra messages. if (e.getValueIsAdjusting()) return; ListSelectionModel lsm = (ListSelectionModel) e.getSource(); if (lsm.isSelectionEmpty()) { System.out.println("No rows are selected."); } else { int selectedRow = lsm.getMinSelectionIndex(); System.out.println("Row " + selectedRow + " is now selected."); }/* w w w.j av a 2 s . c o m*/ } }); } else { table.setRowSelectionAllowed(false); } if (ALLOW_COLUMN_SELECTION) { // false by default if (ALLOW_ROW_SELECTION) { //We allow both row and column selection, which //implies that we *really* want to allow individual //cell selection. table.setCellSelectionEnabled(true); } table.setColumnSelectionAllowed(true); ListSelectionModel colSM = table.getColumnModel().getSelectionModel(); colSM.addListSelectionListener(new ListSelectionListener() { public void valueChanged(ListSelectionEvent e) { //Ignore extra messages. if (e.getValueIsAdjusting()) return; ListSelectionModel lsm = (ListSelectionModel) e.getSource(); if (lsm.isSelectionEmpty()) { System.out.println("No columns are selected."); } else { int selectedCol = lsm.getMinSelectionIndex(); System.out.println("Column " + selectedCol + " is now selected."); } } }); } if (DEBUG) { table.addMouseListener(new MouseAdapter() { public void mouseClicked(MouseEvent e) { printDebugData(table); } }); } //Create the scroll pane and add the table to it. JScrollPane scrollPane = new JScrollPane(table); //Add the scroll pane to this panel. add(scrollPane); }
From source file:lu.lippmann.cdb.ext.hydviga.ui.GapsOverviewPanel.java
public void refresh(final Instances dataSet, final int dateIdx) { final Instances gapsDescriptionsDataset = GapsUtil.buildGapsDescription(gcp, dataSet, dateIdx); final JXTable gapsDescriptionsTable = new JXTable(); final InstanceTableModel gapsDescriptionsTableModel = new InstanceTableModel(false); gapsDescriptionsTableModel.setDataset(gapsDescriptionsDataset); gapsDescriptionsTable.setModel(gapsDescriptionsTableModel); gapsDescriptionsTable.setEditable(true); gapsDescriptionsTable.setShowHorizontalLines(false); gapsDescriptionsTable.setShowVerticalLines(false); gapsDescriptionsTable.setVisibleRowCount(5); gapsDescriptionsTable.setAutoResizeMode(JTable.AUTO_RESIZE_OFF); gapsDescriptionsTable.setSortable(false); gapsDescriptionsTable.packAll();/*w w w . jav a 2 s. c o m*/ gapsDescriptionsTable.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); gapsDescriptionsTable.getSelectionModel().addListSelectionListener(new ListSelectionListener() { @Override public void valueChanged(ListSelectionEvent e) { if (!e.getValueIsAdjusting()) { int modelRow = gapsDescriptionsTable.getSelectedRow(); if (modelRow < 0) modelRow = 0; final String attrname = gapsDescriptionsTableModel.getValueAt(modelRow, 1).toString(); final Attribute attr = dataSet.attribute(attrname); final int gapsize = (int) Double .valueOf(gapsDescriptionsTableModel.getValueAt(modelRow, 5).toString()).doubleValue(); final int position = (int) Double .valueOf(gapsDescriptionsTableModel.getValueAt(modelRow, 6).toString()).doubleValue(); try { final ChartPanel cp = GapsUIUtil.buildGapChartPanel(dataSet, dateIdx, attr, gapsize, position); visualOverviewPanel.removeAll(); visualOverviewPanel.add(cp, BorderLayout.CENTER); geomapPanel.removeAll(); geomapPanel.add(gcp.getMapPanel(Arrays.asList(attrname), new ArrayList<String>(), false)); jxp.updateUI(); } catch (Exception ee) { ee.printStackTrace(); } } } }); gapsDescriptionsTable.addMouseListener(new MouseAdapter() { @Override public void mouseReleased(final MouseEvent e) { final InstanceTableModel instanceTableModel = (InstanceTableModel) gapsDescriptionsTable.getModel(); final int row = gapsDescriptionsTable.rowAtPoint(e.getPoint()); //final int row=gapsDescriptionsTable.getSelectedRow(); final int modelRow = gapsDescriptionsTable.convertRowIndexToModel(row); //final int modelRow=(int)Double.valueOf(instanceTableModel.getValueAt(row,0).toString()).doubleValue(); //System.out.println(row+" "+modelRow); final String attrname = instanceTableModel.getValueAt(modelRow, 1).toString(); final Attribute attr = dataSet.attribute(attrname); final int gapsize = (int) Double.valueOf(instanceTableModel.getValueAt(modelRow, 5).toString()) .doubleValue(); final int position = (int) Double.valueOf(instanceTableModel.getValueAt(modelRow, 6).toString()) .doubleValue(); if (!e.isPopupTrigger()) { // nothing? } else { final JPopupMenu jPopupMenu = new JPopupMenu("feur"); final JMenuItem interactiveFillMenuItem = new JMenuItem("Fill this gap (interactively)"); interactiveFillMenuItem.addActionListener(new ActionListener() { @Override public void actionPerformed(final ActionEvent e) { final GapFillingFrame jxf = new GapFillingFrame(atv, dataSet, attr, dateIdx, GapsUtil.getCountOfValuesBeforeAndAfter(gapsize), position, gapsize, gcp, false); jxf.setSize(new Dimension(900, 700)); //jxf.setExtendedState(Frame.MAXIMIZED_BOTH); jxf.setLocationRelativeTo(jPopupMenu); jxf.setVisible(true); //jxf.setResizable(false); } }); jPopupMenu.add(interactiveFillMenuItem); final JMenuItem lookupInKnowledgeDBMenuItem = new JMenuItem( "Show the most similar cases from KnowledgeDB"); lookupInKnowledgeDBMenuItem.addActionListener(new ActionListener() { @Override public void actionPerformed(final ActionEvent e) { final double x = gcp.getCoordinates(attrname)[0]; final double y = gcp.getCoordinates(attrname)[1]; final String season = instanceTableModel.getValueAt(modelRow, 3).toString() .split("/")[0]; final boolean isDuringRising = instanceTableModel.getValueAt(modelRow, 11).toString() .equals("true"); try { final Calendar cal = Calendar.getInstance(); final String dateAsString = instanceTableModel.getValueAt(modelRow, 2).toString() .replaceAll("'", ""); cal.setTime(FormatterUtil.DATE_FORMAT.parse(dateAsString)); final int year = cal.get(Calendar.YEAR); new SimilarCasesFrame(dataSet, dateIdx, gcp, attrname, gapsize, position, x, y, year, season, isDuringRising); } catch (Exception e1) { e1.printStackTrace(); } } }); jPopupMenu.add(lookupInKnowledgeDBMenuItem); final JMenuItem mExport = new JMenuItem("Export this table as CSV"); mExport.addActionListener(new ActionListener() { @Override public void actionPerformed(final ActionEvent e) { final JFileChooser fc = new JFileChooser(); fc.setAcceptAllFileFilterUsed(false); final int returnVal = fc.showSaveDialog(gapsDescriptionsTable); if (returnVal == JFileChooser.APPROVE_OPTION) { try { final File file = fc.getSelectedFile(); WekaDataAccessUtil.saveInstancesIntoCSVFile(gapsDescriptionsDataset, file); } catch (Exception ee) { ee.printStackTrace(); } } } }); jPopupMenu.add(mExport); jPopupMenu.show(gapsDescriptionsTable, e.getX(), e.getY()); } } }); final int tableWidth = (int) gapsDescriptionsTable.getPreferredSize().getWidth() + 30; final JScrollPane scrollPane = new JScrollPane(gapsDescriptionsTable); scrollPane.setPreferredSize(new Dimension(Math.min(tableWidth, 500), 500)); scrollPane.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED); this.tablePanel.removeAll(); this.tablePanel.add(scrollPane, BorderLayout.CENTER); this.visualOverviewPanel.removeAll(); /* automatically compute the most similar series and the 'rising' flag */ new AbstractSimpleAsync<Void>(false) { @Override public Void execute() throws Exception { final int rc = gapsDescriptionsTableModel.getRowCount(); for (int i = 0; i < rc; i++) { final int modelRow = i; try { final String attrname = gapsDescriptionsTableModel.getValueAt(modelRow, 1).toString(); final Attribute attr = dataSet.attribute(attrname); final int gapsize = (int) Double .valueOf(gapsDescriptionsTableModel.getValueAt(modelRow, 5).toString()) .doubleValue(); final int position = (int) Double .valueOf(gapsDescriptionsTableModel.getValueAt(modelRow, 6).toString()) .doubleValue(); /* most similar */ gapsDescriptionsTableModel.setValueAt("...", modelRow, 7); final int cvba = GapsUtil.getCountOfValuesBeforeAndAfter(gapsize); Instances gapds = WekaDataProcessingUtil.buildFilteredDataSet(dataSet, 0, dataSet.numAttributes() - 1, Math.max(0, position - cvba), Math.min(position + gapsize + cvba, dataSet.numInstances() - 1)); final String mostsimilar = WekaTimeSeriesSimilarityUtil.findMostSimilarTimeSerie(gapds, attr, WekaTimeSeriesUtil.getNamesOfAttributesWithoutGap(gapds), false); gapsDescriptionsTableModel.setValueAt(mostsimilar, modelRow, 7); /* 'rising' flag */ gapsDescriptionsTableModel.setValueAt("...", modelRow, 11); final List<String> attributeNames = WekaDataStatsUtil.getAttributeNames(dataSet); attributeNames.remove("timestamp"); final String nearestStationName = gcp.findNearestStation(attr.name(), attributeNames); final Attribute nearestStationAttr = dataSet.attribute(nearestStationName); //System.out.println(nearestStationName+" "+nearestStationAttr); final boolean isDuringRising = GapsUtil.isDuringRising(dataSet, position, gapsize, new int[] { dateIdx, attr.index(), nearestStationAttr.index() }); gapsDescriptionsTableModel.setValueAt(isDuringRising, modelRow, 11); gapsDescriptionsTableModel.fireTableDataChanged(); } catch (Exception e) { gapsDescriptionsTableModel.setValueAt("n/a", modelRow, 7); gapsDescriptionsTableModel.setValueAt("n/a", modelRow, 11); e.printStackTrace(); } } return null; } @Override public void onSuccess(Void result) { } @Override public void onFailure(Throwable caught) { caught.printStackTrace(); } }.start(); /* select the first row */ gapsDescriptionsTable.setRowSelectionInterval(0, 0); }
From source file:com.iisigroup.ris.WebFileScanUtilBrowserUI.java
private void initGUI() { final SwingActionUtil swingUtil = (SwingActionUtil) SwingActionUtil.newInstance(this); try {/* w w w . j ava 2s.c o m*/ BorderLayout thisLayout = new BorderLayout(); getContentPane().setLayout(thisLayout); this.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE); this.setTitle("browser source code"); { informationMenu = new JPopupMenu(); setComponentPopupMenu(this, informationMenu); } { ListModel openFileListModel = new DefaultListModel(); openFileList = new JList(); openFileList.setModel(openFileListModel); getContentPane().add(openFileList, BorderLayout.NORTH); openFileList.setPreferredSize(new java.awt.Dimension(663, 281)); openFileList.addListSelectionListener(new ListSelectionListener() { public void valueChanged(ListSelectionEvent evt) { swingUtil.invokeAction("openFileList.valueChanged", evt); } }); openFileList.addMouseMotionListener(new MouseMotionAdapter() { public void mouseMoved(MouseEvent evt) { swingUtil.invokeAction("openFileList.mouseMoved", evt); } }); openFileList.addKeyListener(new KeyAdapter() { public void keyPressed(KeyEvent evt) { swingUtil.invokeAction("openFileList.keyPressed", evt); } }); } { jPanel1 = new JPanel(); GroupLayout jPanel1Layout = new GroupLayout((JComponent) jPanel1); jPanel1.setLayout(jPanel1Layout); getContentPane().add(jPanel1, BorderLayout.SOUTH); jPanel1.setPreferredSize(new java.awt.Dimension(478, 35)); { openSelected = new JButton(); openSelected.setText("open all"); openSelected.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { swingUtil.invokeAction("openSelected.actionPerformed", evt); } }); } jPanel1Layout.setHorizontalGroup(jPanel1Layout.createSequentialGroup().addContainerGap(178, 178) .addComponent(openSelected, GroupLayout.PREFERRED_SIZE, 126, GroupLayout.PREFERRED_SIZE) .addContainerGap(174, Short.MAX_VALUE)); jPanel1Layout.setVerticalGroup(jPanel1Layout.createSequentialGroup().addGap(7) .addComponent(openSelected, GroupLayout.PREFERRED_SIZE, 22, GroupLayout.PREFERRED_SIZE) .addGap(0, 6, Short.MAX_VALUE)); } { informationMenu = new JPopupMenu(); } this.setSize(486, 350); this.setLocationRelativeTo(null); //xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx // ?tooltip //xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx int initialDelay = ToolTipManager.sharedInstance().getInitialDelay(); ToolTipManager.sharedInstance().setInitialDelay(0); //xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx // ?tooltip //xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx swingUtil.addAction("openFileList.mouseClicked", new Action() { public void action(EventObject evt) throws Exception { DefaultListModel model = (DefaultListModel) openFileList.getModel(); int pos = openFileList.getLeadSelectionIndex(); if (pos == -1) { return; } setOpenFileListToolTip(); MouseEvent eeev = (MouseEvent) evt; if (eeev.getClickCount() != 2) { return; } MFile file = (MFile) model.elementAt(pos); openSource(file.file); } }); final JListUtil jlistUtil = JListUtil.newInstance(openFileList); swingUtil.addAction("openFileList.keyPressed", new Action() { public void action(EventObject evt) throws Exception { jlistUtil.defaultJListKeyPressed((KeyEvent) evt); setOpenFileListToolTip(); } }); swingUtil.addAction("openSelected.actionPerformed", new Action() { public void action(EventObject evt) throws Exception { DefaultListModel model = (DefaultListModel) openFileList.getModel(); for (Enumeration<?> enu = model.elements(); enu.hasMoreElements();) { MFile file = (MFile) enu.nextElement(); openSource(file.file); } } }); swingUtil.addAction("openFileList.mouseMoved", new Action() { public void action(EventObject evt) throws Exception { setOpenFileListToolTip(); } }); swingUtil.addAction("openFileList.valueChanged", new Action() { public void action(EventObject evt) throws Exception { System.out.println(evt); setOpenFileListToolTip(); } }); } catch (Exception e) { e.printStackTrace(); } }
From source file:com.mirth.connect.connectors.vm.ChannelWriter.java
public ChannelWriter() { parent = PlatformUI.MIRTH_FRAME;/*w ww. ja va 2s. c o m*/ initComponents(); channelIdField.setToolTipText("<html>The destination channel's unique global id.</html>"); channelIdField.getDocument().addDocumentListener(new DocumentListener() { @Override public void insertUpdate(DocumentEvent e) { updateField(); } @Override public void removeUpdate(DocumentEvent e) { updateField(); } @Override public void changedUpdate(DocumentEvent e) { updateField(); } }); class CustomTableCellEditor extends TextFieldCellEditor { @Override protected boolean valueChanged(String value) { if ((value.length() == 0 || checkUniqueProperty(value))) { return false; } parent.setSaveEnabled(true); return true; } protected boolean checkUniqueProperty(String property) { boolean exists = false; for (int rowIndex = 0; rowIndex < mapVariablesTable.getRowCount(); rowIndex++) { if (mapVariablesTable.getValueAt(rowIndex, 0) != null && ((String) mapVariablesTable.getValueAt(rowIndex, 0)).equalsIgnoreCase(property)) { exists = true; } } return exists; } } mapVariablesTable.getColumnModel().getColumn(0).setCellEditor(new CustomTableCellEditor()); mapVariablesTable.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); mapVariablesTable.setToolTipText( "The following map variables will be included in the source map of the destination channel's message."); mapVariablesTable.getSelectionModel().addListSelectionListener(new ListSelectionListener() { public void valueChanged(ListSelectionEvent evt) { if (mapVariablesTable.getRowCount() > 0) { deleteButton.setEnabled(true); } else { deleteButton.setEnabled(false); } } }); }
From source file:net.sf.profiler4j.console.ClassListPanel.java
/** * This method initializes classesTable/*w w w . j a va2s . c o m*/ * * @return javax.swing.JTable */ private JTable getClassesTable() { if (classesTable == null) { classesTable = new JTable(); classesTable.setSelectionMode(javax.swing.ListSelectionModel.MULTIPLE_INTERVAL_SELECTION); classesTable.setFont(new java.awt.Font("Tahoma", java.awt.Font.PLAIN, 12)); classesTable.setModel(getClassListTableModel()); classesTable.setRowHeight(20); classesTable.getSelectionModel().addListSelectionListener(new ListSelectionListener() { public void valueChanged(ListSelectionEvent e) { if (classesTable.getSelectedRowCount() > 0) { addAsRuleButton.setEnabled(true); } else { addAsRuleButton.setEnabled(false); } } }); TableColumn c = classesTable.getColumnModel().getColumn(0); c.setMinWidth(50); c.setMaxWidth(50); c = classesTable.getColumnModel().getColumn(1); c.setMinWidth(300); c.setCellRenderer(new DefaultTableCellRenderer() { Font f1 = new Font("Tahoma", java.awt.Font.PLAIN, 12); Font f2 = new Font("Tahoma", java.awt.Font.BOLD, 12); @Override public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) { super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column); if (isSelected) { setFont(f2); } else { setFont(f1); } if (classListTableModel.getRow(row).info.isInstrumented()) { if (isSelected) { setForeground(Color.YELLOW); setBackground(Color.BLUE); } else { setBackground(Color.decode("#bbffbb")); setForeground(Color.BLACK); } } else { if (isSelected) { setForeground(Color.WHITE); setBackground(Color.BLUE); } else { setBackground(Color.WHITE); setForeground(Color.BLACK); } } setBorder(BorderFactory.createEmptyBorder(0, 4, 0, 4)); return this; } }); } return classesTable; }
From source file:com.anrisoftware.prefdialog.fields.listbox.AbstractListBoxField.java
/** * @see AbstractTitleField#AbstractTitleField(java.awt.Component, Object, * String)/*from w w w . j ava2s .co m*/ * * @param annotationType * the annotation {@link Class} type of the specific combo box * field. The annotation must have the following attributes: * <ul> * <li>model</li> * <li>modelClass</li> * <li>renderer</li> * <li>rendererClass</li> * <li>elements</li> * </ul> */ protected AbstractListBoxField(Class<? extends Annotation> annotationType, ComponentType component, Object parentObject, String fieldName) { super(component, parentObject, fieldName); this.annotationType = annotationType; this.dataListener = lockedListSelectionListener(new ListSelectionListener() { @Override public void valueChanged(ListSelectionEvent e) { try { setSelectedIndices(getComponent().getSelectedIndices()); } catch (PropertyVetoException e1) { } } }); }
From source file:hr.fer.zemris.vhdllab.platform.ui.wizard.support.PortWizardPage.java
@SuppressWarnings("unchecked") @Override//www . j a va 2s .co m protected JComponent createControl() { model = new BeanTableModel(Port.class, new ArrayList<Port>(), getMessageSource()) { private static final long serialVersionUID = 1L; @Override protected String[] createColumnPropertyNames() { return new String[] { "name", "direction", "from", "to" }; } @Override protected Class[] createColumnClasses() { return new Class[] { String.class, PortDirection.class, Integer.class, Integer.class }; } }; reporter = new PortValidationReporter(model, this, minimumPortCount, maximumPortCount); table = new JTable(model); table.setCellSelectionEnabled(true); table.getSelectionModel().addListSelectionListener(new ListSelectionListener() { @Override public void valueChanged(ListSelectionEvent e) { removeAction.setEnabled(!table.getSelectionModel().isSelectionEmpty()); } }); final JComboBox inComboBox = new JComboBox(new EnumComboBoxModel(PortDirection.class)); JTextField portName = new JTextField(); new ComboBoxAutoCompletion(inComboBox); table.getColumnModel().getColumn(0).setPreferredWidth(7); table.getColumnModel().getColumn(1).setCellEditor(new DefaultCellEditor(portName)); table.getColumnModel().getColumn(1).setPreferredWidth(120); table.getColumnModel().getColumn(2).setCellEditor(new ComboBoxCellEditor(inComboBox)); table.getColumnModel().getColumn(3).setCellEditor(new NumberEditorExt()); table.getColumnModel().getColumn(4).setCellEditor(new NumberEditorExt()); table.setPreferredScrollableViewportSize(new Dimension(300, 200)); table.addKeyListener(new EditComboBoxKeyHandler()); JScrollPane scrollPane = new JScrollPane(table); JPanel control = new JPanel(new BorderLayout()); control.add(createButtons(), BorderLayout.NORTH); control.add(scrollPane, BorderLayout.CENTER); return control; }
From source file:fr.free.hd.servers.gui.FaceView.java
@Override protected JComponent createControl() { final GridBagLayout layout = new GridBagLayout(); final JPanel view = new JPanel(layout); //Face list//ww w .ja v a 2 s .com GridBagConstraints c = new GridBagConstraints(); c.gridx = 0; c.gridy = 0; c.gridheight = 3; c.weighty = 0.75; c.weightx = 0.15; c.fill = GridBagConstraints.BOTH; final JList facesList = CreateList(); facesList.getSelectionModel().addListSelectionListener(new ListSelectionListener() { @Override public void valueChanged(ListSelectionEvent e) { if (e.getValueIsAdjusting() == false) { if (facesList.getSelectedIndex() != -1) { face = (Face) facesList.getSelectedValue(); updateLabel(); } else { } } } }); view.add(facesList, c); // New button c = new GridBagConstraints(); c.gridx = 0; c.gridy = 3; c.fill = GridBagConstraints.BOTH; JButton btnNew = new JButton("Nouveau"); btnNew.setEnabled(false); view.add(btnNew, c); // Save button c = new GridBagConstraints(); c.gridx = 0; c.gridy = 4; c.fill = GridBagConstraints.BOTH; JButton btnModified = new JButton("Modifier"); btnModified.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { facesDAO.storeFace(face); } }); view.add(btnModified, c); //Draw Face c = new GridBagConstraints(); c.gridx = 1; c.gridy = 0; c.gridheight = 5; c.gridwidth = 1; c.fill = GridBagConstraints.BOTH; c.weightx = 0.60; lblFace = new JLabel(); view.add(lblFace, c); //Hand Panel c = new GridBagConstraints(); c.gridx = 2; c.gridy = 0; c.weightx = 0.15; c.fill = GridBagConstraints.BOTH; JPanel pnlHand = createPosition(); view.add(pnlHand, c); //Mouth Panel c = new GridBagConstraints(); c.gridx = 2; c.gridy = 1; c.weightx = 0.15; c.fill = GridBagConstraints.BOTH; JPanel pnlKind = createKind(); view.add(pnlKind, c); //Mouth Panel c = new GridBagConstraints(); c.gridx = 2; c.gridy = 2; c.weightx = 0.15; c.fill = GridBagConstraints.BOTH; JPanel pnlMouth = createMouth(); view.add(pnlMouth, c); // Picture filename c = new GridBagConstraints(); c.gridx = 0; c.gridy = 5; c.gridwidth = 2; c.fill = GridBagConstraints.BOTH; JTextField txtPath = new JTextField(); view.add(txtPath, c); //Browse Button c = new GridBagConstraints(); c.gridx = 2; c.gridy = 5; c.fill = GridBagConstraints.BOTH; JButton btnBrownse = new JButton("Browse"); view.add(btnBrownse, c); //Select default face if (facesList.getModel().getSize() > 0) { facesList.setSelectedIndex(0); position = HandPositionEnum.HAND_POSITION_MENTON; kind = HandKeyEnum.HAND_KEY_2V; } return view; }
From source file:com.k42b3.aletheia.response.html.Images.java
public Images() { super();/*from www.j av a2s .c om*/ executorService = Executors.newFixedThreadPool(6); // settings this.setTitle("Images"); this.setLocation(100, 100); this.setPreferredSize(new Dimension(360, 600)); this.setMinimumSize(this.getSize()); this.setResizable(false); this.setLayout(new BorderLayout()); // list model = new DefaultListModel<URL>(); list = new JList<URL>(model); list.addListSelectionListener(new ListSelectionListener() { public void valueChanged(ListSelectionEvent e) { btnDownload.setEnabled(list.getSelectedIndex() != -1); } }); list.setCellRenderer(new ImageCellRenderer()); scp = new JScrollPane(list); scp.setBorder(new EmptyBorder(4, 4, 4, 4)); this.add(scp, BorderLayout.CENTER); // buttons JPanel panelButtons = new JPanel(); FlowLayout fl = new FlowLayout(); fl.setAlignment(FlowLayout.LEFT); panelButtons.setLayout(fl); btnDownload = new JButton("Download"); btnDownload.addActionListener(new DownloadHandler()); btnDownload.setEnabled(false); JButton btnCancel = new JButton("Cancel"); btnCancel.addActionListener(new CloseHandler()); lblInfo = new JLabel(""); panelButtons.add(btnDownload); panelButtons.add(btnCancel); panelButtons.add(lblInfo); this.add(panelButtons, BorderLayout.SOUTH); this.pack(); }
From source file:com.compomics.cell_coord.gui.controller.computation.ComputationMainController.java
/** * Initialize some GUI components./*from w w w . java 2 s .c o m*/ */ private void initMainView() { // format the tables JTableHeader samplesHeader = getMainFrame().getSamplesTable().getTableHeader(); samplesHeader.setBackground(GuiUtils.getHeaderColor()); samplesHeader.setFont(GuiUtils.getHeaderFont()); samplesHeader.setReorderingAllowed(false); JTableHeader tracksHeader = getMainFrame().getTracksTable().getTableHeader(); tracksHeader.setBackground(GuiUtils.getHeaderColor()); tracksHeader.setFont(GuiUtils.getHeaderFont()); tracksHeader.setReorderingAllowed(false); getMainFrame().getSamplesTable().setRowSelectionAllowed(true); getMainFrame().getSamplesTable().setColumnSelectionAllowed(false); getMainFrame().getSamplesTable().setSelectionMode(ListSelectionModel.SINGLE_SELECTION); getMainFrame().getTracksTable().setRowSelectionAllowed(true); getMainFrame().getTracksTable().setColumnSelectionAllowed(false); getMainFrame().getTracksTable().setSelectionMode(ListSelectionModel.SINGLE_SELECTION); // if you click on a sample, the relative tracks are shown in another table getMainFrame().getSamplesTable().getSelectionModel().addListSelectionListener(new ListSelectionListener() { @Override public void valueChanged(ListSelectionEvent e) { if (!e.getValueIsAdjusting()) { int selectedRow = getMainFrame().getSamplesTable().getSelectedRow(); if (selectedRow != -1) { Sample selectedSample = getSamples().get(selectedRow); showTracksInTable(selectedSample); computationDataController.computeSample(selectedSample); // call child controller to show sample data in table computationDataController.showSampleData(selectedSample); // call child controller to plot whatever we need to plot } } } }); // if you click on a track, the relative spots are shown in another table getMainFrame().getTracksTable().getSelectionModel().addListSelectionListener(new ListSelectionListener() { @Override public void valueChanged(ListSelectionEvent e) { if (!e.getValueIsAdjusting()) { Sample selectedSample = getSamples().get(getMainFrame().getSamplesTable().getSelectedRow()); int selectedRow = getMainFrame().getTracksTable().getSelectedRow(); if (selectedRow != -1) { Track selectedTrack = selectedSample.getTracks().get(selectedRow); // call child controller to show track data in table computationDataController.showStepData(selectedTrack); computationDataController.showTrackData(selectedTrack); // call child controller to plot whatever we need to plot computationDataController.plotStepData(selectedTrack); computationDataController.plotTrackData(selectedTrack); } } } }); }