public NodeSelectionDialog(Frame owner, NodeLibrary library, NodeLibraryManager manager) { super(owner, "New Node", true); getRootPane().putClientProperty("Window.style", "small"); JPanel panel = new JPanel(new BorderLayout()); this.library = library; this.manager = manager; filteredNodeListModel = new FilteredNodeListModel(library, manager); searchField = new JTextField(); searchField.putClientProperty("JTextField.variant", "search"); EscapeListener escapeListener = new EscapeListener(); searchField.addKeyListener(escapeListener); ArrowKeysListener arrowKeysListener = new ArrowKeysListener(); searchField.addKeyListener(arrowKeysListener); SearchFieldChangeListener searchFieldChangeListener = new SearchFieldChangeListener(); searchField.getDocument().addDocumentListener(searchFieldChangeListener); nodeList = new JList(filteredNodeListModel); DoubleClickListener doubleClickListener = new DoubleClickListener(); nodeList.addMouseListener(doubleClickListener); nodeList.addKeyListener(escapeListener); nodeList.addKeyListener(arrowKeysListener); nodeList.setSelectedIndex(0); nodeList.setCellRenderer(new NodeRenderer()); JScrollPane nodeScroll = new JScrollPane( nodeList, JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED, JScrollPane.HORIZONTAL_SCROLLBAR_NEVER); nodeScroll.setBorder(null); panel.add(searchField, BorderLayout.NORTH); panel.add(nodeScroll, BorderLayout.CENTER); setContentPane(panel); setSize(500, 400); SwingUtils.centerOnScreen(this); }
/** EdiDialog constructor comment. */ public void show() { getContentPane().setLayout(new java.awt.BorderLayout()); JScrollPane center = new JScrollPane(); getContentPane().add(center, java.awt.BorderLayout.CENTER); list = new JList(); list.setBackground(parentWindow.getBackground()); DefaultListModel model = new DefaultListModel(); list.setModel(model); for (int i = 0; i < DesignFrame.processingElements.length; i++) { model.addElement((String) DesignFrame.processingElements[i][0]); } // list.ActionListener((ActionListener) this); center.setViewportView(list); JPanel down = new JPanel(); getContentPane().add(down, java.awt.BorderLayout.SOUTH); down.setLayout(new java.awt.FlowLayout(java.awt.FlowLayout.RIGHT, 2, 2)); bOK = new JButton("OK"); bOK.addActionListener(this); bAdd = new JButton("Add"); bAdd.addActionListener(this); bCancel = new JButton("Cancel"); bCancel.addActionListener(this); down.add(bOK); down.add(bAdd); down.add(bCancel); pack(); setSize(getWidth(), getHeight() * 2); list.addKeyListener(this); super.show(); }
public FPGACommanderListWindow( String Title, Color fg, boolean count, FPGACommanderListModel model) { super((count) ? Title + " (0)" : Title); this.Title = Title; setResizable(true); setAlwaysOnTop(false); setDefaultCloseOperation(JFrame.HIDE_ON_CLOSE); Color bg = Color.black; textArea.setBackground(bg); textArea.setForeground(fg); textArea.setSelectionBackground(fg); textArea.setSelectionForeground(bg); textArea.setFont(new Font("monospaced", Font.PLAIN, FontSize)); textArea.setModel(model); textArea.setCellRenderer(model.getMyRenderer(count)); textArea.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); model.addListDataListener(this); JScrollPane textMessages = new JScrollPane(textArea); textMessages.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED); textMessages.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED); add(textMessages); setLocationRelativeTo(null); textArea.addKeyListener(this); pack(); addWindowListener(this); this.count = count; this.model = model; }
/** Constructor. */ public TilePatternsView() { super(); tilePatternIcons = new ArrayList<TilePatternIcon>(); setLayout(new BoxLayout(this, BoxLayout.Y_AXIS)); setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5)); // tileset properties // the tile pattern list // view of the current tile pattern // tileset properties tilesetPropertiesView = new TilesetPropertiesView(); tilesetPropertiesView.setMaximumSize(new Dimension(Integer.MAX_VALUE, 120)); tilesetPropertiesView.setAlignmentX(Component.LEFT_ALIGNMENT); // list tilePatternsListModel = new TilePatternsListModel(); tilePatternsList = new JList(tilePatternsListModel); tilePatternsList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); tilePatternsList.setLayoutOrientation(JList.HORIZONTAL_WRAP); tilePatternsList.setVisibleRowCount(-1); // make the rows as wide as possible tilePatternsList .getSelectionModel() .addListSelectionListener(new TilePatternListSelectionListener()); tilePatternsList.setCellRenderer(new TilePatternListRenderer()); tilePatternsList.addKeyListener( new KeyAdapter() { public void keyPressed(KeyEvent keyEvent) { if (keyEvent.getKeyCode() == KeyEvent.VK_DELETE) { if (tileset != null && tileset.getSelectedTilePattern() != null) { tileset.removeTilePattern(); } } } }); JScrollPane listScroller = new JScrollPane(tilePatternsList); listScroller.setMaximumSize(new Dimension(Integer.MAX_VALUE, Integer.MAX_VALUE)); listScroller.setAlignmentX(Component.LEFT_ALIGNMENT); // tile view tilePatternView = new TilePatternView(); tilePatternView.setMaximumSize(new Dimension(Integer.MAX_VALUE, 300)); tilePatternView.setAlignmentX(Component.LEFT_ALIGNMENT); add(tilesetPropertiesView); add(Box.createRigidArea(new Dimension(0, 5))); add(listScroller); add(Box.createRigidArea(new Dimension(0, 5))); add(tilePatternView); }
/** * Creates the area in which the tests that will be run are listed. * * @param testInstantiator * @return */ public static JList createListOfTestsToBeRunArea( TestInstantiatorDynamic testInstantiator, JPopupMenu popup, final ActionListener al) { JList listOfTestsToBeRun = new TestClassList(TestClassList.TestClassListToolTipType.DESCRIPTION); listOfTestsToBeRun.setToolTipText(""); listOfTestsToBeRun.setTransferHandler(new TestsTransferHandler()); listOfTestsToBeRun.setComponentPopupMenu(popup); // // Prevents the user from selecting multiple intervals. Removing // multiple intervals from the list does not work properly in // ActionExecution.removeSelectedTests and I don't see why, so I do // not allow selecting like that it here. // listOfTestsToBeRun.setSelectionMode(ListSelectionModel.SINGLE_INTERVAL_SELECTION); listOfTestsToBeRun.setCellRenderer(new TestCaseCellRenderer()); listOfTestsToBeRun.addKeyListener( new KeyListener() { @Override public void keyPressed(KeyEvent arg0) { // Backspace or delete button can be used to remove // selected tests. // boolean removeTestsKeyPressed = (arg0.getKeyCode() == KeyEvent.VK_DELETE) || (arg0.getKeyCode() == KeyEvent.VK_BACK_SPACE); if (removeTestsKeyPressed) { al.actionPerformed(new ActionEvent(this, 0, Constants.REMOVE_SELECTED_TESTS)); } } @Override public void keyReleased(KeyEvent arg0) {} @Override public void keyTyped(KeyEvent arg0) {} }); DropTarget dt = new DropTarget( listOfTestsToBeRun, new ListOfTestsToBeRunDropListener(listOfTestsToBeRun, testInstantiator)); return listOfTestsToBeRun; }
public hList() { setPreferredSize(new Dimension(100, 100)); list = new JList<T>() { @Override public JToolTip createToolTip() { return hList.this.createToolTip(); } @Override public String getToolTipText(MouseEvent event) { return hList.this.getToolTipText(event); } @Override public String getToolTipText() { return hList.this.getToolTipText(); } }; list.setToolTipText(",jmn"); setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS); setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED); getViewport().add(list); model = new DefaultListModel<T>(); list.setModel(model); list.addMouseListener( new MouseAdapter() { @Override public void mouseReleased(MouseEvent e) { fireChanged(); } }); list.addKeyListener( new KeyAdapter() { @Override public void keyPressed(KeyEvent e) { if (e.getKeyCode() == KeyEvent.VK_DOWN || e.getKeyCode() == KeyEvent.VK_UP) { fireChanged(); } } }); }
@Override public synchronized void addKeyListener(KeyListener l) { list.addKeyListener(l); }
private JList getInfoRouteJList() { if (infoRouteJList == null) { DefaultListModel defaultListModel = new DefaultListModel(); if (this.infoRoutesStretchBeansCollection != null && !this.infoRoutesStretchBeansCollection.isEmpty()) { Iterator<InfoRouteStretchBean> it = this.infoRoutesStretchBeansCollection.iterator(); while (it.hasNext()) { defaultListModel.addElement(it.next()); } } infoRouteJList = new JList(defaultListModel); infoRouteJList.setCellRenderer(new InfoRouteListRenderer()); infoRouteJList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); infoRouteJList.addMouseMotionListener( new MouseMotionListener() { @Override public void mouseDragged(MouseEvent e) {} @Override public void mouseMoved(MouseEvent e) { // Like Mouse Over onInfoRouteListMosueOver(e.getPoint()); } }); infoRouteJList.addMouseListener( new MouseListener() { @Override public void mouseClicked(MouseEvent e) { // On Mouse Click onInfoRouteListeMouseClicked(); } @Override public void mouseEntered(MouseEvent e) {} @Override public void mouseExited(MouseEvent e) {} @Override public void mousePressed(MouseEvent e) {} @Override public void mouseReleased(MouseEvent e) {} }); infoRouteJList.addKeyListener( new KeyListener() { @Override public void keyTyped(KeyEvent e) {} @Override public void keyReleased(KeyEvent e) {} @Override public void keyPressed(KeyEvent e) { if (e.getKeyCode() == KeyEvent.VK_ENTER) { onInfoRouteListEnterKeyPressedDo(); } } }); } return infoRouteJList; }
private void showCompletion() { try { int caretPosition = editorTextArea.getCaretPosition(); int wordStart = getWordStart(); CompletionCandidate[] words = getFilteredWords(wordStart, editorTextArea.getText(wordStart, caretPosition - wordStart)); if (words.length == 0) { return; } final JPopupMenu w = new JPopupMenu(); final JList jList = new JList(words); jList.setCellRenderer( new DefaultListCellRenderer() { private ImageIcon tableIcon = new ImageIcon( getClass().getResource("/org/jooq/debug/console/resources/Table16.png")); private ImageIcon tableColumnIcon = new ImageIcon( getClass().getResource("/org/jooq/debug/console/resources/TableColumn16.png")); private ImageIcon sqlIcon = new ImageIcon( getClass().getResource("/org/jooq/debug/console/resources/SQL16.png")); @Override public Component getListCellRendererComponent( JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) { Component c = super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus); if (c instanceof JLabel) { Icon icon; switch (((CompletionCandidate) value).getKeyWordType()) { case TABLE: icon = tableIcon; break; case TABLE_COlUMN: icon = tableColumnIcon; break; default: icon = sqlIcon; break; } ((JLabel) c).setIcon(icon); } return c; } }); jList.setSelectedIndex(0); jList.addKeyListener( new KeyAdapter() { @Override public void keyPressed(KeyEvent e) { switch (e.getKeyCode()) { case KeyEvent.VK_PAGE_UP: case KeyEvent.VK_PAGE_DOWN: case KeyEvent.VK_UP: case KeyEvent.VK_DOWN: case KeyEvent.VK_HOME: case KeyEvent.VK_END: return; case KeyEvent.VK_ESCAPE: w.setVisible(false); return; case KeyEvent.VK_ENTER: editorTextArea.replaceRange( ((CompletionCandidate) jList.getSelectedValue()).toString(), getWordStart(), editorTextArea.getCaretPosition()); w.setVisible(false); return; } editorTextArea.dispatchEvent( new KeyEvent( editorTextArea, e.getID(), e.getWhen(), e.getModifiers(), e.getKeyCode(), e.getKeyChar(), e.getKeyLocation())); if (e.getKeyChar() != KeyEvent.CHAR_UNDEFINED || e.getKeyCode() == KeyEvent.VK_LEFT || e.getKeyCode() == KeyEvent.VK_RIGHT) { adjustListContent(); } } @Override public void keyReleased(KeyEvent e) { switch (e.getKeyCode()) { case KeyEvent.VK_PAGE_UP: case KeyEvent.VK_PAGE_DOWN: case KeyEvent.VK_UP: case KeyEvent.VK_DOWN: case KeyEvent.VK_HOME: case KeyEvent.VK_END: case KeyEvent.VK_ESCAPE: case KeyEvent.VK_ENTER: return; } editorTextArea.dispatchEvent( new KeyEvent( editorTextArea, e.getID(), e.getWhen(), e.getModifiers(), e.getKeyCode(), e.getKeyChar(), e.getKeyLocation())); if (e.getKeyChar() != KeyEvent.CHAR_UNDEFINED || e.getKeyCode() == KeyEvent.VK_LEFT || e.getKeyCode() == KeyEvent.VK_RIGHT) { adjustListContent(); } } @Override public void keyTyped(KeyEvent e) { switch (e.getKeyCode()) { case KeyEvent.VK_PAGE_UP: case KeyEvent.VK_PAGE_DOWN: case KeyEvent.VK_UP: case KeyEvent.VK_DOWN: case KeyEvent.VK_HOME: case KeyEvent.VK_END: case KeyEvent.VK_ESCAPE: case KeyEvent.VK_ENTER: return; } editorTextArea.dispatchEvent( new KeyEvent( editorTextArea, e.getID(), e.getWhen(), e.getModifiers(), e.getKeyCode(), e.getKeyChar(), e.getKeyLocation())); if (e.getKeyChar() != KeyEvent.CHAR_UNDEFINED || e.getKeyCode() == KeyEvent.VK_LEFT || e.getKeyCode() == KeyEvent.VK_RIGHT) { adjustListContent(); } } private void adjustListContent() { try { int wordStart = getWordStart(); CompletionCandidate[] words = getFilteredWords( wordStart, editorTextArea.getText( wordStart, editorTextArea.getCaretPosition() - wordStart)); if (words.length == 0) { w.setVisible(false); return; } jList.setListData(words); jList.setSelectedIndex(0); } catch (BadLocationException e) { e.printStackTrace(); } } }); jList.addMouseListener( new MouseAdapter() { @Override public void mousePressed(MouseEvent e) { if (e.getButton() == MouseEvent.BUTTON1 && e.getClickCount() == 2) { editorTextArea.replaceRange( ((CompletionCandidate) jList.getSelectedValue()).toString(), getWordStart(), editorTextArea.getCaretPosition()); w.setVisible(false); } } }); w.add(new JScrollPane(jList), BorderLayout.CENTER); w.setPreferredSize(new Dimension(200, 200)); Rectangle position = editorTextArea.modelToView(caretPosition); w.show(editorTextArea, position.x + position.width, position.y + position.height); jList.requestFocus(); } catch (BadLocationException e) { e.printStackTrace(); } }
private void jbInit() throws Exception { // Leemos la conexion // // con = getDBConnection(); GeopistaGeneradorListadosConexionBD geopistaListados = new GeopistaGeneradorListadosConexionBD(); this.setLayout(null); this.setSize(new Dimension(854, 500)); jPanel1.setLayout(null); jPanel1.setBorder(BorderFactory.createEtchedBorder(EtchedBorder.RAISED)); lblDatosGenerales.setText(aplicacion.getI18nString("generador.app.reports.datos.generales")); lblModulo.setText(aplicacion.getI18nString("generador.app.reports.modulo")); lblCapa.setText(aplicacion.getI18nString("generador.app.reports.capa")); // Cargamos la lista de capas ArrayList capas = geopistaListados.capasGeopista(); Iterator i = capas.iterator(); lblDatosGenerales.setBounds(new Rectangle(135, 5, 185, 20)); lblModulo.setBounds(new Rectangle(135, 23, 60, 25)); lblCapa.setBounds(new Rectangle(135, 50, 45, 30)); jPanel1.setBounds(new Rectangle(10, 15, 750, 500)); jSeparator1.setBounds(new Rectangle(0, 135, 735, 5)); while (i.hasNext()) { modeloList.addElement(i.next()); } // Creamos la lista con el modelo anteriormente definido // -- jPanel1.setSize(new Dimension(750, 600)); cmbModulos.setBackground(new Color(254, 255, 255)); cmbModulos.setBounds(new Rectangle(215, 25, 520, 20)); lstCapas.setSelectionModel(listSelectionModel1); lblTitulo.setText(aplicacion.getI18nString("informe.datos.seleccion.titulo.fichero")); lblTitulo.setBounds(new Rectangle(140, 215, 95, 15)); txtTituloInforme.setBounds(new Rectangle(140, 230, 595, 20)); lstCapas.addKeyListener( new java.awt.event.KeyAdapter() { public void keyReleased(java.awt.event.KeyEvent e) { String cadena = (String) lstCapas.getSelectedValue(); lstCapas.ensureIndexIsVisible(lstCapas.getSelectedIndex()); lstCapas.setSelectedValue((String) cadena, true); } }); lstCapas.addMouseListener( new MouseListener() { public void mouseClicked(MouseEvent e) { wizardContext.inputChanged(); } public void mousePressed(MouseEvent e) {} public void mouseReleased(MouseEvent e) {} public void mouseEntered(MouseEvent e) {} { } public void mouseExited(MouseEvent e) {} }); lblDescripcion.setText(aplicacion.getI18nString("generador.app.reports.descripcion.informe")); lblDescripcion.setBounds(new Rectangle(140, 255, 95, 20)); txtDescripcion.setBounds(new Rectangle(140, 280, 595, 95)); lblOrientacion.setText(aplicacion.getI18nString("generador.app.reports.orientacion.informe")); lblOrientacion.setBounds(new Rectangle(135, 178, 85, 25)); lblNombreFichero.setText(aplicacion.getI18nString("generador.app.reports.nombre.fichero")); lblNombreFichero.setBounds(new Rectangle(135, 145, 120, 30)); txtNombreFichero.setBounds(new Rectangle(215, 150, 520, 20)); // hb.enableHelpKey(this,"encabezado",hs); // Ponemos a mano los Módulos , prueba cmbModulos.addItem( (String) aplicacion.getI18nString("generador.app.reports.modulo.planeamiento")); cmbModulos.addItem(aplicacion.getI18nString("generador.app.reports.modulo.catastro")); cmbModulos.addItem(aplicacion.getI18nString("generador.app.reports.modulo.informacion")); cmbModulos.addItem(aplicacion.getI18nString("generador.app.reports.modulo.patrimonio")); cmbModulos.addItem(aplicacion.getI18nString("generador.app.reports.modulo.infraestructuras")); // Ponemos las explicaciones de las secciones /* lblExplicacionDatosInformes.setText(aplicacion.getI18nString("informe.datos.generales.explicacion.comentarios")); txtTituloInforme.setToolTipText(aplicacion.getI18nString("informe.datos.generales.explicacion.titulo.fichero")); txtDescripcion.setToolTipText(aplicacion.getI18nString("informe.datos.generales.explicacion.detalle")); txtNombreFichero.setToolTipText(aplicacion.getI18nString("informe.datos.generales.explicacion.nombre.fichero")); lblUbicacion.setText(aplicacion.getI18nString("informe.datos.generales.explicacion.ubicacion"));*/ // Ponemos a mano la horientacion optVertical.setText(aplicacion.getI18nString("generador.app.reports.orientacion.vertical")); optHorizontal.setText(aplicacion.getI18nString("generador.app.reports.orientacion.horizontal")); // Nuevo Listener para ver cuando cambia la caja de texto txtTituloInforme.addKeyListener( new KeyListener() { public void keyTyped(KeyEvent e) {} public void keyPressed(KeyEvent e) { wizardContext.inputChanged(); } public void keyReleased(KeyEvent e) {} }); optVertical.setText(aplicacion.getI18nString("generador.app.reports.orientacion.vertical")); optVertical.setSelected(true); optVertical.setBounds(new Rectangle(215, 180, 125, 20)); optVertical.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { optVertical_actionPerformed(e); } }); optHorizontal.setText(aplicacion.getI18nString("generador.app.reports.orientacion.horizontal")); optHorizontal.setBounds(new Rectangle(360, 180, 135, 20)); optHorizontal.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { optHorizontal_actionPerformed(e); } }); jScrollPane1.setBounds(new Rectangle(215, 60, 520, 70)); jSeparator2.setBounds(new Rectangle(5, 205, 730, 5)); lblImagen.setBounds(new Rectangle(15, 20, 110, 490)); lblImagen.setIcon(IconLoader.icon((String) blackboardInformes.get("tipoBanner"))); lblImagen.setBounds(new Rectangle(15, 20, 110, 490)); lblImagen.setBorder(BorderFactory.createLineBorder(Color.black, 1)); lblImagen.setBorder(BorderFactory.createLineBorder(Color.black, 1)); txtNombreFichero.addKeyListener( new KeyListener() { public void keyTyped(KeyEvent e) {} public void keyPressed(KeyEvent e) { wizardContext.inputChanged(); } public void keyReleased(KeyEvent e) {} }); jScrollPane1.getViewport().add(lstCapas, null); jPanel1.add(jSeparator2, null); jPanel1.add(jScrollPane1, null); jPanel1.add(optHorizontal, null); jPanel1.add(optVertical, null); jPanel1.add(txtTituloInforme, null); jPanel1.add(lblTitulo, null); jPanel1.add(txtDescripcion, null); jPanel1.add(lblDescripcion, null); jPanel1.add(lblOrientacion, null); jPanel1.add(txtNombreFichero, null); jPanel1.add(lblNombreFichero, null); jPanel1.add(jSeparator1, null); jPanel1.add(lblCapa, null); jPanel1.add(cmbModulos, null); jPanel1.add(lblModulo, null); jPanel1.add(lblDatosGenerales, null); this.add(lblImagen, null); this.add(jPanel1, null); // Cargamos las capas en la lista }
public LoadFromMemoryFrame(final MainFrame mainFrame) { setSize(800, 600); // setAlwaysOnTop(true); setTitle(translate("dialog.title")); this.mainFrame = mainFrame; addWindowListener( new WindowAdapter() { @Override public void windowClosing(WindowEvent e) { if (!mainFrame.isVisible()) { mainFrame.setVisible(true); } } }); model = new DefaultListModel<>(); resTableModel = new DefaultTableModel() { @Override public Class<?> getColumnClass(int columnIndex) { switch (columnIndex) { case 0: return Integer.class; case 1: return Integer.class; case 2: return String.class; case 3: return String.class; } return null; } @Override public boolean isCellEditable(int rowIndex, int columnIndex) { return false; } }; resTableModel.addColumn(translate("column.version")); resTableModel.addColumn(translate("column.fileSize")); resTableModel.addColumn(translate("column.pid")); resTableModel.addColumn(translate("column.processName")); tableRes = new JTable(resTableModel); TableRowSorter<DefaultTableModel> sorter = new TableRowSorter<>(resTableModel); tableRes.setRowSorter(sorter); list = new JList<>(model); list.addKeyListener( new KeyAdapter() { @Override public void keyPressed(KeyEvent e) { if (e.getKeyCode() == 10) { // Enter pressed selectProcess(); } } }); list.addMouseListener( new MouseAdapter() { @Override public void mouseClicked(MouseEvent e) { if (e.getClickCount() > 1) { selectProcess(); } } }); tableRes.addMouseListener( new MouseAdapter() { @Override public void mouseClicked(MouseEvent e) { if (e.getClickCount() > 1) { openSWF(); } } }); tableRes.addKeyListener( new KeyAdapter() { @Override public void keyPressed(KeyEvent e) { if (e.getKeyCode() == 10) { // Enter pressed openSWF(); } } }); list.setCellRenderer( new DefaultListCellRenderer() { @Override public Component getListCellRendererComponent( JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) { JLabel label = (JLabel) super.getListCellRendererComponent( list, value, index, isSelected, cellHasFocus); if (value instanceof com.jpexs.process.Process) { if (((com.jpexs.process.Process) value).getIcon() != null) { label.setIcon(new ImageIcon(((com.jpexs.process.Process) value).getIcon())); } } if (!isSelected) { label.setBackground(Color.white); } return label; } }); refreshList(); Container cnt = getContentPane(); cnt.setLayout(new BorderLayout()); JPanel leftPanel = new JPanel(new BorderLayout()); leftPanel.add(new JScrollPane(list), BorderLayout.CENTER); JPanel leftButtonsPanel = new JPanel(new FlowLayout()); JButton selectButton = new JButton(translate("button.select")); selectButton.setActionCommand(ACTION_SELECT_PROCESS); selectButton.addActionListener(this); JButton refreshButton = new JButton(translate("button.refresh")); refreshButton.setActionCommand(ACTION_REFRESH_PROCESS_LIST); refreshButton.addActionListener(this); leftButtonsPanel.add(selectButton); leftButtonsPanel.add(refreshButton); leftPanel.add(leftButtonsPanel, BorderLayout.SOUTH); JPanel rightPanel = new JPanel(new BorderLayout()); rightPanel.add(new JScrollPane(tableRes), BorderLayout.CENTER); JPanel rightButtonsPanel = new JPanel(new FlowLayout()); JButton openButton = new JButton(translate("button.open")); openButton.setActionCommand(ACTION_OPEN_SWF); openButton.addActionListener(this); JButton saveButton = new JButton(translate("button.save")); saveButton.setActionCommand(ACTION_SAVE); saveButton.addActionListener(this); rightButtonsPanel.add(openButton); rightButtonsPanel.add(saveButton); rightPanel.add(rightButtonsPanel, BorderLayout.SOUTH); JPanel statePanel = new JPanel(); statePanel.setLayout(new BoxLayout(statePanel, BoxLayout.Y_AXIS)); stateLabel = new JLabel(translate("noprocess")); statePanel.add(stateLabel); progress = new JProgressBar(0, 100); statePanel.add(progress); progress.setVisible(false); rightPanel.add(statePanel, BorderLayout.NORTH); cnt.add( new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, leftPanel, rightPanel), BorderLayout.CENTER); View.setWindowIcon(this); View.centerScreen(this); List<Image> images = new ArrayList<>(); images.add(View.loadImage("loadmemory16")); images.add(View.loadImage("loadmemory32")); setIconImages(images); }
public MainWindow2(Option option, File arg) { super(getDirectory(arg).getAbsolutePath()); final File dir = getDirectory(arg); setIconImage(PSystemVersion.getPlantumlSmallIcon2()); this.option = option; dirWatcher = new DirWatcher2(dir, option, getRegexpPattern(getExtensions())); Log.info("Showing MainWindow"); scrollPane = new JScrollPane(jList1); scrollPane.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10)); final JPanel south = new JPanel(new BorderLayout()); final JLabel labelFileExtensions = new JLabel("File extensions: "); extensions.setText(getExtensions()); labelFileExtensions.setBorder(BorderFactory.createEmptyBorder(6, 6, 6, 6)); CompoundBorder border = BorderFactory.createCompoundBorder( BorderFactory.createEmptyBorder(10, 10, 10, 10), BorderFactory.createEtchedBorder()); border = BorderFactory.createCompoundBorder(border, BorderFactory.createEmptyBorder(5, 5, 5, 5)); south.setBorder(border); south.add(labelFileExtensions, BorderLayout.WEST); south.add(extensions, BorderLayout.CENTER); south.add(changeDirButton, BorderLayout.SOUTH); getContentPane().add(south, BorderLayout.SOUTH); getContentPane().add(scrollPane, BorderLayout.CENTER); final MouseListener mouseListener = new MouseAdapter() { @Override public void mouseClicked(MouseEvent e) { try { if (e.getClickCount() == 2) { final int index = jList1.locationToIndex(e.getPoint()); doubleClick( (SimpleLine2) jList1.getModel().getElementAt(index), jList1.getModel(), index); } } catch (Exception ex) { } } }; jList1.addMouseListener(mouseListener); changeDirButton.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { System.err.println("Opening Directory Window"); displayDialogChangeDir(); } }); jList1.addKeyListener( new KeyAdapter() { @Override public void keyPressed(KeyEvent e) { if (e.getKeyCode() == KeyEvent.VK_ENTER) { final int index = jList1.getSelectedIndex(); doubleClick( (SimpleLine2) jList1.getModel().getElementAt(index), jList1.getModel(), index); } } }); extensions.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { changeExtensions(extensions.getText()); } }); extensions.addFocusListener( new FocusListener() { public void focusGained(FocusEvent e) {} public void focusLost(FocusEvent e) { changeExtensions(extensions.getText()); } }); final JMenuBar menuBar = new JMenuBar(); final JMenu mFile = new JMenu("File"); menuBar.add(mFile); setJMenuBar(menuBar); final JMenuItem sprite = new JMenuItem("Open Sprite Window"); mFile.add(sprite); sprite.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { new SpriteWindow(); } }); final JMenuItem about = new JMenuItem("About"); mFile.add(about); about.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { new AboutWindow(); } }); final JMenuItem exit = new JMenuItem("Exit"); mFile.add(exit); exit.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { System.exit(0); } }); setSize(640, 400); this.setLocationRelativeTo(this.getParent()); setVisible(true); setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); startTimer(); }
public EditProfileDialog(final Frame parent, final SkeinforgeGenerator parentGeneratorIn) { super(parent, true); parentGenerator = parentGeneratorIn; setTitle("Edit Profiles"); setLayout(new MigLayout("aligny, top, ins 5, fill")); editButton.setToolTipText("Click to edit this profile's properties."); deleteButton.setToolTipText("Click to remove this profile. Note that this can not be undone."); locateButton.setToolTipText( "Click to find the folder for this profile, e.g. to make backups or to share your settings."); duplicateButton.setToolTipText( "This will make a copy of the currently selected profile, with a new name that you provide."); // have to set this. Something wrong with the initial use of the // ListSelectionListener doneButton.setEnabled(false); editButton.setEnabled(false); locateButton.setEnabled(false); deleteButton.setEnabled(false); duplicateButton.setEnabled(false); profilePanel.setLayout(new MigLayout("top, ins 0, fill, flowy")); profilePanel.add(new JLabel("Select a Skeinforge profile:"), "split"); prefList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); prefList.addListSelectionListener( new ListSelectionListener() { public void valueChanged(ListSelectionEvent selectionEvent) { boolean selected = !((JList) selectionEvent.getSource()).isSelectionEmpty(); doneButton.setEnabled(selected); editButton.setEnabled(selected); locateButton.setEnabled(selected); deleteButton.setEnabled(selected); duplicateButton.setEnabled(selected); } }); // Add a listener for mouse clicks prefList.addMouseListener( new MouseAdapter() { public void mouseClicked(MouseEvent evt) { JList list = (JList) evt.getSource(); if (evt.getClickCount() == 2) { // Double-click generates with this profile int idx = list.locationToIndex(evt.getPoint()); Profile p = ProfileUtils.getListedProfile(list.getModel(), profiles, idx); Base.preferences.put("lastGeneratorProfileSelected", p.toString()); parentGenerator.configSuccess = true; parentGenerator.profile = p.getFullPath(); setVisible(false); } } }); loadList(prefList); profilePanel.add(new JScrollPane(prefList), "growx, growy"); prefList.addKeyListener( new KeyAdapter() { public void keyPressed(KeyEvent e) { Base.logger.fine("key pressed event: " + e); if (e.getKeyCode() == KeyEvent.VK_ENTER) { int idx = prefList.getSelectedIndex(); Base.logger.fine("idx=" + idx); Profile p = ProfileUtils.getListedProfile(prefList.getModel(), profiles, idx); Base.preferences.put("lastGeneratorProfileSelected", p.toString()); parentGenerator.configSuccess = true; parentGenerator.profile = p.getFullPath(); setVisible(false); } else if (e.getKeyCode() == KeyEvent.VK_ESCAPE) { setVisible(false); } } }); filterBox.addActionListener( new ActionListener() { @Override public void actionPerformed(ActionEvent arg0) { loadList(prefList); } }); profilePanel.add(filterBox, "growx, wrap"); profilePanel.add(editButton, "split, growx"); editButton.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { int idx = prefList.getSelectedIndex(); if (idx == -1) { JOptionPane.showMessageDialog(parent, "Select a profile to edit."); } else { Profile p = ProfileUtils.getListedProfile(prefList.getModel(), profiles, idx); parentGenerator.editProfile(p); } } }); profilePanel.add(duplicateButton, "split, growx"); duplicateButton.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { int idx = prefList.getSelectedIndex(); String newName = JOptionPane.showInputDialog(parent, "Name your new profile:"); if (newName != null) { Profile p = ProfileUtils.getListedProfile(prefList.getModel(), profiles, idx); Profile newp = parentGenerator.duplicateProfile(p, newName); loadList(prefList); // Select new profile if (newp != null) prefList.setSelectedValue(newp.toString(), true); pack(); } } }); profilePanel.add(locateButton, "split, growx"); locateButton.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { int idx = prefList.getSelectedIndex(); if (idx == -1) { } else { Profile p = ProfileUtils.getListedProfile(prefList.getModel(), profiles, idx); boolean result = new ProfileUtils().openFolder(p); Base.logger.log(Level.FINEST, "Opening directory for profile: " + result); } } }); profilePanel.add(deleteButton, "growx"); deleteButton.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { int idx = prefList.getSelectedIndex(); Profile p = ProfileUtils.getListedProfile(prefList.getModel(), profiles, idx); int userResponse = JOptionPane.showConfirmDialog( null, "Are you sure you want to delete profile " + p.toString() + "? This cannot be undone.", "Delete Profile", JOptionPane.YES_NO_OPTION); if (userResponse == JOptionPane.YES_OPTION) { boolean result = new ProfileUtils().delete(p); loadList(prefList); pack(); Base.logger.log(Level.INFO, "Profile " + p.getFullPath() + " deleted: " + result); } } }); add(profilePanel, "wrap, growx"); add(doneButton, "tag ok, split 2"); doneButton.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent arg0) { parentGenerator.configSuccess = false; setVisible(false); } }); }
private void setupList() { _listMouseObserver = new LibraryPlaylistsMouseObserver(); _listSelectionListener = new LibraryPlaylistsSelectionListener(); SortedListModel sortedModel = new SortedListModel( _model, SortOrder.ASCENDING, new Comparator<LibraryPlaylistsListCell>() { @Override public int compare(LibraryPlaylistsListCell o1, LibraryPlaylistsListCell o2) { if (o1 == _newPlaylistCell) { return -1; } if (o2 == _newPlaylistCell) { return 1; } return o1.getText().compareTo(o2.getText()); } }); _list = new LibraryIconList(sortedModel); _list.setFixedCellHeight(TableSettings.DEFAULT_TABLE_ROW_HEIGHT.getValue()); _list.setCellRenderer(new LibraryPlaylistsCellRenderer()); _list.addMouseListener(new DefaultMouseListener(_listMouseObserver)); _list.addListSelectionListener(_listSelectionListener); _list.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION); _list.setLayoutOrientation(JList.VERTICAL); _list.setPrototypeCellValue( new LibraryPlaylistsListCell( "test", "", GUIMediator.getThemeImage("playlist"), null, null)); _list.setVisibleRowCount(-1); _list.setDragEnabled(true); _list.setTransferHandler(new LibraryPlaylistsTransferHandler(_list)); ToolTipManager.sharedInstance().registerComponent(_list); _list.addKeyListener( new KeyAdapter() { @Override public void keyPressed(KeyEvent e) { list_keyPressed(e); } }); _list.addMouseListener( new MouseAdapter() { @Override public void mouseClicked(MouseEvent e) { if (e.getClickCount() > 1) { actionStartRename(); } } }); _textName = new JTextField(); ThemeMediator.fixKeyStrokes(_textName); UIDefaults defaults = new UIDefaults(); defaults.put("TextField.contentMargins", new InsetsUIResource(0, 4, 0, 4)); _textName.putClientProperty("Nimbus.Overrides.InheritDefaults", Boolean.TRUE); _textName.putClientProperty("Nimbus.Overrides", defaults); _textName.addKeyListener( new KeyAdapter() { @Override public void keyPressed(KeyEvent e) { textName_keyPressed(e); } }); _textName.setVisible(false); _list.add(_textName); }
public ConfigurationDialog(final Frame parent) { super(parent, true); setTitle("Choose a skeinforge profile"); setLayout(new MigLayout("aligny top")); editButton.setToolTipText("Click to edit this profile's properties."); locateButton.setToolTipText( "Click to find the folder for this profile, e.g. to make backups or to share your settings."); deleteButton.setToolTipText( "Click to remove this profile. Note that this can not be undone."); newButton.setToolTipText( "This will make a copy of the currently selected profile, with a new name that you provide."); // have to set this. Something wrong with the initial use of the // ListSelectionListener generate.setEnabled(false); editButton.setEnabled(false); locateButton.setEnabled(false); deleteButton.setEnabled(false); newButton.setEnabled(false); add(new JLabel("Select a printing profile:"), "wrap"); final JList prefList = new JList(); prefList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); prefList.addListSelectionListener( new ListSelectionListener() { public void valueChanged(ListSelectionEvent selectionEvent) { boolean selected = !((JList) selectionEvent.getSource()).isSelectionEmpty(); generate.setEnabled(selected); editButton.setEnabled(selected); locateButton.setEnabled(selected); deleteButton.setEnabled(selected); newButton.setEnabled(selected); } }); // Add a listener for mouse clicks prefList.addMouseListener( new MouseAdapter() { public void mouseClicked(MouseEvent evt) { JList list = (JList) evt.getSource(); if (evt.getClickCount() == 2) { // Double-click generates with this profile int idx = list.locationToIndex(evt.getPoint()); Profile p = (Profile) prefList.getModel().getElementAt(idx); Base.preferences.put("lastGeneratorProfileSelected", p.toString()); configSuccess = true; profile = p.getFullPath(); setVisible(false); } } }); loadList(prefList); add(prefList, "growy"); prefList.addKeyListener( new KeyAdapter() { public void keyPressed(KeyEvent e) { Base.logger.fine("key pressed event: " + e); if (e.getKeyCode() == KeyEvent.VK_ENTER) { int idx = prefList.getSelectedIndex(); Base.logger.fine("idx=" + idx); Profile p = (Profile) prefList.getModel().getElementAt(idx); Base.preferences.put("lastGeneratorProfileSelected", p.toString()); configSuccess = true; profile = p.getFullPath(); setVisible(false); } else if (e.getKeyCode() == KeyEvent.VK_ESCAPE) { setVisible(false); } } }); add(editButton, "split,flowy,growx"); editButton.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { int idx = prefList.getSelectedIndex(); if (idx == -1) { JOptionPane.showMessageDialog(parent, "Select a profile to edit."); } else { Profile p = (Profile) prefList.getModel().getElementAt(idx); editProfile(p); } } }); add(locateButton, "split,flowy,growx"); locateButton.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { int idx = prefList.getSelectedIndex(); if (idx == -1) { } else { Profile p = (Profile) prefList.getModel().getElementAt(idx); boolean result = new ProfileUtils().openFolder(p); Base.logger.log(Level.FINEST, "Opening directory for profile: " + result); } } }); add(newButton, "growx,flowy"); newButton.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { int idx = prefList.getSelectedIndex(); String newName = JOptionPane.showInputDialog(parent, "Name your new profile:"); if (newName != null) { File newProfDir = new File(getUserProfilesDir(), newName); Profile p = (Profile) prefList.getModel().getElementAt(idx); File oldProfDir = new File(p.getFullPath()); try { Base.copyDir(oldProfDir, newProfDir); Profile newProf = new Profile(newProfDir.getAbsolutePath()); editProfile(newProf); loadList(prefList); } catch (IOException ioe) { Base.logger.log(Level.SEVERE, "Couldn't copy directory", ioe); } } } }); add(deleteButton, "wrap,growx"); deleteButton.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { int idx = prefList.getSelectedIndex(); Profile p = (Profile) prefList.getModel().getElementAt(idx); boolean result = new ProfileUtils().delete(p); loadList(prefList); Base.logger.log(Level.INFO, "Profile " + p.getFullPath() + " deleted: " + result); } }); for (SkeinforgePreference preference : preferences) { add(preference.getUI(), "wrap"); } add(generate, "tag ok"); JButton cancel = new JButton("Cancel"); add(cancel, "tag cancel"); generate.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent arg0) { int idx = prefList.getSelectedIndex(); Profile p = (Profile) prefList.getModel().getElementAt(idx); Base.preferences.put("lastGeneratorProfileSelected", p.toString()); configSuccess = true; profile = p.getFullPath(); setVisible(false); SkeinforgeGenerator.setSelectedProfile(p.toString()); } }); cancel.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent arg0) { configSuccess = false; setVisible(false); } }); }
@SuppressWarnings("unchecked") private void showList() { LinkedList<String> ll = new LinkedList<String>(); LinkedList<String> ll2 = null; inJarTree = false; String s = listHead; if (s.toLowerCase().endsWith("package.json")) { ll2 = buildListFromJSON(s); // fullNodeName = s; // showFileNames(); } else { if (-1 == s.indexOf("!")) { // if fullNodeName is NOT a // file // within a jar file ... if (listHead == null) return; File f = new File(listHead); if (!f.exists() || !f.isDirectory()) return; String[] fl = f.list(); ll2 = new LinkedList<String>(); if (fl == null || fl.length == 0) { ll2.add("(empty folder)"); } else { for (int j = 0; j < fl.length; j++) { String fn = s + File.separator + fl[j]; File fx = new File(fn); if (!fx.exists()) continue; if (fx.isDirectory()) ll.add(fl[j]); // directories go into ll first } for (int j = 0; j < fl.length; j++) { String fn = s + File.separator + fl[j]; File fx = new File(fn); if (!fx.exists()) continue; if (!fx.isDirectory() && (fCParms.filter.accept(fx) || driver.allFiles)) ll2.add(fl[j]); // non-directories go into ll2, // which is // then sorted, and then added // to ll } } } else { inJarTree = true; if (currentNode == null) return; Enumeration<DefaultMutableTreeNode> e = currentNode.children(); ll = new LinkedList<String>(); ll2 = new LinkedList<String>(); while (e.hasMoreElements()) { DefaultMutableTreeNode node = (e.nextElement()); Object obj = node.getUserObject(); ll2.add((String) obj); } } } if (ll2 == null) return; Collections.sort(ll2, comp); for (String li : ll2) { ll.add(li); } if (!inJarTree) { if (listHead.equals(listShowingJarFile)) { s = driver.javaFBPJarFile; // int j = s.lastIndexOf(File.separator); // s = s.substring(j + 1); ll.add(s); } } Object[] oa = ll.toArray(); nodeNames = new String[oa.length]; for (int j = 0; j < oa.length; j++) { nodeNames[j] = (String) oa[j]; } list = new JList<String>(nodeNames); list.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); list.addKeyListener(this); list.addMouseListener(this); list.addListSelectionListener(this); list.setFocusTraversalKeysEnabled(false); order.remove(3); order.add(3, list); list.setFixedCellHeight(driver.fontg.getSize() + 2); list.setCellRenderer(renderer); list.setEnabled(true); if (!saveAs) list.addAncestorListener(new RequestFocusListener()); if (listView != null) panel.remove(listView); listView = new JScrollPane(list); panel.add(listView, BorderLayout.CENTER); selComp = list; list.setSelectedIndex(0); list.setFocusable(true); list.setVisible(true); // list.requestFocusInWindow(); paintList(); frame.pack(); listView.repaint(); dialog.repaint(); panel.validate(); panel.repaint(); frame.repaint(); }