public void updateClientList() { Iterator i = clients.iterator(); DefaultListModel model = new DefaultListModel(); EditorClient placebo = new EditorClient(self, 0, " ", 0, 0, ""); model.addElement(placebo); while (i.hasNext()) { EditorClient c = (EditorClient) i.next(); model.addElement(c); } lstClients.setModel(model); lstClients.setSelectedValue(currClient, true); }
public ClientsPanel() { super(new BorderLayout()); lstClients = new JList(); lstClients.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); lstClients.setCellRenderer( new DefaultListCellRenderer() { public Component getListCellRendererComponent( JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) { EditorClient c = (EditorClient) value; JLabel label = new JLabel(c.getName()); if (c.isPresent()) label.setForeground(MyColors.getMainColor(c.getColorCode())); else label.setForeground(Color.GRAY); if (isSelected) label.setBackground(lstClients.getSelectionBackground()); return label; } }); lstClients.addMouseListener( new MouseAdapter() { public void mouseClicked(MouseEvent e) { if (EditorServer_Debug) System.out.println(" mouseClicked "); int ndx = lstClients.locationToIndex(new Point(e.getX(), e.getY())); if (ndx > -1 && ndx < lstClients.getModel().getSize()) lstClients.setSelectedIndex(ndx); else { if (EditorServer_Debug) System.out.println(" invalid mouse click on the JList"); } } }); lstClients.addListSelectionListener( new ListSelectionListener() { public void valueChanged(ListSelectionEvent e) { EditorClient c = (EditorClient) lstClients.getSelectedValue(); currClient = c; updateActionTableFor(currClient); } }); tblActions = new JTable(getClearTableModel()); add(new JScrollPane(lstClients), BorderLayout.WEST); add(new JScrollPane(tblActions), BorderLayout.CENTER); }
public void unhiliteInactiveParticipant(String cname) { int i = plistModel.indexOf(cname); plist.removeSelectionInterval(i, i); }
public void hiliteActiveParticipant(String cname) { int i = plistModel.indexOf(cname); plist.addSelectionInterval(i, i); }
public DocumentPanel() { super(new BorderLayout()); JLabel lblDocument = new JLabel("Document: " + document.getTitle()); lblDocument.setBorder(new EtchedBorder()); textPane = new JTextPane(document); textPane.setEditable(false); textPane.setMargin(new Insets(5, 20, 5, 5)); textPane.setMaximumSize(new Dimension(364, 1000000000)); textPane.setPreferredSize(new Dimension(364, 400)); textPane.setMinimumSize(new Dimension(364, 10)); textPane.addCaretListener( new CaretListener() { public void caretUpdate(CaretEvent e) { int length = document.getLength(); int offset = e.getDot(); if (e.getDot() == e.getMark()) textPane.getCaret().moveDot(offset + 1); Paragraph p = lockManager.getParFromOffset(offset); int pOffset = p.getOffset(); lblCursor.setText( "Document Length=" + String.valueOf(length) + ", CaretOffset=" + String.valueOf(offset) + ", Paragraph=" + p.toString() + ", Offset in Paragraph=" + String.valueOf(offset - p.getOffset())); } }); Box box = new Box(BoxLayout.X_AXIS); box.add(textPane); box.add(Box.createGlue()); box.setBackground(Color.WHITE); box.setOpaque(true); box.setPreferredSize(new Dimension(600, 10000)); lblCursor = new JLabel("Cursor"); lblCursor.setBorder(new EtchedBorder()); JPanel boxText = new JPanel(new BorderLayout()); boxText.setBorder(new EmptyBorder(5, 5, 5, 5)); boxText.add(lblDocument, BorderLayout.NORTH); boxText.add(new JScrollPane(box), BorderLayout.CENTER); boxText.add(lblCursor, BorderLayout.SOUTH); JLabel lblPars = new JLabel("Paragraphs: "); lblPars.setBorder(new EtchedBorder()); parList = new JList(); parList.setPreferredSize(new Dimension(100, 300)); parList.setEnabled(false); JPanel boxPars = new JPanel(new BorderLayout()); boxPars.setBorder(new EmptyBorder(5, 5, 5, 5)); boxPars.add(lblPars, BorderLayout.NORTH); boxPars.add(new JScrollPane(parList), BorderLayout.CENTER); add(boxText, BorderLayout.CENTER); add(boxPars, BorderLayout.EAST); }