private void showJTree(JScrollPane view, Point pt) { JTree tree = (JTree)view.Viewport.View; Point p = SwingUtilities.convertPoint(view, pt.x, pt.y, tree); int row = tree.getClosestRowForLocation(p.x, p.y); TreePath path = tree.getClosestPathForLocation(p.x, p.y); Rectangle bds = tree.getPathBounds(path); if (bds == null || !bds.contains(p)) { hide(); return; } if (setCompAndRow(tree, row)) { Rectangle visible = getShowingRect(view); Rectangle[] rects = getRects(bds, visible); if (rects.Length > 0) { ensureOldPopupsHidden(); painter.configure(path.LastPathComponent, view, tree, path, row); showPopups(rects, bds, visible, tree, view); } else { hide(); } } }
internal bool setLastRenderedScrollPane(JScrollPane comp) { bool result = comp != this.comp; this.comp = comp; return(result); }
private JComponent getPlayerListComponent() { var playerlistbox = new PlayerListBox(mcServer); var jscrollpane = new JScrollPane(playerlistbox, 22, 30); jscrollpane.setBorder(new TitledBorder(new EtchedBorder(), "Players")); return(jscrollpane); }
private void showJList(JScrollPane view, Point pt) { JList list = (JList)view.Viewport.View; Point p = SwingUtilities.convertPoint(view, pt.x, pt.y, list); int row = list.locationToIndex(p); if (row == -1) { hide(); return; } Rectangle bds = list.getCellBounds(row, row); //GetCellBounds returns a width that is the //full component width; we want only what //the renderer really needs. ListCellRenderer ren = list.CellRenderer; Dimension rendererSize = ren.getListCellRendererComponent(list, list.Model.getElementAt(row), row, false, false).PreferredSize; // fix for possible npe spotted by SCO // http://pspsharp.org/forum/viewtopic.php?p=3387#p3387 if (bds == null) { hide(); return; } bds.width = rendererSize.width; if (!bds.contains(p)) { hide(); return; } //bds.width = rendererSize.width; //if (bds == null || !bds.contains(p)) { // hide(); // return; //} // end "fix for possible npe spotted by SCO" if (setCompAndRow(list, row)) { Rectangle visible = getShowingRect(view); Rectangle[] rects = getRects(bds, visible); if (rects.Length > 0) { ensureOldPopupsHidden(); painter.configure(list.Model.getElementAt(row), view, list, row); showPopups(rects, bds, visible, list, view); } else { hide(); } } }
private void initComponents() { scrollPane = new JScrollPane(); chatMessagesLabel = new JLabel(); chatMessage = new JTextField(); sendButton = new JButton(); adhocIDLabel = new JLabel(); groupNameLabel = new JLabel(); membersLabel = new JLabel(); membersList = new JLabel(); Title = "Chat"; Resizable = true; sendButton.Text = "Send"; sendButton.DefaultCapable = true; RootPane.DefaultButton = sendButton; sendButton.addActionListener(new ActionListenerAnonymousInnerClass(this)); // Start displaying the chat message from the bottom chatMessagesLabel.VerticalAlignment = SwingConstants.BOTTOM; chatMessagesLabel.PreferredSize = new Dimension(500, 300); scrollPane.ViewportView = chatMessagesLabel; adhocIDLabel.Text = AdhocID; groupNameLabel.Text = GroupName; membersLabel.Text = "Members:"; membersList.PreferredSize = new Dimension(100, chatMessagesLabel.PreferredSize.height); chatMessage.Editable = true; // // Layout: // // +-------------------------------------------+-----------------+ // | | adhocIDLabel | // | | groupNameLabel | // | chatMessageLabel in scrollPane | membersLabel | // | +-----------------+ // | | membersList | // | | | // | | | // | | | // | | | // +-------------------------------------------+----+------------+ // | chatMessage | sendButton | // +------------------------------------------------+------------+ // GroupLayout layout = new GroupLayout(ContentPane); ContentPane.Layout = layout; layout.HorizontalGroup = layout.createParallelGroup().addGroup(layout.createSequentialGroup().addComponent(scrollPane).addGroup(layout.createParallelGroup().addGroup(layout.createParallelGroup().addComponent(adhocIDLabel)).addGroup(layout.createParallelGroup().addComponent(groupNameLabel)).addComponent(membersLabel).addComponent(membersList))).addGroup(layout.createSequentialGroup().addComponent(chatMessage).addComponent(sendButton)); layout.VerticalGroup = layout.createSequentialGroup().addGroup(layout.createParallelGroup().addComponent(scrollPane).addGroup(layout.createSequentialGroup().addGroup(layout.createParallelGroup().addComponent(adhocIDLabel)).addGroup(layout.createParallelGroup().addComponent(groupNameLabel)).addComponent(membersLabel).addComponent(membersList))).addGroup(layout.createParallelGroup().addComponent(chatMessage).addComponent(sendButton)); pack(); }
public virtual string ShowListSelectionDialog(IList <string> files, Point location) { Frame frame = new Frame(); //System.out.println(location); //frame.setLocation(location); JDialog dialog = new JDialog(frame, "Jar File Chooser", true); dialog.SetLocation(location); JList fileList = new JList(new Vector <string>(files)); fileList.SetSelectionMode(ListSelectionModelConstants.SingleSelection); IMouseListener mouseListener = new _MouseAdapter_68(dialog); // double clicked fileList.AddMouseListener(mouseListener); JScrollPane scroll = new JScrollPane(fileList); JButton okay = new JButton(); okay.SetText("Okay"); okay.SetToolTipText("Okay"); okay.AddActionListener(null); JButton cancel = new JButton(); cancel.SetText("Cancel"); cancel.SetToolTipText("Cancel"); cancel.AddActionListener(null); GridBagLayout gridbag = new GridBagLayout(); GridBagConstraints constraints = new GridBagConstraints(); dialog.SetLayout(gridbag); constraints.gridwidth = GridBagConstraints.Remainder; constraints.fill = GridBagConstraints.Both; constraints.weightx = 1.0; constraints.weighty = 1.0; gridbag.SetConstraints(scroll, constraints); dialog.Add(scroll); constraints.gridwidth = GridBagConstraints.Relative; constraints.fill = GridBagConstraints.None; constraints.weighty = 0.0; gridbag.SetConstraints(okay, constraints); dialog.Add(okay); constraints.gridwidth = GridBagConstraints.Remainder; gridbag.SetConstraints(cancel, constraints); dialog.Add(cancel); dialog.Pack(); dialog.SetSize(dialog.GetPreferredSize()); dialog.SetVisible(true); if (fileList.IsSelectionEmpty()) { return(null); } return(files[fileList.GetSelectedIndex()]); }
public override void mouseMoved(MouseEvent e) { Point p = e.Point; JComponent comp = (JComponent)e.Source; JScrollPane jsp = (JScrollPane)SwingUtilities.getAncestorOfClass(typeof(JScrollPane), comp); if (jsp != null) { p = SwingUtilities.convertPoint(comp, p, jsp); show(jsp, p); } }
/// <summary> /// Shows the appropriate popups given the state of the scroll pane and /// its view. </summary> /// <param name="view"> The scroll pane owning the component the event happened on </param> /// <param name="pt"> The point at which the mouse event happened, in the coordinate /// space of the scroll pane. </param> internal void show(JScrollPane view, Point pt) { if (view.Viewport.View is JTree) { showJTree(view, pt); } else if (view.Viewport.View is JList) { showJList(view, pt); } else { System.Diagnostics.Debug.Assert(false, "Bad component type registered: " + view.Viewport.View); } }
/// <summary> /// Configures a list cell renderer and sets up sizing and the /// backing image from it /// </summary> public bool configure(object nd, JScrollPane tv, JList list, int row) { LastRendereredObject = nd; LastRenderedScrollPane = tv; Component renderer = null; bg = list.BackgRound; bool sel = list.SelectionEmpty ? false : list.SelectionModel.isSelectedIndex(row); renderer = list.CellRenderer.getListCellRendererComponent(list, nd, row, sel, false); if (renderer != null) { Component = renderer; } return(true); }
public Hider(JComponent comp, JScrollPane pane) { if (comp is JTree) { tree = (JTree)comp; list = null; } else { list = (JList)comp; tree = null; } System.Diagnostics.Debug.Assert(tree != null || list != null); this.pane = pane; attach(); }
public void menuEntryActivated(JPanel param1JPanel) { param1JPanel.removeAll(); param1JPanel.Layout = new BorderLayout(); CostOSRibbonApplicationMenuPopupPanelSecondary costOSRibbonApplicationMenuPopupPanelSecondary = new CostOSRibbonApplicationMenuPopupPanelSecondaryAnonymousInnerClass(this, menuEntry); JScrollPane jScrollPane = new JScrollPane(costOSRibbonApplicationMenuPopupPanelSecondary, 20, 31); jScrollPane.Border = BorderFactory.createEmptyBorder(); jScrollPane.Viewport.Background = SECONDARY_MENU_COLOR; jScrollPane.Background = SECONDARY_MENU_COLOR; Dimension dimension = costOSRibbonApplicationMenuPopupPanelSecondary.PreferredSize; costOSRibbonApplicationMenuPopupPanelSecondary.PreferredSize = new Dimension((param1JPanel.PreferredSize).width - (jScrollPane.VerticalScrollBar.PreferredSize).width, dimension.height); param1JPanel.Background = SECONDARY_MENU_COLOR; param1JPanel.add(jScrollPane, "Center"); param1JPanel.revalidate(); }
private JComponent getLogComponent() { var jpanel = new JPanel(new BorderLayout()); var jtextarea = new JTextArea(); logger.addHandler(new GuiLogOutputHandler(jtextarea)); var jscrollpane = new JScrollPane(jtextarea, 22, 30); jtextarea.setEditable(false); var jtextfield = new JTextField(); jtextfield.addActionListener(new ServerGuiCommandListener(this, jtextfield)); jtextarea.addFocusListener(new ServerGuiFocusAdapter(this)); jpanel.add(jscrollpane, "Center"); jpanel.add(jtextfield, "South"); jpanel.setBorder(new TitledBorder(new EtchedBorder(), "Log and chat")); return(jpanel); }
/// <summary> /// Configures a tree cell renderer and sets up sizing and the /// backing image from it /// </summary> public bool configure(object nd, JScrollPane tv, JTree tree, TreePath path, int row) { LastRendereredObject = nd; LastRenderedScrollPane = tv; Component renderer = null; bg = tree.BackgRound; bool sel = tree.SelectionEmpty ? false : tree.SelectionModel.isPathSelected(path); bool exp = tree.isExpanded(path); bool leaf = !exp && tree.Model.isLeaf(nd); bool lead = path.Equals(tree.SelectionModel.LeadSelectionPath); renderer = tree.CellRenderer.getTreeCellRendererComponent(tree, nd, sel, exp, leaf, row, lead); if (renderer != null) { Component = renderer; } return(true); }
private void JbInit() { //pf = new PrintFile("out"); this.AddWindowListener(new _WindowAdapter_110()); //Set up the input/output fields and let them scroll. inputBox.SetLineWrap(true); inputBox.SetWrapStyleWord(true); outputBox.SetLineWrap(true); outputBox.SetWrapStyleWord(true); outputBox.SetEditable(false); JScrollPane scroll1 = new JScrollPane(inputBox); JScrollPane scroll2 = new JScrollPane(outputBox); scroll1.SetBorder(BorderFactory.CreateTitledBorder(BorderFactory.CreateEtchedBorder(), "Type a sentence to tag: ")); scroll2.SetBorder(BorderFactory.CreateTitledBorder(BorderFactory.CreateEtchedBorder(), "Tagged sentence: ")); //Set up the button for starting tagging JPanel buttonPanel = new JPanel(); buttonPanel.SetBackground(Color.White); buttonPanel.ApplyComponentOrientation(ComponentOrientation.RightToLeft); FlowLayout fl = new FlowLayout(); fl.SetAlignment(FlowLayout.Right); buttonPanel.SetLayout(fl); tagButton.SetText("Tag sentence!"); tagButton.SetBackground(Color.White); buttonPanel.Add(tagButton); tagButton.AddActionListener(null); //Lay it all out this.SetLayout(new GridBagLayout()); GridBagConstraints c = new GridBagConstraints(); c.fill = GridBagConstraints.Both; c.gridwidth = GridBagConstraints.Remainder; c.weightx = 4.0; c.weighty = 4.0; this.Add(scroll1, c); c.weighty = 1.0; this.Add(buttonPanel, c); c.weighty = 4.0; c.gridheight = GridBagConstraints.Remainder; this.Add(scroll2, c); }
private JViewport getViewport() { Container parent = this.getParent(); if (parent is JViewport) { Container parent2 = parent.getParent(); if (parent2 is JScrollPane) { JScrollPane jscrollPane = (JScrollPane)parent2; JViewport viewport = jscrollPane.getViewport(); if (viewport == null || viewport.getView() != this) { return(null); } return(viewport); } } return(null); }
private JPanel getDatabaseFailureUpdateFrame(System.Collections.IList paramList) { StringWriter stringWriter = new StringWriter(); PrintWriter printWriter = new PrintWriter(stringWriter); paramList.ForEach(paramObject => { Exception exception = (Exception)paramObject; paramPrintWriter.println("===================================="); paramPrintWriter.println(exception.GetType() + " : " + exception.Message); exception.printStackTrace(paramPrintWriter); paramPrintWriter.println(); }); JPanel jPanel = new JPanel(); jPanel.Layout = new BorderLayout(); JTextArea jTextArea = new JTextArea(stringWriter.ToString(), 100, 80); JScrollPane jScrollPane = new JScrollPane(jTextArea, 22, 32); jPanel.add(jScrollPane, "Center"); return(jPanel); }
/// <summary> /// Set a component (JList or JTree) which should be listened to, such that if /// a model, selection or scroll event occurs, all currently open popups /// should be hidden. /// </summary> private void setHideComponent(JComponent comp, JScrollPane parent) { if (hider != null) { if (hider.isListeningTo(comp)) { return; } } if (hider != null) { hider.detach(); } if (comp != null) { hider = new Hider(comp, parent); } else { hider = null; } }
// private String initText = "In"; private void BuildContentPanel() { editorPane = new JEditorPane(); editorPane.SetContentType("text/rtf"); editorPane.AddKeyListener(new NERGUI.InputListener(this)); // defaultAttrSet = ((StyledEditorKit)editorPane.getEditorKit()).getInputAttributes(); StyleConstants.SetFontFamily(defaultAttrSet, "Lucinda Sans"); IDocument doc = new DefaultStyledDocument(); editorPane.SetDocument(doc); try { doc.InsertString(0, initText, defaultAttrSet); } catch (Exception ex) { throw new Exception(ex); } JScrollPane scrollPane = new JScrollPane(editorPane); frame.GetContentPane().Add(scrollPane, BorderLayout.Center); editorPane.SetEditable(true); }
/// <summary> /// Gets the sub-rectangle of a JScrollPane's area that /// is actually showing the view /// </summary> private Rectangle getShowingRect(JScrollPane pane) { Insets ins1 = pane.Viewport.Insets; Border inner = pane.ViewportBorder; Insets ins2; if (inner != null) { ins2 = inner.getBorderInsets(pane); } else { ins2 = new Insets(0, 0, 0, 0); } Insets ins3 = new Insets(0, 0, 0, 0); if (pane.Border != null) { ins3 = pane.Border.getBorderInsets(pane); } Rectangle r = pane.ViewportBorderBounds; r.translate(-r.x, -r.y); r.width -= ins1.left + ins1.right; r.width -= ins2.left + ins2.right; r.height -= ins1.top + ins1.bottom; r.height -= ins2.top + ins2.bottom; r.x -= ins2.left; r.x -= ins3.left; Point p = pane.Viewport.ViewPosition; r.translate(p.x, p.y); r = SwingUtilities.convertRectangle(pane.Viewport, r, pane); return(r); }
internal void clear() { comp = null; node = null; }
/// <summary> /// This method is called from within the constructor to /// initialize the form. /// </summary> /// <remarks> /// This method is called from within the constructor to /// initialize the form. /// WARNING: Do NOT modify this code. The content of this method is /// always regenerated by the Form Editor. /// </remarks> private void InitComponents() { //GEN-BEGIN:initComponents splitPane = new JSplitPane(); topPanel = new JPanel(); buttonsAndFilePanel = new JPanel(); loadButtonPanel = new JPanel(); loadFileButton = new JButton(); loadParserButton = new JButton(); saveOutputButton = new JButton(); buttonPanel = new JPanel(); backButton = new JButton(); if (GetType().GetResource("/edu/stanford/nlp/parser/ui/leftarrow.gif") != null) { backButton.SetIcon(new ImageIcon(GetType().GetResource("/edu/stanford/nlp/parser/ui/leftarrow.gif"))); } else { backButton.SetText("< Prev"); } forwardButton = new JButton(); if (GetType().GetResource("/edu/stanford/nlp/parser/ui/rightarrow.gif") != null) { forwardButton.SetIcon(new ImageIcon(GetType().GetResource("/edu/stanford/nlp/parser/ui/rightarrow.gif"))); } else { forwardButton.SetText("Next >"); } parseButton = new JButton(); parseNextButton = new JButton(); clearButton = new JButton(); dataFilePanel = new JPanel(); dataFileLabel = new JLabel(); textScrollPane = new JScrollPane(); textPane = new JTextPane(); treeContainer = new JPanel(); parserFilePanel = new JPanel(); parserFileLabel = new JLabel(); statusPanel = new JPanel(); statusLabel = new JLabel(); progressBar = new JProgressBar(); progressBar.SetVisible(false); SetLayout(new BorderLayout()); splitPane.SetOrientation(JSplitPane.VerticalSplit); topPanel.SetLayout(new BorderLayout()); buttonsAndFilePanel.SetLayout(new BoxLayout(buttonsAndFilePanel, BoxLayout.YAxis)); loadButtonPanel.SetLayout(new FlowLayout(FlowLayout.Left)); loadFileButton.SetText("Load File"); loadFileButton.SetToolTipText("Load a data file."); loadFileButton.AddActionListener(null); loadButtonPanel.Add(loadFileButton); loadParserButton.SetText("Load Parser"); loadParserButton.SetToolTipText("Load a serialized parser."); loadParserButton.AddActionListener(null); loadButtonPanel.Add(loadParserButton); saveOutputButton.SetText("Save Output"); saveOutputButton.SetToolTipText("Save the processed output."); saveOutputButton.SetEnabled(false); saveOutputButton.AddActionListener(null); loadButtonPanel.Add(saveOutputButton); buttonsAndFilePanel.Add(loadButtonPanel); buttonPanel.SetLayout(new FlowLayout(FlowLayout.Left)); backButton.SetToolTipText("Scroll backward one sentence."); backButton.SetEnabled(false); backButton.AddActionListener(null); buttonPanel.Add(backButton); forwardButton.SetToolTipText("Scroll forward one sentence."); forwardButton.SetEnabled(false); forwardButton.AddActionListener(null); buttonPanel.Add(forwardButton); parseButton.SetText("Parse"); parseButton.SetToolTipText("Parse selected sentence."); parseButton.SetEnabled(false); parseButton.AddActionListener(null); buttonPanel.Add(parseButton); parseNextButton.SetText("Parse >"); parseNextButton.SetToolTipText("Parse selected sentence and then scrolls forward one sentence."); parseNextButton.SetEnabled(false); parseNextButton.AddActionListener(null); buttonPanel.Add(parseNextButton); clearButton.SetText("Clear"); clearButton.SetToolTipText("Clears parse tree."); clearButton.SetEnabled(false); clearButton.AddActionListener(null); buttonPanel.Add(clearButton); buttonsAndFilePanel.Add(buttonPanel); dataFilePanel.SetLayout(new FlowLayout(FlowLayout.Left)); dataFilePanel.Add(dataFileLabel); buttonsAndFilePanel.Add(dataFilePanel); topPanel.Add(buttonsAndFilePanel, BorderLayout.North); textPane.SetPreferredSize(new Dimension(250, 250)); textPane.AddFocusListener(new _FocusAdapter_888(this)); textPane.AddMouseListener(new _MouseAdapter_895(this)); textPane.AddMouseMotionListener(new _MouseMotionAdapter_902(this)); textScrollPane.SetViewportView(textPane); topPanel.Add(textScrollPane, BorderLayout.Center); splitPane.SetLeftComponent(topPanel); treeContainer.SetLayout(new BorderLayout()); treeContainer.SetBackground(new Color(255, 255, 255)); treeContainer.SetBorder(new BevelBorder(BevelBorder.Raised)); treeContainer.SetForeground(new Color(0, 0, 0)); treeContainer.SetPreferredSize(new Dimension(200, 200)); treePanel = new TreeJPanel(); treeContainer.Add("Center", treePanel); treePanel.SetBackground(Color.white); parserFilePanel.SetLayout(new FlowLayout(FlowLayout.Left)); parserFilePanel.SetBackground(new Color(255, 255, 255)); parserFileLabel.SetText("Parser: None"); parserFilePanel.Add(parserFileLabel); treeContainer.Add(parserFilePanel, BorderLayout.North); splitPane.SetRightComponent(treeContainer); Add(splitPane, BorderLayout.Center); statusPanel.SetLayout(new FlowLayout(FlowLayout.Left)); statusLabel.SetText("Ready"); statusPanel.Add(statusLabel); progressBar.SetName(string.Empty); statusPanel.Add(progressBar); Add(statusPanel, BorderLayout.South); }
/// <summary> /// Show popups for each rectangle, using the now configured painter. /// </summary> private void showPopups(Rectangle[] rects, Rectangle bds, Rectangle visible, JComponent comp, JScrollPane view) { bool shown = false; for (int i = 0; i < rects.Length; i++) { Rectangle sect = rects[i]; sect.translate(-bds.x, -bds.y); ImgComp part = painter.getPartial(sect, bds.x + rects[i].x < visible.x); Point pos = new Point(bds.x + rects[i].x, bds.y + rects[i].y); SwingUtilities.convertPointToScreen(pos, comp); if (comp is JList) { //XXX off by one somewhere, only with JLists - where? pos.y--; } if (pos.x > 0) { //Mac OS will reposition off-screen popups to x=0, //so don't try to show them popups[i] = PopupFactory.getPopup(view, part, pos.x, pos.y); popups[i].show(); shown = true; } } if (shown) { setHideComponent(comp, view); } else { setHideComponent(null, null); //clear references } }
private void initFactEditPanel() { factComponents.clear(); //UPGRADE_ISSUE: Class 'java.awt.GridBagLayout' was not converted. 'ms-help://MS.VSCC.2003/commoner/redir/redirect.htm?keyword="jlca1000_javaawtGridBagLayout"' //UPGRADE_ISSUE: Constructor 'java.awt.GridBagLayout.GridBagLayout' was not converted. 'ms-help://MS.VSCC.2003/commoner/redir/redirect.htm?keyword="jlca1000_javaawtGridBagLayout"' GridBagLayout gridbag = new GridBagLayout(); //UPGRADE_ISSUE: Class 'java.awt.GridBagConstraints' was not converted. 'ms-help://MS.VSCC.2003/commoner/redir/redirect.htm?keyword="jlca1000_javaawtGridBagConstraints"' //UPGRADE_ISSUE: Constructor 'java.awt.GridBagConstraints.GridBagConstraints' was not converted. 'ms-help://MS.VSCC.2003/commoner/redir/redirect.htm?keyword="jlca1000_javaawtGridBagConstraints"' GridBagConstraints c = new GridBagConstraints(); //UPGRADE_ISSUE: Constructor 'java.awt.BorderLayout.BorderLayout' was not converted. 'ms-help://MS.VSCC.2003/commoner/redir/redirect.htm?keyword="jlca1000_javaawtBorderLayout"' JPanel factEditPanel = new JPanel(new BorderLayout()); JPanel innerPanel = new JPanel(gridbag); factEditPanel.setBorder(BorderFactory.createTitledBorder("Set the Slots for the Fact")); if (templateList.SelectedIndex > - 1) { Module module = engine.WorkingMemory.findModule(System.String.valueOf(moduleList.SelectedValue)); Template tmp = module.getTemplate(System.String.valueOf(templateList.SelectedValue)); //UPGRADE_ISSUE: Field 'java.awt.GridBagConstraints.weightx' was not converted. 'ms-help://MS.VSCC.2003/commoner/redir/redirect.htm?keyword="jlca1000_javaawtGridBagConstraints"' c.weightx = 1.0; Slot[] slots = tmp.AllSlots; for (int i = 0; i < slots.Length; ++i) { //UPGRADE_ISSUE: Field 'java.awt.GridBagConstraints.gridx' was not converted. 'ms-help://MS.VSCC.2003/commoner/redir/redirect.htm?keyword="jlca1000_javaawtGridBagConstraints"' c.gridx = 0; //UPGRADE_ISSUE: Field 'java.awt.GridBagConstraints.gridy' was not converted. 'ms-help://MS.VSCC.2003/commoner/redir/redirect.htm?keyword="jlca1000_javaawtGridBagConstraints"' c.gridy = i; //UPGRADE_ISSUE: Field 'java.awt.GridBagConstraints.fill' was not converted. 'ms-help://MS.VSCC.2003/commoner/redir/redirect.htm?keyword="jlca1000_javaawtGridBagConstraints"' //UPGRADE_ISSUE: Field 'java.awt.GridBagConstraints.VERTICAL' was not converted. 'ms-help://MS.VSCC.2003/commoner/redir/redirect.htm?keyword="jlca1000_javaawtGridBagConstraints"' c.fill = GridBagConstraints.VERTICAL; //UPGRADE_ISSUE: Field 'java.awt.GridBagConstraints.anchor' was not converted. 'ms-help://MS.VSCC.2003/commoner/redir/redirect.htm?keyword="jlca1000_javaawtGridBagConstraints"' //UPGRADE_ISSUE: Field 'java.awt.GridBagConstraints.EAST' was not converted. 'ms-help://MS.VSCC.2003/commoner/redir/redirect.htm?keyword="jlca1000_javaawtGridBagConstraints"' c.anchor = GridBagConstraints.EAST; JLabel label = new JLabel(slots[i].Name + ": "); gridbag.setConstraints(label, c); innerPanel.add(label); //UPGRADE_ISSUE: Field 'java.awt.GridBagConstraints.gridx' was not converted. 'ms-help://MS.VSCC.2003/commoner/redir/redirect.htm?keyword="jlca1000_javaawtGridBagConstraints"' c.gridx = 1; //UPGRADE_ISSUE: Field 'java.awt.GridBagConstraints.fill' was not converted. 'ms-help://MS.VSCC.2003/commoner/redir/redirect.htm?keyword="jlca1000_javaawtGridBagConstraints"' //UPGRADE_ISSUE: Field 'java.awt.GridBagConstraints.BOTH' was not converted. 'ms-help://MS.VSCC.2003/commoner/redir/redirect.htm?keyword="jlca1000_javaawtGridBagConstraints"' c.fill = GridBagConstraints.BOTH; //UPGRADE_ISSUE: Field 'java.awt.GridBagConstraints.anchor' was not converted. 'ms-help://MS.VSCC.2003/commoner/redir/redirect.htm?keyword="jlca1000_javaawtGridBagConstraints"' //UPGRADE_ISSUE: Field 'java.awt.GridBagConstraints.WEST' was not converted. 'ms-help://MS.VSCC.2003/commoner/redir/redirect.htm?keyword="jlca1000_javaawtGridBagConstraints"' c.anchor = GridBagConstraints.WEST; if (slots[i] is MultiSlot) { MultiSlotEditor multislotEditor = new MultiSlotEditor(this); JScrollPane scrollPane = new JScrollPane(multislotEditor.List); gridbag.setConstraints(scrollPane, c); innerPanel.add(scrollPane); factComponents.put(slots[i], multislotEditor.List); } else if (slots[i].ValueType == Constants.FACT_TYPE) { // TODO Fact-Selector JComboBox factBox = new JComboBox(); factComponents.put(slots[i], factBox); } else { JTextField textField = new JTextField(); gridbag.setConstraints(textField, c); innerPanel.add(textField); factComponents.put(slots[i], textField); } } } //UPGRADE_ISSUE: Field 'java.awt.BorderLayout.CENTER' was not converted. 'ms-help://MS.VSCC.2003/commoner/redir/redirect.htm?keyword="jlca1000_javaawtBorderLayout"' factEditPanel.add(new JScrollPane(innerPanel), BorderLayout.CENTER); JPanel dumpAreaPanel = new JPanel(); dumpAreaPanel.setLayout(new BoxLayout(dumpAreaPanel, BoxLayout.Y_AXIS)); dumpAreaPanel.add(new JLabel("Fact Preview:")); dumpAreaPanel.add(new JScrollPane(dumpAreaFact)); reloadButtondumpAreaFact = new JButton("Reload Fact Preview", IconLoader.getImageIcon("arrow_refresh")); reloadButtondumpAreaFact.addActionListener(this); dumpAreaPanel.add(reloadButtondumpAreaFact); //UPGRADE_ISSUE: Field 'java.awt.GridBagConstraints.weightx' was not converted. 'ms-help://MS.VSCC.2003/commoner/redir/redirect.htm?keyword="jlca1000_javaawtGridBagConstraints"' c.weightx = 0.0; //UPGRADE_ISSUE: Field 'java.awt.GridBagConstraints.gridwidth' was not converted. 'ms-help://MS.VSCC.2003/commoner/redir/redirect.htm?keyword="jlca1000_javaawtGridBagConstraints"' c.gridwidth = 2; //UPGRADE_ISSUE: Field 'java.awt.GridBagConstraints.gridy' was not converted. 'ms-help://MS.VSCC.2003/commoner/redir/redirect.htm?keyword="jlca1000_javaawtGridBagConstraints"' c.gridy = 1; //UPGRADE_ISSUE: Field 'java.awt.GridBagConstraints.gridx' was not converted. 'ms-help://MS.VSCC.2003/commoner/redir/redirect.htm?keyword="jlca1000_javaawtGridBagConstraints"' c.gridx = 0; //UPGRADE_ISSUE: Field 'java.awt.GridBagConstraints.fill' was not converted. 'ms-help://MS.VSCC.2003/commoner/redir/redirect.htm?keyword="jlca1000_javaawtGridBagConstraints"' //UPGRADE_ISSUE: Field 'java.awt.GridBagConstraints.BOTH' was not converted. 'ms-help://MS.VSCC.2003/commoner/redir/redirect.htm?keyword="jlca1000_javaawtGridBagConstraints"' c.fill = GridBagConstraints.BOTH; gridbag.setConstraints(dumpAreaPanel, c); //UPGRADE_ISSUE: Field 'java.awt.BorderLayout.SOUTH' was not converted. 'ms-help://MS.VSCC.2003/commoner/redir/redirect.htm?keyword="jlca1000_javaawtBorderLayout"' factEditPanel.add(dumpAreaPanel, BorderLayout.SOUTH); contentPanel.add("factEdit", factEditPanel); }
/// <summary> /// Sets up the GUI. </summary> /// <param name="index"> the index in the worksheet to first select </param> private void setupGUI(int index) { string routine = "setupGUI"; addWindowListener(this); JPanel p1 = new JPanel(); // first 6 months' effeciency //JPanel p2 = new JPanel(); // last 6 months' effeciency JPanel p3 = new JPanel(); // div sta id -> switch for diversion JPanel p4 = new JPanel(); // user name -> data type switch JPanel left_panel = new JPanel(); // multilist and search area JPanel right_panel = new JPanel(); // everything else __cropIDJTextField = new JTextField(12); __nameJTextField = new JTextField(24); __plantMonthJTextField = new JTextField(6); __plantDayJTextField = new JTextField(6); __harvestMonthJTextField = new JTextField(6); __harvestDayJTextField = new JTextField(6); __daysToCoverJTextField = new JTextField(6); __seasonLengthJTextField = new JTextField(6); __earliestValueJTextField = new JTextField(6); __latestValueJTextField = new JTextField(6); __maxRootFeetJTextField = new JTextField(6); __maxAppDepthJTextField = new JTextField(6); __firstDaysBetweenJTextField = new JTextField(6); __secondDaysBetweenJTextField = new JTextField(6); IList <string> v = new List <string>(); v.Add(__0_MEAN_TEMP); v.Add(__1_28_DEG_FROST); v.Add(__2_32_DEG_FROST); v.Add(__999_NONE); __earliestFlagComboBox = new SimpleJComboBox(v); __latestFlagComboBox = new SimpleJComboBox(v); __searchID = new JTextField(10); __searchName = new JTextField(10); __searchName.setEditable(false); __findNextCrop = new JButton(__BUTTON_FIND_NEXT); __searchCriteriaGroup = new ButtonGroup(); __searchIDJRadioButton = new JRadioButton(__BUTTON_ID, true); __searchNameJRadioButton = new JRadioButton(__BUTTON_NAME, false); __searchCriteriaGroup.add(__searchIDJRadioButton); __searchCriteriaGroup.add(__searchNameJRadioButton); JButton applyJButton = new JButton(__BUTTON_APPLY); JButton cancelJButton = new JButton(__BUTTON_CANCEL); JButton helpJButton = new JButton(__BUTTON_HELP); helpJButton.setEnabled(false); JButton closeJButton = new JButton(__BUTTON_CLOSE); GridBagLayout gb = new GridBagLayout(); JPanel mainJPanel = new JPanel(); mainJPanel.setLayout(gb); p1.setLayout(new GridLayout(4, 6, 2, 0)); p3.setLayout(gb); p4.setLayout(gb); right_panel.setLayout(gb); left_panel.setLayout(gb); int y; PropList p = new PropList("StateCU_CropCharacteristics_JFrame.JWorksheet"); p.add("JWorksheet.CellFont=Courier"); p.add("JWorksheet.CellStyle=Plain"); p.add("JWorksheet.CellSize=11"); p.add("JWorksheet.HeaderFont=Arial"); p.add("JWorksheet.HeaderStyle=Plain"); p.add("JWorksheet.HeaderSize=11"); p.add("JWorksheet.HeaderBackground=LightGray"); p.add("JWorksheet.RowColumnPresent=false"); p.add("JWorksheet.ShowPopupMenu=true"); p.add("JWorksheet.SelectionMode=SingleRowSelection"); int[] widths = null; try { StateCU_CropCharacteristics_TableModel tmw = new StateCU_CropCharacteristics_TableModel(__cropsVector); StateCU_CropCharacteristics_CellRenderer crw = new StateCU_CropCharacteristics_CellRenderer(tmw); __worksheet = new JWorksheet(crw, tmw, p); __worksheet.removeColumn(3); __worksheet.removeColumn(4); widths = crw.getColumnWidths(); } catch (Exception e) { Message.printWarning(2, routine, e); __worksheet = new JWorksheet(0, 0, p); Console.WriteLine(e.ToString()); Console.Write(e.StackTrace); } __worksheet.setPreferredScrollableViewportSize(null); __worksheet.setHourglassJFrame(this); __worksheet.addMouseListener(this); __worksheet.addKeyListener(this); JGUIUtil.addComponent(left_panel, new JScrollPane(__worksheet), 0, 0, 6, 14, 1, 1, 0, 0, 1, 1, GridBagConstraints.BOTH, GridBagConstraints.CENTER); y = 0; JGUIUtil.addComponent(p3, new JLabel("Crop ID:"), 0, y, 1, 1, 0, 0, 0, 0, 0, 0, GridBagConstraints.NONE, GridBagConstraints.EAST); JGUIUtil.addComponent(p3, __cropIDJTextField, 1, y, 1, 1, 1, 1, 1, 0, 0, 1, GridBagConstraints.NONE, GridBagConstraints.WEST); __cropIDJTextField.setEditable(false); y++; JGUIUtil.addComponent(p3, new JLabel("Name:"), 0, y, 1, 1, 0, 0, 0, 0, 0, 0, GridBagConstraints.NONE, GridBagConstraints.EAST); JGUIUtil.addComponent(p3, __nameJTextField, 1, y, 3, 1, 1, 1, 1, 0, 0, 1, GridBagConstraints.NONE, GridBagConstraints.WEST); y++; JGUIUtil.addComponent(p3, new JLabel("Planting Month and Day:"), 0, y, 1, 1, 0, 0, 0, 0, 0, 0, GridBagConstraints.NONE, GridBagConstraints.EAST); JGUIUtil.addComponent(p3, __plantMonthJTextField, 1, y, 1, 1, 1, 1, 1, 0, 0, 1, GridBagConstraints.NONE, GridBagConstraints.WEST); JGUIUtil.addComponent(p3, __plantDayJTextField, 2, y, 2, 1, 1, 1, 1, 0, 0, 1, GridBagConstraints.NONE, GridBagConstraints.WEST); y++; JGUIUtil.addComponent(p3, new JLabel("Harvest Month and Day:"), 0, y, 1, 1, 0, 0, 0, 0, 0, 0, GridBagConstraints.NONE, GridBagConstraints.EAST); JGUIUtil.addComponent(p3, __harvestMonthJTextField, 1, y, 1, 1, 1, 1, 1, 0, 0, 1, GridBagConstraints.NONE, GridBagConstraints.WEST); JGUIUtil.addComponent(p3, __harvestDayJTextField, 2, y, 2, 1, 1, 1, 1, 0, 0, 1, GridBagConstraints.NONE, GridBagConstraints.WEST); y++; JGUIUtil.addComponent(p3, new JLabel("Days to Full Cover:"), 0, y, 1, 1, 0, 0, 0, 0, 0, 0, GridBagConstraints.NONE, GridBagConstraints.EAST); JGUIUtil.addComponent(p3, __daysToCoverJTextField, 1, y, 1, 1, 1, 1, 1, 0, 0, 1, GridBagConstraints.NONE, GridBagConstraints.WEST); y++; JGUIUtil.addComponent(p3, new JLabel("Length of Season (days):"), 0, y, 1, 1, 0, 0, 0, 0, 0, 0, GridBagConstraints.NONE, GridBagConstraints.EAST); JGUIUtil.addComponent(p3, __seasonLengthJTextField, 1, y, 1, 1, 1, 1, 1, 0, 0, 1, GridBagConstraints.NONE, GridBagConstraints.WEST); y++; JGUIUtil.addComponent(p3, new JLabel("Earliest Moisture Use:"), 0, y, 1, 1, 0, 0, 0, 0, 0, 0, GridBagConstraints.NONE, GridBagConstraints.EAST); JGUIUtil.addComponent(p3, __earliestFlagComboBox, 1, y, 1, 1, 1, 1, 1, 0, 0, 1, GridBagConstraints.NONE, GridBagConstraints.WEST); JGUIUtil.addComponent(p3, new JLabel("Value (F Deg.):"), 2, y, 1, 1, 1, 1, 1, 0, 0, 1, GridBagConstraints.NONE, GridBagConstraints.WEST); JGUIUtil.addComponent(p3, __earliestValueJTextField, 3, y, 1, 1, 1, 1, 1, 0, 0, 1, GridBagConstraints.NONE, GridBagConstraints.WEST); y++; JGUIUtil.addComponent(p3, new JLabel("Latest Moisture Use:"), 0, y, 1, 1, 0, 0, 0, 0, 0, 0, GridBagConstraints.NONE, GridBagConstraints.EAST); JGUIUtil.addComponent(p3, __latestFlagComboBox, 1, y, 1, 1, 1, 1, 1, 0, 0, 1, GridBagConstraints.NONE, GridBagConstraints.WEST); JGUIUtil.addComponent(p3, new JLabel("Value (F Deg.):"), 2, y, 1, 1, 1, 1, 1, 0, 0, 1, GridBagConstraints.NONE, GridBagConstraints.WEST); JGUIUtil.addComponent(p3, __latestValueJTextField, 3, y, 1, 1, 1, 1, 1, 0, 0, 1, GridBagConstraints.NONE, GridBagConstraints.WEST); y++; JGUIUtil.addComponent(p3, new JLabel("Maximum Root Zone (feet):"), 0, y, 1, 1, 0, 0, 0, 0, 0, 0, GridBagConstraints.NONE, GridBagConstraints.EAST); JGUIUtil.addComponent(p3, __maxRootFeetJTextField, 1, y, 1, 1, 1, 1, 1, 0, 0, 1, GridBagConstraints.NONE, GridBagConstraints.WEST); y++; JGUIUtil.addComponent(p3, new JLabel("Maximum Application Depth (inches):"), 0, y, 1, 1, 0, 0, 0, 0, 0, 0, GridBagConstraints.NONE, GridBagConstraints.EAST); JGUIUtil.addComponent(p3, __maxAppDepthJTextField, 1, y, 1, 1, 1, 1, 1, 0, 0, 1, GridBagConstraints.NONE, GridBagConstraints.WEST); y++; JGUIUtil.addComponent(p3, new JLabel("Days between 1st and 2nd cuttings:"), 0, y, 1, 1, 0, 0, 0, 0, 0, 0, GridBagConstraints.NONE, GridBagConstraints.EAST); JGUIUtil.addComponent(p3, __firstDaysBetweenJTextField, 1, y, 1, 1, 1, 1, 1, 0, 0, 1, GridBagConstraints.NONE, GridBagConstraints.WEST); y++; JGUIUtil.addComponent(p3, new JLabel("Days between 2nd and 3rd cuttings:"), 0, y, 1, 1, 0, 0, 0, 0, 0, 0, GridBagConstraints.NONE, GridBagConstraints.EAST); JGUIUtil.addComponent(p3, __secondDaysBetweenJTextField, 1, y, 1, 1, 1, 1, 1, 0, 0, 1, GridBagConstraints.NONE, GridBagConstraints.WEST); // two top panels of info JGUIUtil.addComponent(right_panel, p3, 0, 0, 2, 1, 0, 0, 0, 0, 0, 0, GridBagConstraints.NONE, GridBagConstraints.NORTHWEST); int[] widths2 = null; try { __blaneyModel = new StateCU_CropCharacteristics_TableModel(__cropsVector); StateCU_CropCharacteristics_CellRenderer crw = new StateCU_CropCharacteristics_CellRenderer(__blaneyModel); __coeffWorksheet = new JWorksheet(crw, __blaneyModel, p); __coeffWorksheet.removeColumn(1); __coeffWorksheet.removeColumn(2); widths2 = crw.getColumnWidths(); } catch (Exception e) { Message.printWarning(2, routine, e); __coeffWorksheet = new JWorksheet(0, 0, p); Console.WriteLine(e.ToString()); Console.Write(e.StackTrace); } __coeffWorksheet.setPreferredScrollableViewportSize(null); __coeffWorksheet.setHourglassJFrame(this); JScrollPane jsp = new JScrollPane(__coeffWorksheet); jsp.setBorder(BorderFactory.createTitledBorder(jsp.getBorder(), "Blaney-Criddle Crop Coefficients")); JGUIUtil.addComponent(right_panel, jsp, 0, y, 4, 4, 1, 1, 0, 0, 0, 0, GridBagConstraints.BOTH, GridBagConstraints.NORTHWEST); // add search areas y = 14; JPanel searchPanel = new JPanel(); searchPanel.setLayout(gb); searchPanel.setBorder(BorderFactory.createTitledBorder("Search above list for: ")); JGUIUtil.addComponent(left_panel, searchPanel, 0, y, 4, 1, 0, 0, 10, 10, 0, 0, GridBagConstraints.NONE, GridBagConstraints.WEST); int y2 = 0; JGUIUtil.addComponent(searchPanel, __searchIDJRadioButton, 0, y2, 1, 1, 0, 0, 5, 10, 0, 0, GridBagConstraints.NONE, GridBagConstraints.WEST); __searchIDJRadioButton.addActionListener(this); JGUIUtil.addComponent(searchPanel, __searchID, 1, y2, 1, 1, 1, 0, 0, 0, 0, 0, GridBagConstraints.NONE, GridBagConstraints.EAST); __searchID.addActionListener(this); y2++; JGUIUtil.addComponent(searchPanel, __searchNameJRadioButton, 0, y2, 1, 1, 0, 0, 5, 10, 0, 0, GridBagConstraints.NONE, GridBagConstraints.WEST); __searchNameJRadioButton.addActionListener(this); JGUIUtil.addComponent(searchPanel, __searchName, 1, y2, 1, 1, 1, 0, 0, 0, 0, 0, GridBagConstraints.NONE, GridBagConstraints.EAST); __searchName.addActionListener(this); y2++; JGUIUtil.addComponent(searchPanel, __findNextCrop, 0, y2, 4, 1, 0, 0, 20, 10, 20, 10, GridBagConstraints.NONE, GridBagConstraints.WEST); __findNextCrop.addActionListener(this); // add buttons which lead to crop // direct flow demand, and return flow information FlowLayout fl = new FlowLayout(FlowLayout.CENTER); // add help and close buttons y++; JPanel p6 = new JPanel(); p6.setLayout(fl); if (__editable) { p6.add(applyJButton); p6.add(cancelJButton); } p6.add(helpJButton); p6.add(closeJButton); JGUIUtil.addComponent(right_panel, p6, GridBagConstraints.RELATIVE, y, 4, 1, 1, 0, 30, 0, 0, 0, GridBagConstraints.BOTH, GridBagConstraints.SOUTH); applyJButton.addActionListener(this); cancelJButton.addActionListener(this); helpJButton.addActionListener(this); closeJButton.addActionListener(this); JGUIUtil.addComponent(mainJPanel, left_panel, 0, 0, 4, 10, 1, 1, 10, 10, 10, 0, GridBagConstraints.BOTH, GridBagConstraints.WEST); JGUIUtil.addComponent(mainJPanel, right_panel, GridBagConstraints.RELATIVE, 0, 4, 10, 0, 1, 10, 10, 10, 10, GridBagConstraints.BOTH, GridBagConstraints.EAST); getContentPane().add(mainJPanel); JPanel bottomJPanel = new JPanel(); bottomJPanel.setLayout(gb); __messageJTextField = new JTextField(); __messageJTextField.setEditable(false); JGUIUtil.addComponent(bottomJPanel, __messageJTextField, 0, 0, 7, 1, 1.0, 0.0, GridBagConstraints.HORIZONTAL, GridBagConstraints.WEST); __statusJTextField = new JTextField(5); __statusJTextField.setEditable(false); JGUIUtil.addComponent(bottomJPanel, __statusJTextField, 7, 0, 1, 1, 0.0, 0.0, GridBagConstraints.NONE, GridBagConstraints.WEST); getContentPane().add("South", bottomJPanel); initializeDisables(); // JGUIUtil.center(this); pack(); setSize(850, 620); selectTableIndex(index); setVisible(true); if (widths != null) { __worksheet.setColumnWidths(widths); } if (widths2 != null) { __coeffWorksheet.setColumnWidths(widths2); } }
//-------- //-------- Constructors //-------- /// <summary> /// Constructor a frame to contain the device data. Provide /// the device and the log file name /// </summary> public TagMainFrame() : base("1-Wire Tag Viewer") { // construct the frame //set the look and feel to the system look and feel try { UIManager.LookAndFeel = UIManager.SystemLookAndFeelClassName; } catch (Exception e) { Console.WriteLine(e.ToString()); Console.Write(e.StackTrace); } // add an event listener to end the aplication when the frame is closed addWindowListener(new WindowAdapterAnonymousInnerClassHelper(this, e)); // create the main panel mainPanel = new JPanel(new BorderLayout(10, 10)); // create the sub-pannels northPanel = new JPanel(); northPanel.Border = BorderFactory.createLoweredBevelBorder(); centerPanel = new JPanel(); centerPanel.Layout = new BoxLayout(centerPanel, BoxLayout.Y_AXIS); southPanel = new JPanel(); southPanel.Layout = new BoxLayout(southPanel, BoxLayout.Y_AXIS); southPanel.Border = BorderFactory.createLoweredBevelBorder(); westPanel = new JPanel(); westPanel.Border = BorderFactory.createRaisedBevelBorder(); westPanel.Border = BorderFactory.createEmptyBorder(10, 10, 10, 10); eastPanel = new JPanel(); eastPanel.Border = BorderFactory.createEmptyBorder(10, 10, 10, 10); // fill the panels // north logLabel = new JLabel("Log Filename: "); northPanel.add(logLabel); logField = new JTextField("log.txt", 20); logField.addActionListener(this); northPanel.add(logField); // center listData = new DefaultListModel(); listData.addElement(" "); listData.addElement(" "); listData.addElement(" "); listData.addElement(" "); pathList = new JList(listData); pathList.VisibleRowCount = 5; scrollPanel = new JScrollPane(pathList); scrollPanel.Border = BorderFactory.createTitledBorder(BorderFactory.createEtchedBorder(), "1-Wire Paths to Search"); centerPanel.add(scrollPanel); // west scanCheck = new JCheckBox("Scan 1-Wire Paths for XML Tags", false); scanCheck.addActionListener(this); westPanel.add(scanCheck); // south portLabel = new JLabel("Adapter:"); southPanel.add(portLabel); statusLabel = new JLabel("Status:"); southPanel.add(statusLabel); // add to main mainPanel.add(northPanel, BorderLayout.NORTH); mainPanel.add(centerPanel, BorderLayout.CENTER); mainPanel.add(southPanel, BorderLayout.SOUTH); mainPanel.add(eastPanel, BorderLayout.EAST); mainPanel.add(westPanel, BorderLayout.WEST); // add to frame ContentPane.add(mainPanel); // pack the frame pack(); // resize the window and put in random location Dimension current_sz = Size; Size = new Dimension(current_sz.width * 5 / 4, current_sz.height); Toolkit tool = Toolkit.DefaultToolkit; Dimension mx = tool.ScreenSize; Dimension sz = Size; Random rand = new Random(); setLocation((mx.width - sz.width) / 2, (mx.height - sz.height) / 2); // clear out the listbox data listData.removeAllElements(); // make visible Visible = true; }
public JSConsole(string[] args) : base("Rhino JavaScript Console") { JMenuBar menubar = new JMenuBar(); CreateFileChooser(); string[] fileItems = new string[] { "Load...", "Exit" }; string[] fileCmds = new string[] { "Load", "Exit" }; char[] fileShortCuts = new char[] { 'L', 'X' }; string[] editItems = new string[] { "Cut", "Copy", "Paste" }; char[] editShortCuts = new char[] { 'T', 'C', 'P' }; string[] plafItems = new string[] { "Metal", "Windows", "Motif" }; bool[] plafState = new bool[] { true, false, false }; JMenu fileMenu = new JMenu("File"); fileMenu.SetMnemonic('F'); JMenu editMenu = new JMenu("Edit"); editMenu.SetMnemonic('E'); JMenu plafMenu = new JMenu("Platform"); plafMenu.SetMnemonic('P'); for (int i = 0; i < fileItems.Length; ++i) { JMenuItem item = new JMenuItem(fileItems[i], fileShortCuts[i]); item.SetActionCommand(fileCmds[i]); item.AddActionListener(this); fileMenu.Add(item); } for (int i_1 = 0; i_1 < editItems.Length; ++i_1) { JMenuItem item = new JMenuItem(editItems[i_1], editShortCuts[i_1]); item.AddActionListener(this); editMenu.Add(item); } ButtonGroup group = new ButtonGroup(); for (int i_2 = 0; i_2 < plafItems.Length; ++i_2) { JRadioButtonMenuItem item = new JRadioButtonMenuItem(plafItems[i_2], plafState[i_2]); group.Add(item); item.AddActionListener(this); plafMenu.Add(item); } menubar.Add(fileMenu); menubar.Add(editMenu); menubar.Add(plafMenu); SetJMenuBar(menubar); consoleTextArea = new ConsoleTextArea(args); JScrollPane scroller = new JScrollPane(consoleTextArea); SetContentPane(scroller); consoleTextArea.SetRows(24); consoleTextArea.SetColumns(80); AddWindowListener(new _WindowAdapter_135()); Pack(); SetVisible(true); // System.setIn(consoleTextArea.getIn()); // System.setOut(consoleTextArea.getOut()); // System.setErr(consoleTextArea.getErr()); Program.SetIn(consoleTextArea.GetIn()); Program.SetOut(consoleTextArea.GetOut()); Program.SetErr(consoleTextArea.GetErr()); Program.Main(args); }
public static void main(string[] args) { AudioTool.prefs = Preferences.userRoot().node("/edu/cmu/sphinx/tools/audio/AudioTool"); AudioTool.filename = AudioTool.prefs.get("filename", "untitled.raw"); AudioTool.file = new File(AudioTool.filename); if (args.Length == 1 && String.instancehelper_equals(args[0], "-dumpMixers")) { AudioTool.dumpMixers(); java.lang.System.exit(0); } try { if (args.Length > 0) { AudioTool.filename = args[0]; } URL url; if (args.Length == 2) { url = new File(args[1]).toURI().toURL(); } else { url = ClassLiteral <AudioTool> .Value.getResource("spectrogram.config.xml"); } ConfigurationManager configurationManager = new ConfigurationManager(url); AudioTool.recorder = (Microphone)configurationManager.lookup("microphone"); AudioTool.recorder.initialize(); AudioTool.audio = new AudioData(); FrontEnd frontEnd = (FrontEnd)configurationManager.lookup("frontEnd"); StreamDataSource dataSource = (StreamDataSource)configurationManager.lookup("streamDataSource"); FrontEnd frontEnd2 = (FrontEnd)configurationManager.lookup("cepstrumFrontEnd"); StreamDataSource dataSource2 = (StreamDataSource)configurationManager.lookup("cstreamDataSource"); PropertySheet propertySheet = configurationManager.getPropertySheet("windower"); float @float = propertySheet.getFloat("windowShiftInMs"); JFrame jframe = new JFrame("AudioTool"); AudioTool.fileChooser = new JFileChooser(); AudioTool.createMenuBar(jframe); float num = @float * AudioTool.audio.getAudioFormat().getSampleRate() / 1000f; AudioTool.audioPanel = new AudioPanel(AudioTool.audio, 1f / num, 0.004f); AudioTool.spectrogramPanel = new SpectrogramPanel(frontEnd, dataSource, AudioTool.audio); AudioTool.cepstrumPanel = new CepstrumPanel(frontEnd2, dataSource2, AudioTool.audio); JPanel jpanel = new JPanel(); jpanel.setLayout(new BoxLayout(jpanel, 3)); jpanel.add(AudioTool.audioPanel); AudioTool.audioPanel.setAlignmentX(0f); jpanel.add(AudioTool.spectrogramPanel); AudioTool.spectrogramPanel.setAlignmentX(0f); jpanel.add(AudioTool.cepstrumPanel); AudioTool.cepstrumPanel.setAlignmentX(0f); JScrollPane jscrollPane = new JScrollPane(jpanel); JPanel jpanel2 = new JPanel(new BorderLayout()); jpanel2.add(AudioTool.createButtonPanel(), "North"); jpanel2.add(jscrollPane); AudioTool.player = new AudioPlayer(AudioTool.audio); AudioTool.player.start(); AudioTool.getAudioFromFile(AudioTool.filename); jframe.setDefaultCloseOperation(3); jframe.setContentPane(jpanel2); jframe.pack(); jframe.setSize(640, 400); jframe.setVisible(true); } catch (System.Exception ex) { Throwable.instancehelper_printStackTrace(ex); } }