/** TabbedPaneDemo Constructor */ public TabbedPaneDemo(SwingSet2 swingset) { // Set the title for this demo, and an icon used to represent this // demo inside the SwingSet2 app. super(swingset, "TabbedPaneDemo", "toolbar/JTabbedPane.gif"); // create tab position controls JPanel tabControls = new JPanel(); tabControls.add(new JLabel(getString("TabbedPaneDemo.label"))); top = (JRadioButton) tabControls.add(new JRadioButton(getString("TabbedPaneDemo.top"))); left = (JRadioButton) tabControls.add(new JRadioButton(getString("TabbedPaneDemo.left"))); bottom = (JRadioButton) tabControls.add(new JRadioButton(getString("TabbedPaneDemo.bottom"))); right = (JRadioButton) tabControls.add(new JRadioButton(getString("TabbedPaneDemo.right"))); getDemoPanel().add(tabControls, BorderLayout.NORTH); group = new ButtonGroup(); group.add(top); group.add(bottom); group.add(left); group.add(right); top.setSelected(true); top.addActionListener(this); bottom.addActionListener(this); left.addActionListener(this); right.addActionListener(this); // create tab tabbedpane = new JTabbedPane(); getDemoPanel().add(tabbedpane, BorderLayout.CENTER); String name = getString("TabbedPaneDemo.laine"); JLabel pix = new JLabel(createImageIcon("tabbedpane/laine.jpg", name)); tabbedpane.add(name, pix); name = getString("TabbedPaneDemo.ewan"); pix = new JLabel(createImageIcon("tabbedpane/ewan.jpg", name)); tabbedpane.add(name, pix); name = getString("TabbedPaneDemo.hania"); pix = new JLabel(createImageIcon("tabbedpane/hania.jpg", name)); tabbedpane.add(name, pix); name = getString("TabbedPaneDemo.bounce"); spin = new HeadSpin(); tabbedpane.add(name, spin); tabbedpane .getModel() .addChangeListener( new ChangeListener() { public void stateChanged(ChangeEvent e) { SingleSelectionModel model = (SingleSelectionModel) e.getSource(); if (model.getSelectedIndex() == tabbedpane.getTabCount() - 1) { spin.go(); } } }); }
/** * Method for adding a new Panel * * @param object The new Panel */ public void addPanel(GPropertiesPanel object, String title) { pane.add(object, title); objects.add(object); }
public SketchProperties(Editor e, Sketch s) { super(); editor = e; sketch = s; fields = new HashMap<String, JComponent>(); this.setPreferredSize(new Dimension(500, 400)); this.setMinimumSize(new Dimension(500, 400)); this.setMaximumSize(new Dimension(500, 400)); this.setSize(new Dimension(500, 400)); Point eLoc = editor.getLocation(); int x = eLoc.x; int y = eLoc.y; Dimension eSize = editor.getSize(); int w = eSize.width; int h = eSize.height; int cx = x + (w / 2); int cy = y + (h / 2); this.setLocation(new Point(cx - 250, cy - 200)); this.setModal(true); outer = new JPanel(new BorderLayout()); outer.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10)); this.add(outer); win = new JPanel(); win.setLayout(new BorderLayout()); outer.add(win, BorderLayout.CENTER); buttonBar = new JPanel(new FlowLayout(FlowLayout.RIGHT)); saveButton = new JButton("OK"); saveButton.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { save(); SketchProperties.this.dispose(); } }); cancelButton = new JButton("Cancel"); cancelButton.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { SketchProperties.this.dispose(); } }); buttonBar.add(saveButton); buttonBar.add(cancelButton); win.add(buttonBar, BorderLayout.SOUTH); tabs = new JTabbedPane(); overviewPane = new JPanel(); overviewPane.setLayout(new BoxLayout(overviewPane, BoxLayout.PAGE_AXIS)); overviewPane.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10)); addTextField(overviewPane, "author", "Sketch author:"); addTextArea(overviewPane, "summary", "Summary:"); addTextArea(overviewPane, "license", "Copyright / License:"); tabs.add("Overview", overviewPane); objectsPane = new JPanel(); objectsPane.setLayout(new BoxLayout(objectsPane, BoxLayout.PAGE_AXIS)); objectsPane.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10)); addTextField(objectsPane, "board", "Board:"); addTextField(objectsPane, "core", "Core:"); addTextField(objectsPane, "compiler", "Compiler:"); addTextField(objectsPane, "port", "Serial port:"); addTextField(objectsPane, "programmer", "Programmer:"); JButton setDef = new JButton("Set to current IDE values"); setDef.setMaximumSize(setDef.getPreferredSize()); setDef.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { setObjectValues(); } }); objectsPane.add(Box.createVerticalGlue()); objectsPane.add(setDef); tabs.add("Objects", objectsPane); win.add(tabs, BorderLayout.CENTER); this.setTitle("Sketch Properties"); this.pack(); this.setVisible(true); }
public EditorServer(String fileName, String name, String desc) { super(); self = this; if (fileName == null || !loadDocument(fileName)) { clients = new Vector(); document = new EditorDocument(name, desc, "", System.currentTimeMillis()); try { // ascii code for first blue line... document.insertString(0, "·-·+·*=·x·\n", document.getStyle("line")); } catch (BadLocationException ble) { System.out.println("EditorServer->const: BadLocationException"); } paragraphs = new Paragraphs(document); lockManager = new LockManager(clients, document, paragraphs); highlights = new Highlights(lockManager, document); nextClientId = 1; } isAudioOptionSelected = false; // to avoid unecessary Audio - Text participant matching documentPanel = new DocumentPanel(); updateParagraphList(); clientsPanel = new ClientsPanel(); clientsPanel.updateClientList(); Icon clockIcon = getImageIcon("images/clock.gif"); Icon clockIcon2 = getImageIcon("images/clock2.gif"); startRTPrecording = new JButton("START RTP Recording", clockIcon); startRTPrecording.setRolloverIcon(clockIcon2); RecordingHandler recHandler = new RecordingHandler(self); startRTPrecording.addActionListener(recHandler); Icon stopIcon = getImageIcon("images/stop.gif"); stopRTPrecording = new JButton("STOP RTP recording", stopIcon); stopRTPrecording.setEnabled(false); stopRTPrecording.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { recorder.endRecording(); stopRTPrecording.setEnabled(false); startRTPrecording.setEnabled(true); } }); Container container = getContentPane(); container.setLayout(new FlowLayout()); container.add(startRTPrecording); container.add(stopRTPrecording); // JTabbedPane tabPane = new JTabbedPane() ; tabPane.add("Document", documentPanel); tabPane.add("Text Clients", clientsPanel); container.add(tabPane, BorderLayout.CENTER); setTitle("EditorServer"); setSize(new Dimension(800, 600)); addWindowListener( new WindowAdapter() { public void windowClosing(WindowEvent e) { lockManager.saveDocument(null, highlights, self); System.exit(0); } }); JMenuItem mnuSave = new JMenuItem("Save"); mnuSave.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { JFileChooser dialog = new JFileChooser(); dialog.addChoosableFileFilter( new MyFileFilter("Collabortive Document File (*.cde)", ".cde")); dialog.setAcceptAllFileFilterUsed(false); if (dialog.showSaveDialog(null) == JFileChooser.APPROVE_OPTION) { lockManager.saveDocument(dialog.getSelectedFile().getPath(), highlights, self); } } }); JMenuItem mnuSaveXML = new JMenuItem("Save XML"); mnuSaveXML.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { JFileChooser dialog = new JFileChooser(); dialog.addChoosableFileFilter(new MyFileFilter("XML File (*.xml)", ".xml")); dialog.setAcceptAllFileFilterUsed(false); if (dialog.showSaveDialog(null) == JFileChooser.APPROVE_OPTION) { lockManager.saveXML(dialog.getSelectedFile().getPath(), highlights, self); } } }); JMenu mnuFile = new JMenu("File"); mnuFile.add(mnuSave); mnuFile.add(mnuSaveXML); JMenuBar menu = new JMenuBar(); menu.add(mnuFile); setJMenuBar(menu); Thread backupThread = new Thread() { public void run() { while (1 == 1) { yield(); try { // sleep(1000) ; sleep(5 * 60 * 1000); lockManager.saveDocument(null, highlights, self); } catch (Exception e) { System.out.println("EditorServer: backupThread. error"); e.printStackTrace(); } } } }; backupThread.setDaemon(true); backupThread.start(); } // endof const WITHOUT audio profile maker
/** Creates the debug process, which is a GUI window that displays XML traffic. */ private void createDebug() { frame = new JFrame( "Smack Debug Window -- " + connection.getServiceName() + ":" + connection.getPort()); // Add listener for window closing event frame.addWindowListener( new WindowAdapter() { public void windowClosing(WindowEvent evt) { rootWindowClosing(evt); } }); // We'll arrange the UI into four tabs. The first tab contains all data, the second // client generated XML, the third server generated XML, and the fourth is packet // data from the server as seen by Smack. JTabbedPane tabbedPane = new JTabbedPane(); JPanel allPane = new JPanel(); allPane.setLayout(new GridLayout(3, 1)); tabbedPane.add("All", allPane); // Create UI elements for client generated XML traffic. final JTextArea sentText1 = new JTextArea(); final JTextArea sentText2 = new JTextArea(); sentText1.setEditable(false); sentText2.setEditable(false); sentText1.setForeground(new Color(112, 3, 3)); sentText2.setForeground(new Color(112, 3, 3)); allPane.add(new JScrollPane(sentText1)); tabbedPane.add("Sent", new JScrollPane(sentText2)); // Add pop-up menu. JPopupMenu menu = new JPopupMenu(); JMenuItem menuItem1 = new JMenuItem("Copy"); menuItem1.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { // Get the clipboard Clipboard clipboard = Toolkit.getDefaultToolkit().getSystemClipboard(); // Set the sent text as the new content of the clipboard clipboard.setContents(new StringSelection(sentText1.getText()), null); } }); JMenuItem menuItem2 = new JMenuItem("Clear"); menuItem2.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { sentText1.setText(""); sentText2.setText(""); } }); // Add listener to the text area so the popup menu can come up. MouseListener popupListener = new PopupListener(menu); sentText1.addMouseListener(popupListener); sentText2.addMouseListener(popupListener); menu.add(menuItem1); menu.add(menuItem2); // Create UI elements for server generated XML traffic. final JTextArea receivedText1 = new JTextArea(); final JTextArea receivedText2 = new JTextArea(); receivedText1.setEditable(false); receivedText2.setEditable(false); receivedText1.setForeground(new Color(6, 76, 133)); receivedText2.setForeground(new Color(6, 76, 133)); allPane.add(new JScrollPane(receivedText1)); tabbedPane.add("Received", new JScrollPane(receivedText2)); // Add pop-up menu. menu = new JPopupMenu(); menuItem1 = new JMenuItem("Copy"); menuItem1.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { // Get the clipboard Clipboard clipboard = Toolkit.getDefaultToolkit().getSystemClipboard(); // Set the sent text as the new content of the clipboard clipboard.setContents(new StringSelection(receivedText1.getText()), null); } }); menuItem2 = new JMenuItem("Clear"); menuItem2.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { receivedText1.setText(""); receivedText2.setText(""); } }); // Add listener to the text area so the popup menu can come up. popupListener = new PopupListener(menu); receivedText1.addMouseListener(popupListener); receivedText2.addMouseListener(popupListener); menu.add(menuItem1); menu.add(menuItem2); // Create UI elements for interpreted XML traffic. final JTextArea interpretedText1 = new JTextArea(); final JTextArea interpretedText2 = new JTextArea(); interpretedText1.setEditable(false); interpretedText2.setEditable(false); interpretedText1.setForeground(new Color(1, 94, 35)); interpretedText2.setForeground(new Color(1, 94, 35)); allPane.add(new JScrollPane(interpretedText1)); tabbedPane.add("Interpreted", new JScrollPane(interpretedText2)); // Add pop-up menu. menu = new JPopupMenu(); menuItem1 = new JMenuItem("Copy"); menuItem1.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { // Get the clipboard Clipboard clipboard = Toolkit.getDefaultToolkit().getSystemClipboard(); // Set the sent text as the new content of the clipboard clipboard.setContents(new StringSelection(interpretedText1.getText()), null); } }); menuItem2 = new JMenuItem("Clear"); menuItem2.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { interpretedText1.setText(""); interpretedText2.setText(""); } }); // Add listener to the text area so the popup menu can come up. popupListener = new PopupListener(menu); interpretedText1.addMouseListener(popupListener); interpretedText2.addMouseListener(popupListener); menu.add(menuItem1); menu.add(menuItem2); frame.getContentPane().add(tabbedPane); frame.setSize(550, 400); frame.setVisible(true); // Create a special Reader that wraps the main Reader and logs data to the GUI. ObservableReader debugReader = new ObservableReader(reader); readerListener = new ReaderListener() { public void read(String str) { int index = str.lastIndexOf(">"); if (index != -1) { receivedText1.append(str.substring(0, index + 1)); receivedText2.append(str.substring(0, index + 1)); receivedText1.append(NEWLINE); receivedText2.append(NEWLINE); if (str.length() > index) { receivedText1.append(str.substring(index + 1)); receivedText2.append(str.substring(index + 1)); } } else { receivedText1.append(str); receivedText2.append(str); } } }; debugReader.addReaderListener(readerListener); // Create a special Writer that wraps the main Writer and logs data to the GUI. ObservableWriter debugWriter = new ObservableWriter(writer); writerListener = new WriterListener() { public void write(String str) { sentText1.append(str); sentText2.append(str); if (str.endsWith(">")) { sentText1.append(NEWLINE); sentText2.append(NEWLINE); } } }; debugWriter.addWriterListener(writerListener); // Assign the reader/writer objects to use the debug versions. The packet reader // and writer will use the debug versions when they are created. reader = debugReader; writer = debugWriter; // Create a thread that will listen for all incoming packets and write them to // the GUI. This is what we call "interpreted" packet data, since it's the packet // data as Smack sees it and not as it's coming in as raw XML. listener = new PacketListener() { public void processPacket(Packet packet) { interpretedText1.append(packet.toXML()); interpretedText2.append(packet.toXML()); interpretedText1.append(NEWLINE); interpretedText2.append(NEWLINE); } }; }
public IndexingFrame(Frames parent, BatchState bs) { this.parent = parent; this.batchState = bs; this.indexingFrame = this; // Set the window's title this.setTitle("Indexing"); this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); // Create menu bar this.createMenuBar(this); this.setPreferredSize(new Dimension(2000, 1000)); // Set the location of the window on the desktop this.setLocation(100, 100); // Size the window according to the preferred sizes and layout of its subcomponents this.pack(); Container contentPane = this.getContentPane(); contentPane.setLayout(new BoxLayout(contentPane, BoxLayout.PAGE_AXIS)); ButtonBar buttonBar = new ButtonBar(this, batchState); contentPane.add(buttonBar); JTabbedPane leftTabbedPane = new JTabbedPane(); formEntry = new FormEntry(this, batchState); // TableEntry table = new TableEntry(); model = new DefaultTableModel() { @Override public boolean isCellEditable(int row, int column) { return column != 0; } }; // tableEntry = new JTable(model); // tableEntry.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION); // tableEntry.setColumnSelectionAllowed(true); // tableEntry.setRowSelectionAllowed(true); // // tableEntry.setGridColor(Color.BLACK); tableEntry = new TableEntry(this, batchState, model); JScrollPane scrollpane = new JScrollPane(tableEntry); leftTabbedPane.add("Table Entry", scrollpane); listModel = new DefaultListModel<String>(); list = new JList(listModel); JScrollPane listScroll = new JScrollPane(list); JScrollPane formScroll = new JScrollPane(formEntry); JPanel formSplit = new JPanel(); formSplit.setLayout(new BoxLayout(formSplit, BoxLayout.LINE_AXIS)); formSplit.add(listScroll); formSplit.add(formScroll); leftTabbedPane.add("Form Entry", formSplit); JTabbedPane rightTabbedPane = new JTabbedPane(); fieldHelp = new FieldHelp(batchState); JScrollPane helpScroll = new JScrollPane(fieldHelp); helpScroll.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS); ImageNavigation imageNavigation = new ImageNavigation(); rightTabbedPane.add("Field Help", helpScroll); rightTabbedPane.add("Image Navigation", imageNavigation); horizontalSplitPane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, leftTabbedPane, rightTabbedPane); horizontalSplitPane.setAlignmentX(Component.CENTER_ALIGNMENT); horizontalSplitPane.setDividerLocation(this.getWidth() / 2); horizontalSplitPane.setOneTouchExpandable(true); horizontalSplitPane.setResizeWeight(0.5); this.imageComponent = new ImageComponent(); componentPanel = new JPanel(); // componentPanel.setBackground(Color.gray); // componentPanel.setPreferredSize(new Dimension(400,400)); component = new DrawingComponent(this, batchState); componentPanel.add(component, BorderLayout.CENTER); // slider = new JSlider(1, 100, 20); // slider.addChangeListener(sliderChangeListener); // componentPanel.add(slider, BorderLayout.SOUTH); verticalSplitPane = new JSplitPane(JSplitPane.VERTICAL_SPLIT, component, horizontalSplitPane); verticalSplitPane.setDividerLocation(this.getHeight() / 2); verticalSplitPane.setOneTouchExpandable(true); verticalSplitPane.setAlignmentX(Component.CENTER_ALIGNMENT); verticalSplitPane.setResizeWeight(0.5); contentPane.add(verticalSplitPane); this.pack(); }