List of usage examples for javax.swing JLabel setCursor
public void setCursor(Cursor cursor)
From source file:ca.phon.app.session.editor.view.segmentation.SegmentationEditorView.java
private void updateParticipantPanel() { participantPanel.removeAll();/*from w w w . j av a 2 s . c o m*/ // setup layout String colLayout = "fill:default"; String rowLayout = "pref, 5px"; for (int i = 0; i <= getEditor().getSession().getParticipantCount(); i++) { rowLayout += ", pref, 5px"; } FormLayout layout = new FormLayout(colLayout, rowLayout); participantPanel.setLayout(layout); CellConstraints cc = new CellConstraints(); int currentRow = 1; String ksStr = (OSInfo.isMacOs() ? "\u2318" : "CTRL +") + "0"; PhonUIAction noPartSegmentAct = new PhonUIAction(this, "performSegmentation", null); noPartSegmentAct.putValue(Action.NAME, ksStr + " speaker undefined"); // setup labels to be used like buttons String segMsg = "Click name to create a new record:"; JLabel segLbl = new JLabel(segMsg); participantPanel.add(segLbl, cc.xy(1, currentRow)); currentRow += 2; JLabel noPartLbl = new JLabel(); String noPartMsg = ksStr + " <no speaker>"; noPartLbl.setText(noPartMsg); noPartLbl.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR)); noPartLbl.addMouseListener(new SegmentLabelMouseHandler()); noPartLbl.setOpaque(false); participantPanel.add(noPartLbl, cc.xy(1, currentRow)); currentRow += 2; final Session session = getEditor().getSession(); int pIdx = 1; for (Participant p : session.getParticipants()) { ksStr = (OSInfo.isMacOs() ? "\u2318" : "CTRL +") + pIdx; final NewSegmentAction segmentAction = new NewSegmentAction(getEditor(), this, p); segmentAction.putValue(Action.NAME, ksStr + " " + p.toString()); JLabel participantLbl = new JLabel(); String participantStr = ksStr + " " + (p.getName() != null ? p.getName() : p.getId()); participantLbl.setText(participantStr); participantLbl.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR)); participantLbl.addMouseListener(new SegmentLabelMouseHandler(p)); participantLbl.setOpaque(false); participantPanel.add(participantLbl, cc.xy(1, currentRow)); currentRow += 2; pIdx++; } }
From source file:aurelienribon.gdxsetupui.ui.MainPanel.java
private void initUI() { startSetupBtn.addActionListener(new ActionListener() { @Override/*from w ww . j av a2 s .c om*/ public void actionPerformed(ActionEvent e) { showSetupView(); } }); startUpdateBtn.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { showUpdateView(); } }); changeModeBtn.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { showInitView(); } }); JLabel aboutLabel = new JLabel("About this app >"); Style.registerCssClasses(aboutLabel, ".linkLabel"); aboutLabel.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR)); versionLabel.setLayout(new BorderLayout()); versionLabel.add(aboutLabel, BorderLayout.EAST); aboutLabel.addMouseListener(new MouseAdapter() { @Override public void mousePressed(MouseEvent e) { showAboutPanel(); } }); }
From source file:gg.pistol.sweeper.gui.component.DecoratedPanel.java
/** * Helper factory method for creating clickable links. * * @param linkText/*from www .ja v a 2s . co m*/ * a string that will be displayed as a link * @param action * the action performed at click * @return the link component */ protected JComponent createLink(String linkText, final Runnable action) { Preconditions.checkNotNull(linkText); Preconditions.checkNotNull(action); JLabel link = new JLabel("<html><a href=''>" + linkText + "</a></html>"); link.setComponentOrientation(ComponentOrientation.getOrientation(i18n.getLocale())); link.setCursor(new Cursor(Cursor.HAND_CURSOR)); link.addMouseListener(new MouseAdapter() { @Override public void mouseClicked(MouseEvent e) { action.run(); } }); return link; }
From source file:Installer.java
public static JLabel linkify(final String text, String URL, String toolTip) { URI temp = null;// w ww. j a v a 2 s .c om try { temp = new URI(URL); } catch (Exception e) { e.printStackTrace(); } final URI uri = temp; final JLabel link = new JLabel(); link.setText("<HTML><FONT color=\"#000099\">" + text + "</FONT></HTML>"); if (!toolTip.equals("")) link.setToolTipText(toolTip); link.setCursor(new Cursor(Cursor.HAND_CURSOR)); link.addMouseListener(new MouseListener() { public void mouseExited(MouseEvent arg0) { link.setText("<HTML><FONT color=\"#000099\">" + text + "</FONT></HTML>"); } public void mouseEntered(MouseEvent arg0) { link.setText("<HTML><FONT color=\"#000099\"><U>" + text + "</U></FONT></HTML>"); } public void mouseClicked(MouseEvent arg0) { if (Desktop.isDesktopSupported()) { try { Desktop.getDesktop().browse(uri); } catch (Exception e) { e.printStackTrace(); } } else { JOptionPane pane = new JOptionPane("Could not open link."); JDialog dialog = pane.createDialog(new JFrame(), ""); dialog.setVisible(true); } } public void mousePressed(MouseEvent e) { } public void mouseReleased(MouseEvent e) { } }); return link; }
From source file:com.sshtools.common.ui.SshToolsApplication.java
/** * Show an 'About' dialog//from www. j a v a 2 s . co m * * */ public void showAbout(final Component parent) { JPanel p = new JPanel(new GridBagLayout()); p.setBorder(BorderFactory.createEmptyBorder(4, 4, 4, 4)); GridBagConstraints gBC = new GridBagConstraints(); gBC.anchor = GridBagConstraints.CENTER; gBC.fill = GridBagConstraints.HORIZONTAL; gBC.insets = new Insets(1, 1, 1, 1); JLabel a = new JLabel(getApplicationName()); a.setFont(a.getFont().deriveFont(24f)); UIUtil.jGridBagAdd(p, a, gBC, GridBagConstraints.REMAINDER); MultilineLabel v = new MultilineLabel(getApplicationName() + " " + getApplicationVersion()); v.setFont(v.getFont().deriveFont(10f)); UIUtil.jGridBagAdd(p, v, gBC, GridBagConstraints.REMAINDER); MultilineLabel x = new MultilineLabel(getAboutAuthors()); x.setBorder(BorderFactory.createEmptyBorder(8, 0, 8, 0)); x.setFont(x.getFont().deriveFont(12f)); UIUtil.jGridBagAdd(p, x, gBC, GridBagConstraints.REMAINDER); MultilineLabel c = new MultilineLabel(getAboutLicenseDetails()); c.setFont(c.getFont().deriveFont(10f)); UIUtil.jGridBagAdd(p, c, gBC, GridBagConstraints.REMAINDER); final JLabel h = new JLabel(getAboutURL()); h.setForeground(Color.blue); h.setFont(new Font(h.getFont().getName(), Font.BOLD, 10)); h.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR)); h.addMouseListener(new MouseAdapter() { public void mouseClicked(MouseEvent evt) { try { BrowserLauncher.openURL(getAboutURL()); } catch (IOException ioe) { ioe.printStackTrace(); } } }); UIUtil.jGridBagAdd(p, h, gBC, GridBagConstraints.REMAINDER); JOptionPane.showMessageDialog(parent, p, "About", JOptionPane.PLAIN_MESSAGE, getApplicationLargeIcon()); }
From source file:com.sshtools.appframework.ui.SshToolsApplication.java
/** * Show an 'About' dialog// ww w . j a va2 s .c o m */ public void showAbout(Component parent) { JPanel p = new JPanel(new GridBagLayout()); p.setBorder(BorderFactory.createEmptyBorder(4, 4, 4, 4)); GridBagConstraints gBC = new GridBagConstraints(); gBC.anchor = GridBagConstraints.CENTER; gBC.fill = GridBagConstraints.HORIZONTAL; gBC.insets = new Insets(1, 1, 1, 1); JLabel a = new JLabel(getApplicationName()); a.setFont(a.getFont().deriveFont(24f)); UIUtil.jGridBagAdd(p, a, gBC, GridBagConstraints.REMAINDER); JLabel v = new JLabel("Version " + getApplicationVersion()); v.setFont(v.getFont().deriveFont(10f)); UIUtil.jGridBagAdd(p, v, gBC, GridBagConstraints.REMAINDER); MultilineLabel x = new MultilineLabel(getAboutLicenseDetails()); x.setBorder(BorderFactory.createEmptyBorder(8, 0, 8, 0)); x.setFont(x.getFont().deriveFont(12f)); UIUtil.jGridBagAdd(p, x, gBC, GridBagConstraints.REMAINDER); MultilineLabel c = new MultilineLabel(getExpiryInfo()); c.setFont(c.getFont().deriveFont(10f)); UIUtil.jGridBagAdd(p, c, gBC, GridBagConstraints.REMAINDER); final JLabel h = new JLabel(getAboutURL()); h.setForeground(Color.blue); h.setFont(new Font(h.getFont().getName(), Font.BOLD, 10)); h.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR)); h.addMouseListener(new MouseAdapter() { @Override public void mouseClicked(MouseEvent evt) { try { BrowserLauncher.openURL(getAboutURL()); } catch (IOException ioe) { ioe.printStackTrace(); } } }); UIUtil.jGridBagAdd(p, h, gBC, GridBagConstraints.REMAINDER); JOptionPane.showMessageDialog(parent, p, "About", JOptionPane.PLAIN_MESSAGE, getApplicationLargeIcon()); }
From source file:de.whiledo.iliasdownloader2.swing.service.MainController.java
protected void showInfo() { JPanel panel = new JPanel(new BorderLayout()); panel.add(/*from ww w. j a v a 2s. c o m*/ new JLabel( "<html>Kevin Krummenauer 2015<br><br>Icons by http://jonasraskdesign.com<br><br></html>"), BorderLayout.NORTH); JLabel link = new JLabel("Kontakt: " + EMAIL); link.addMouseListener(new MouseAdapter() { @Override public void mouseClicked(MouseEvent e) { openEMail(); } }); link.setCursor(new Cursor(Cursor.HAND_CURSOR)); link.setForeground(Color.BLUE); panel.add(link, BorderLayout.CENTER); JPanel panel2 = new JPanel(new GridLayout(0, 1, 4, 4)); { panel2.add(new JLabel("<html><b>Libraries and its licenses</b> (click to open)</html>"), BorderLayout.NORTH); val list = Arrays.asList( new TwoObjectsX<String, String>("ILIAS Downloader 2", ServiceFunctions.ILIASDOWNLOADER_WEBSITE_LICENSE), new TwoObjectsX<String, String>("Java JDK 8", "http://www.oracle.com/technetwork/java/javase/terms/license/index.html"), new TwoObjectsX<String, String>("Apache Commons IO und Apache Commons Codec", "apache_license.txt"), new TwoObjectsX<String, String>("Project Lombok", "lombok_license.txt"), new TwoObjectsX<String, String>("KSOAP2", "ksoap2_android.txt"), new TwoObjectsX<String, String>("Simple XML Serialization", "apache_license.txt")); for (val lib : list) { link = new JLabel(lib.getObjectA()); if (lib.getObjectB() != null) { link.addMouseListener(new MouseAdapter() { @Override public void mouseClicked(MouseEvent e) { String s = lib.getObjectB(); try { if (s.toLowerCase().startsWith("http")) { Desktop.getDesktop().browse(new URI(s)); } else { showLicense(s); } } catch (Exception e1) { showError("Lizenz nicht gefunden: " + s, e1); } } }); link.setCursor(new Cursor(Cursor.HAND_CURSOR)); link.setForeground(Color.BLUE); } panel2.add(link); } } panel.add(panel2, BorderLayout.SOUTH); JOptionPane.showMessageDialog(mainFrame, panel, "Info " + APP_NAME, JOptionPane.INFORMATION_MESSAGE); }
From source file:userinterface.properties.GUIGraphHandler.java
public void plotNewFunction() { JDialog dialog;/*w w w . j a v a2 s.com*/ JRadioButton radio2d, radio3d, newGraph, existingGraph; JTextField functionField, seriesName; JButton ok, cancel; JComboBox<String> chartOptions; JLabel example; //init all the fields of the dialog dialog = new JDialog(GUIPrism.getGUI()); radio2d = new JRadioButton("2D"); radio3d = new JRadioButton("3D"); newGraph = new JRadioButton("New Graph"); existingGraph = new JRadioButton("Exisiting"); chartOptions = new JComboBox<String>(); functionField = new JTextField(); ok = new JButton("Plot"); cancel = new JButton("Cancel"); seriesName = new JTextField(); example = new JLabel("<html><font size=3 color=red>Example:</font><font size=3>x/2 + 5</font></html>"); example.addMouseListener(new MouseAdapter() { @Override public void mouseEntered(MouseEvent e) { example.setCursor(new Cursor(Cursor.HAND_CURSOR)); example.setForeground(Color.BLUE); } @Override public void mouseExited(MouseEvent e) { example.setCursor(new Cursor(Cursor.DEFAULT_CURSOR)); example.setForeground(Color.BLACK); } @Override public void mouseClicked(MouseEvent e) { if (e.getButton() == MouseEvent.BUTTON1) { if (radio2d.isSelected()) { functionField.setText("x/2 + 5"); } else { functionField.setText("x+y+5"); } functionField.setFont(new Font(Font.SANS_SERIF, Font.PLAIN, 15)); functionField.setForeground(Color.BLACK); } } }); //set dialog properties dialog.setSize(400, 350); dialog.setTitle("Plot a new function"); dialog.setModal(true); dialog.setLayout(new BoxLayout(dialog.getContentPane(), BoxLayout.Y_AXIS)); dialog.setLocationRelativeTo(GUIPrism.getGUI()); //add every component to their dedicated panels JPanel graphTypePanel = new JPanel(new FlowLayout()); graphTypePanel.setBorder(BorderFactory .createTitledBorder(BorderFactory.createEtchedBorder(EtchedBorder.LOWERED), "Function type")); graphTypePanel.add(radio2d); graphTypePanel.add(radio3d); JPanel functionFieldPanel = new JPanel(new BorderLayout()); functionFieldPanel.setBorder(BorderFactory .createTitledBorder(BorderFactory.createEtchedBorder(EtchedBorder.LOWERED), "Function")); functionFieldPanel.add(functionField, BorderLayout.CENTER); functionFieldPanel.add(example, BorderLayout.SOUTH); JPanel chartSelectPanel = new JPanel(); chartSelectPanel.setLayout(new BoxLayout(chartSelectPanel, BoxLayout.Y_AXIS)); chartSelectPanel.setBorder(BorderFactory .createTitledBorder(BorderFactory.createEtchedBorder(EtchedBorder.LOWERED), "Plot function to")); JPanel radioPlotPanel = new JPanel(new FlowLayout()); radioPlotPanel.add(newGraph); radioPlotPanel.add(existingGraph); JPanel chartOptionsPanel = new JPanel(new FlowLayout()); chartOptionsPanel.add(chartOptions); chartSelectPanel.add(radioPlotPanel); chartSelectPanel.add(chartOptionsPanel); JPanel bottomControlPanel = new JPanel(new FlowLayout(FlowLayout.RIGHT)); bottomControlPanel.add(ok); bottomControlPanel.add(cancel); JPanel seriesNamePanel = new JPanel(new BorderLayout()); seriesNamePanel.setBorder(BorderFactory .createTitledBorder(BorderFactory.createEtchedBorder(EtchedBorder.LOWERED), "Series name")); seriesNamePanel.add(seriesName, BorderLayout.CENTER); // add all the panels to the dialog dialog.add(graphTypePanel); dialog.add(functionFieldPanel); dialog.add(chartSelectPanel); dialog.add(seriesNamePanel); dialog.add(bottomControlPanel); // do all the enables and set properties radio2d.setSelected(true); newGraph.setSelected(true); chartOptions.setEnabled(false); functionField.setText("Add function expression here...."); functionField.setFont(new Font(Font.SANS_SERIF, Font.ITALIC, 15)); functionField.setForeground(Color.GRAY); seriesName.setText("New function"); ok.setMnemonic('P'); cancel.setMnemonic('C'); example.setToolTipText("click to try out"); ok.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put(KeyStroke.getKeyStroke(KeyEvent.VK_ENTER, 0), "ok"); ok.getActionMap().put("ok", new AbstractAction() { @Override public void actionPerformed(ActionEvent e) { ok.doClick(); } }); cancel.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put(KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0), "cancel"); cancel.getActionMap().put("cancel", new AbstractAction() { @Override public void actionPerformed(ActionEvent e) { cancel.doClick(); } }); boolean found = false; for (int i = 0; i < theTabs.getTabCount(); i++) { if (theTabs.getComponentAt(i) instanceof Graph) { chartOptions.addItem(getGraphName(i)); found = true; } } if (!found) { existingGraph.setEnabled(false); chartOptions.setEnabled(false); } //add all the action listeners radio2d.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { if (radio2d.isSelected()) { radio3d.setSelected(false); if (chartOptions.getItemCount() > 0) { existingGraph.setEnabled(true); chartOptions.setEnabled(true); } example.setText( "<html><font size=3 color=red>Example:</font><font size=3>x/2 + 5</font></html>"); } } }); radio3d.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { if (radio3d.isSelected()) { radio2d.setSelected(false); newGraph.setSelected(true); existingGraph.setEnabled(false); chartOptions.setEnabled(false); example.setText("<html><font size=3 color=red>Example:</font><font size=3>x+y+5</font></html>"); } } }); newGraph.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { if (newGraph.isSelected()) { existingGraph.setSelected(false); chartOptions.setEnabled(false); } } }); existingGraph.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { if (existingGraph.isSelected()) { newGraph.setSelected(false); chartOptions.setEnabled(true); } } }); ok.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { String function = functionField.getText(); Expression expr = null; try { expr = GUIPrism.getGUI().getPrism().parseSingleExpressionString(function); expr = (Expression) expr.accept(new ASTTraverseModify() { @Override public Object visit(ExpressionIdent e) throws PrismLangException { return new ExpressionConstant(e.getName(), TypeDouble.getInstance()); } }); expr.typeCheck(); expr.semanticCheck(); } catch (PrismLangException e1) { // for copying style JLabel label = new JLabel(); // html content in our case the error we want to show JEditorPane ep = new JEditorPane("text/html", "<html> There was an error parsing the function. To read about what built-in" + " functions are supported <br>and some more information on the functions, visit " + "<a href='http://www.prismmodelchecker.org/manual/ThePRISMLanguage/Expressions'>Prism expressions site</a>." + "<br><br><font color=red>Error: </font>" + e1.getMessage() + " </html>"); // handle link events ep.addHyperlinkListener(new HyperlinkListener() { @Override public void hyperlinkUpdate(HyperlinkEvent e) { if (e.getEventType().equals(HyperlinkEvent.EventType.ACTIVATED)) { try { Desktop.getDesktop().browse(e.getURL().toURI()); } catch (IOException | URISyntaxException e1) { e1.printStackTrace(); } } } }); ep.setEditable(false); ep.setBackground(label.getBackground()); // show the error dialog JOptionPane.showMessageDialog(dialog, ep, "Parse Error", JOptionPane.ERROR_MESSAGE); return; } if (radio2d.isSelected()) { ParametricGraph graph = null; if (newGraph.isSelected()) { graph = new ParametricGraph(""); } else { for (int i = 0; i < theTabs.getComponentCount(); i++) { if (theTabs.getTitleAt(i).equals(chartOptions.getSelectedItem())) { graph = (ParametricGraph) theTabs.getComponent(i); } } } dialog.dispose(); defineConstantsAndPlot(expr, graph, seriesName.getText(), newGraph.isSelected(), true); } else if (radio3d.isSelected()) { try { expr = (Expression) expr.accept(new ASTTraverseModify() { @Override public Object visit(ExpressionIdent e) throws PrismLangException { return new ExpressionConstant(e.getName(), TypeDouble.getInstance()); } }); expr.semanticCheck(); expr.typeCheck(); } catch (PrismLangException e1) { e1.printStackTrace(); } if (expr.getAllConstants().size() < 2) { JOptionPane.showMessageDialog(dialog, "There are not enough variables in the function to plot a 3D chart!", "Error", JOptionPane.ERROR_MESSAGE); return; } // its always a new graph ParametricGraph3D graph = new ParametricGraph3D(expr); dialog.dispose(); defineConstantsAndPlot(expr, graph, seriesName.getText(), true, false); } dialog.dispose(); } }); cancel.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { dialog.dispose(); } }); // we will show info about the function when field is out of focus functionField.addFocusListener(new FocusListener() { @Override public void focusLost(FocusEvent e) { if (!functionField.getText().equals("")) { return; } functionField.setText("Add function expression here...."); functionField.setFont(new Font(Font.SANS_SERIF, Font.ITALIC, 15)); functionField.setForeground(Color.GRAY); } @Override public void focusGained(FocusEvent e) { if (!functionField.getText().equals("Add function expression here....")) { return; } functionField.setForeground(Color.BLACK); functionField.setFont(new Font(Font.SANS_SERIF, Font.PLAIN, 15)); functionField.setText(""); } }); // show the dialog dialog.setVisible(true); }
From source file:Tcpbw100.java
public void testResults(String tmpstr) { StringTokenizer tokens;/*w ww .j a v a2 s .c om*/ int i = 0; String sysvar, strval; int sysval, Zero = 0, bwdelay, minwin; double sysval2, j; String osName, osArch, osVer, javaVer, javaVendor, client; tokens = new StringTokenizer(tmpstr); sysvar = null; strval = null; while (tokens.hasMoreTokens()) { if (++i % 2 == 1) { sysvar = tokens.nextToken(); } else { strval = tokens.nextToken(); diagnosis.append(sysvar + " " + strval + "\n"); //we load all the key value pairs to the report, too //may come in handy in the future //TODO: strip the trailing ':' from sysvar report.put("web100_" + sysvar.replaceAll(":$", ""), strval); emailText += sysvar + " " + strval + "\n%0A"; if (strval.indexOf(".") == -1) { sysval = Integer.parseInt(strval); save_int_values(sysvar, sysval); } else { sysval2 = Double.valueOf(strval).doubleValue(); save_dbl_values(sysvar, sysval2); } } } // Grab some client details from the applet environment osName = System.getProperty("os.name"); pub_osName = osName; osArch = System.getProperty("os.arch"); pub_osArch = osArch; osVer = System.getProperty("os.version"); pub_osVer = osVer; javaVer = System.getProperty("java.version"); pub_javaVer = javaVer; javaVendor = System.getProperty("java.vendor"); if (osArch.startsWith("x86") == true) { client = messages.getString("pc"); } else { client = messages.getString("workstation"); } // Calculate some variables and determine path conditions // Note: calculations now done in server and the results are shipped // back to the client for printing. if (CountRTT > 0) { // Now write some messages to the screen if (c2sData < 3) { if (c2sData < 0) { results.append(messages.getString("unableToDetectBottleneck") + "\n"); emailText += "Server unable to determine bottleneck link type.\n%0A"; pub_AccessTech = "Connection type unknown"; } else { results.append(messages.getString("your") + " " + client + " " + messages.getString("connectedTo") + " "); emailText += messages.getString("your") + " " + client + " " + messages.getString("connectedTo") + " "; if (c2sData == 1) { results.append(messages.getString("dialup") + "\n"); emailText += messages.getString("dialup") + "\n%0A"; mylink = .064; pub_AccessTech = "Dial-up Modem"; } else { results.append(messages.getString("cabledsl") + "\n"); emailText += messages.getString("cabledsl") + "\n%0A"; mylink = 3; pub_AccessTech = "Cable/DSL modem"; } } } else { results.append(messages.getString("theSlowestLink") + " "); emailText += messages.getString("theSlowestLink") + " "; if (c2sData == 3) { results.append(messages.getString("10mbps") + "\n"); emailText += messages.getString("10mbps") + "\n%0A"; mylink = 10; pub_AccessTech = "10 Mbps Ethernet"; } else if (c2sData == 4) { results.append(messages.getString("45mbps") + "\n"); emailText += messages.getString("45mbps") + "\n%0A"; mylink = 45; pub_AccessTech = "45 Mbps T3/DS3 subnet"; } else if (c2sData == 5) { results.append("100 Mbps "); emailText += "100 Mbps "; mylink = 100; pub_AccessTech = "100 Mbps Ethernet"; if (half_duplex == 0) { results.append(messages.getString("fullDuplex") + "\n"); emailText += messages.getString("fullDuplex") + "\n%0A"; } else { results.append(messages.getString("halfDuplex") + "\n"); emailText += messages.getString("halfDuplex") + "\n%0A"; } } else if (c2sData == 6) { results.append(messages.getString("622mbps") + "\n"); emailText += messages.getString("622mbps") + "\n%0A"; mylink = 622; pub_AccessTech = "622 Mbps OC-12"; } else if (c2sData == 7) { results.append(messages.getString("1gbps") + "\n"); emailText += messages.getString("1gbps") + "\n%0A"; mylink = 1000; pub_AccessTech = "1.0 Gbps Gigabit Ethernet"; } else if (c2sData == 8) { results.append(messages.getString("2.4gbps") + "\n"); emailText += messages.getString("2.4gbps") + "\n%0A"; mylink = 2400; pub_AccessTech = "2.4 Gbps OC-48"; } else if (c2sData == 9) { results.append(messages.getString("10gbps") + "\n"); emailText += messages.getString("10gbps") + "\n%0A"; mylink = 10000; pub_AccessTech = "10 Gigabit Ethernet/OC-192"; } } if (mismatch == 1) { results.append(messages.getString("oldDuplexMismatch") + "\n"); emailText += messages.getString("oldDuplexMismatch") + "\n%0A"; } else if (mismatch == 2) { results.append(messages.getString("duplexFullHalf") + "\n"); emailText += messages.getString("duplexFullHalf") + "\n%0A"; } else if (mismatch == 4) { results.append(messages.getString("possibleDuplexFullHalf") + "\n"); emailText += messages.getString("possibleDuplexFullHalf") + "\n%0A"; } else if (mismatch == 3) { results.append(messages.getString("duplexHalfFull") + "\n"); emailText += messages.getString("duplexHalfFull") + "\n%0A"; } else if (mismatch == 5) { results.append(messages.getString("possibleDuplexHalfFull") + "\n"); emailText += messages.getString("possibleDuplexHalfFull") + "\n%0A"; } else if (mismatch == 7) { results.append(messages.getString("possibleDuplexHalfFullWarning") + "\n"); emailText += messages.getString("possibleDuplexHalfFullWarning") + "\n%0A"; } if (mismatch == 0) { if (bad_cable == 1) { results.append(messages.getString("excessiveErrors ") + "\n"); emailText += messages.getString("excessiveErrors") + "\n%0A"; } if (congestion == 1) { results.append(messages.getString("otherTraffic") + "\n"); emailText += messages.getString("otherTraffic") + "\n%0A"; } if (((2 * rwin) / rttsec) < mylink) { j = (float) ((mylink * avgrtt) * 1000) / 8 / 1024; if (j > (float) MaxRwinRcvd) { results.append(messages.getString("receiveBufferShouldBe") + " " + prtdbl(j) + messages.getString("toMaximizeThroughput") + " \n"); emailText += messages.getString("receiveBufferShouldBe") + " " + prtdbl(j) + messages.getString("toMaximizeThroughput") + "\n%0A"; } } } if ((tests & TEST_C2S) == TEST_C2S) { if (sc2sspd < (c2sspd * (1.0 - VIEW_DIFF))) { // TODO: distinguish the host buffering from the middleboxes buffering JLabel info = new JLabel(messages.getString("information")); info.addMouseListener(new MouseAdapter() { public void mouseClicked(MouseEvent e) { showBufferedBytesInfo(); } }); info.setForeground(Color.BLUE); info.setCursor(new Cursor(Cursor.HAND_CURSOR)); info.setAlignmentY((float) 0.8); results.insertComponent(info); results.append(messages.getString("c2sPacketQueuingDetected") + "\n"); } } if ((tests & TEST_S2C) == TEST_S2C) { if (s2cspd < (ss2cspd * (1.0 - VIEW_DIFF))) { // TODO: distinguish the host buffering from the middleboxes buffering JLabel info = new JLabel(messages.getString("information")); info.addMouseListener(new MouseAdapter() { public void mouseClicked(MouseEvent e) { showBufferedBytesInfo(); } }); info.setForeground(Color.BLUE); info.setCursor(new Cursor(Cursor.HAND_CURSOR)); info.setAlignmentY((float) 0.8); results.insertComponent(info); results.append(messages.getString("s2cPacketQueuingDetected") + "\n"); } } statistics.append("\n\t------ " + messages.getString("clientInfo") + "------\n"); statistics.append(messages.getString("osData") + " " + messages.getString("name") + " = " + osName + ", " + messages.getString("architecture") + " = " + osArch); statistics.append(", " + messages.getString("version") + " = " + osVer + "\n"); statistics.append(messages.getString("javaData") + ": " + messages.getString("vendor") + " = " + javaVendor + ", " + messages.getString("version") + " = " + javaVer + "\n"); report.put("os_name", osName); report.put("os_architecture", osArch); report.put("os_version", osVer); statistics.append("Java data: Vendor = " + javaVendor + ", Version = " + javaVer + "\n"); report.put("java_vendor", javaVendor); report.put("java_version", javaVer); // statistics.append(" java.class.version=" + System.getProperty("java.class.version") + "\n"); statistics.append("\n\t------ " + messages.getString("web100Details") + " ------\n"); if (c2sData == -2) statistics.append(messages.getString("insufficient") + "\n"); else if (c2sData == -1) statistics.append(messages.getString("ipcFail") + "\n"); else if (c2sData == 0) statistics.append(messages.getString("rttFail") + "\n"); else if (c2sData == 1) statistics.append(messages.getString("foundDialup") + "\n"); else if (c2sData == 2) statistics.append(messages.getString("foundDsl") + "\n"); else if (c2sData == 3) statistics.append(messages.getString("found10mbps") + "\n"); else if (c2sData == 4) statistics.append(messages.getString("found45mbps") + "\n"); else if (c2sData == 5) statistics.append(messages.getString("found100mbps") + "\n"); else if (c2sData == 6) statistics.append(messages.getString("found622mbps") + "\n"); else if (c2sData == 7) statistics.append(messages.getString("found1gbps") + "\n"); else if (c2sData == 8) statistics.append(messages.getString("found2.4gbps") + "\n"); else if (c2sData == 9) statistics.append(messages.getString("found10gbps") + "\n"); if (half_duplex == 0) statistics.append(messages.getString("linkFullDpx") + "\n"); else statistics.append(messages.getString("linkHalfDpx") + "\n"); if (congestion == 0) statistics.append(messages.getString("congestNo") + "\n"); else statistics.append(messages.getString("congestYes") + "\n"); if (bad_cable == 0) statistics.append(messages.getString("cablesOk") + "\n"); else statistics.append(messages.getString("cablesNok") + "\n"); if (mismatch == 0) statistics.append(messages.getString("duplexOk") + "\n"); else if (mismatch == 1) { statistics.append(messages.getString("duplexNok") + " "); emailText += messages.getString("duplexNok") + " "; } else if (mismatch == 2) { statistics.append(messages.getString("duplexFullHalf") + "\n"); emailText += messages.getString("duplexFullHalf") + "\n%0A "; } else if (mismatch == 3) { statistics.append(messages.getString("duplexHalfFull") + "\n"); emailText += messages.getString("duplexHalfFull") + "\n%0A "; } statistics.append("\n" + messages.getString("web100rtt") + " = " + prtdbl(avgrtt) + " " + "ms" + "; "); emailText += "\n%0A" + messages.getString("web100rtt") + " = " + prtdbl(avgrtt) + " " + "ms" + "; "; statistics.append(messages.getString("packetsize") + " = " + CurrentMSS + " " + messages.getString("bytes") + "; " + messages.getString("and") + " \n"); emailText += messages.getString("packetsize") + " = " + CurrentMSS + " " + messages.getString("bytes") + "; " + messages.getString("and") + " \n%0A"; report.put("rtt", prtdbl(avgrtt)); rttLbl.setText(prtdbl(avgrtt)); rttLbl.setText(String.format(padding + "%.0f msec", avgrtt)); report.put("mss", Integer.toString(CurrentMSS)); report.put("retransmissions", Integer.toString(PktsRetrans)); report.put("sack_blocks", Integer.toString(SACKsRcvd)); report.put("duplicate_acks", Integer.toString(DupAcksIn)); report.put("timeouts", Integer.toString(Timeouts)); report.put("wait_seconds", Double.toString(waitsec)); report.put("out_of_order", Double.toString(order)); report.put("loss", Double.toString(loss)); report.put("jitter", get_jitter()); lossLbl.setText(String.format(padding + "%.0f %%", loss * 100)); jitterLbl.setText(padding + get_jitter() + " msec"); if (PktsRetrans > 0) { statistics.append(PktsRetrans + " " + messages.getString("pktsRetrans")); statistics.append(", " + DupAcksIn + " " + messages.getString("dupAcksIn")); statistics.append(", " + messages.getString("and") + " " + SACKsRcvd + " " + messages.getString("sackReceived") + "\n"); emailText += PktsRetrans + " " + messages.getString("pktsRetrans"); emailText += ", " + DupAcksIn + " " + messages.getString("dupAcksIn"); emailText += ", " + messages.getString("and") + " " + SACKsRcvd + " " + messages.getString("sackReceived") + "\n%0A"; if (Timeouts > 0) { statistics.append(messages.getString("connStalled") + " " + Timeouts + " " + messages.getString("timesPktLoss") + "\n"); } statistics.append(messages.getString("connIdle") + " " + prtdbl(waitsec) + " " + messages.getString("seconds") + " (" + prtdbl((waitsec / timesec) * 100) + messages.getString("pctOfTime") + ")\n"); emailText += messages.getString("connStalled") + " " + Timeouts + " " + messages.getString("timesPktLoss") + "\n%0A"; emailText += messages.getString("connIdle") + " " + prtdbl(waitsec) + " " + messages.getString("seconds") + " (" + prtdbl((waitsec / timesec) * 100) + messages.getString("pctOfTime") + ")\n%0A"; } else if (DupAcksIn > 0) { statistics.append(messages.getString("noPktLoss1") + " - "); statistics.append(messages.getString("ooOrder") + " " + prtdbl(order * 100) + messages.getString("pctOfTime") + "\n"); emailText += messages.getString("noPktLoss1") + " - "; emailText += messages.getString("ooOrder") + " " + prtdbl(order * 100) + messages.getString("pctOfTime") + "\n%0A"; } else { statistics.append(messages.getString("noPktLoss2") + ".\n"); emailText += messages.getString("noPktLoss2") + ".\n%0A"; } if ((tests & TEST_C2S) == TEST_C2S) { if (c2sspd > sc2sspd) { if (sc2sspd < (c2sspd * (1.0 - VIEW_DIFF))) { statistics.append(messages.getString("c2s") + " " + messages.getString("qSeen") + ": " + prtdbl(100 * (c2sspd - sc2sspd) / c2sspd) + "%\n"); } else { statistics.append(messages.getString("c2s") + " " + messages.getString("qSeen") + ": " + prtdbl(100 * (c2sspd - sc2sspd) / c2sspd) + "%\n"); } } } if ((tests & TEST_S2C) == TEST_S2C) { if (ss2cspd > s2cspd) { if (s2cspd < (ss2cspd * (1.0 - VIEW_DIFF))) { statistics.append(messages.getString("s2c") + " " + messages.getString("qSeen") + ": " + prtdbl(100 * (ss2cspd - s2cspd) / ss2cspd) + "%\n"); } else { statistics.append(messages.getString("s2c") + " " + messages.getString("qSeen") + ": " + prtdbl(100 * (ss2cspd - s2cspd) / ss2cspd) + "%\n"); } } } if (rwintime > .015) { statistics.append(messages.getString("thisConnIs") + " " + messages.getString("limitRx") + " " + prtdbl(rwintime * 100) + messages.getString("pctOfTime") + ".\n"); emailText += messages.getString("thisConnIs") + " " + messages.getString("limitRx") + " " + prtdbl(rwintime * 100) + messages.getString("pctOfTime") + ".\n%0A"; pub_pctRcvrLimited = rwintime * 100; // I think there is a bug here, it sometimes tells you to increase the buffer // size, but the new size is smaller than the current. if (((2 * rwin) / rttsec) < mylink) { statistics.append(" " + messages.getString("incrRxBuf") + " (" + prtdbl(MaxRwinRcvd / 1024) + " KB) " + messages.getString("willImprove") + "\n"); } } if (sendtime > .015) { statistics.append(messages.getString("thisConnIs") + " " + messages.getString("limitTx") + " " + prtdbl(sendtime * 100) + messages.getString("pctOfTime") + ".\n"); emailText += messages.getString("thisConnIs") + " " + messages.getString("limitTx") + " " + prtdbl(sendtime * 100) + messages.getString("pctOfTime") + ".\n%0A"; if ((2 * (swin / rttsec)) < mylink) { statistics.append(" " + messages.getString("incrTxBuf") + " (" + prtdbl(Sndbuf / 2048) + " KB) " + messages.getString("willImprove") + "\n"); } } if (cwndtime > .005) { statistics.append(messages.getString("thisConnIs") + " " + messages.getString("limitNet") + " " + prtdbl(cwndtime * 100) + messages.getString("pctOfTime") + ".\n"); emailText += messages.getString("thisConnIs") + " " + messages.getString("limitNet") + " " + prtdbl(cwndtime * 100) + messages.getString("pctOfTime") + ".\n%0A"; // if (cwndtime > .15) // statistics.append(" Contact your local network administrator to report a network problem\n"); // if (order > .15) // statistics.append(" Contact your local network admin and report excessive packet reordering\n"); } if ((spd < 4) && (loss > .01)) { statistics.append(messages.getString("excLoss") + "\n"); } statistics.append("\n" + messages.getString("web100tcpOpts") + " \n"); statistics.append("RFC 2018 Selective Acknowledgment: "); if (SACKEnabled == Zero) statistics.append(messages.getString("off") + "\n"); else statistics.append(messages.getString("on") + "\n"); statistics.append("RFC 896 Nagle Algorithm: "); if (NagleEnabled == Zero) statistics.append(messages.getString("off") + "\n"); else statistics.append(messages.getString("on") + "\n"); statistics.append("RFC 3168 Explicit Congestion Notification: "); if (ECNEnabled == Zero) statistics.append(messages.getString("off") + "\n"); else statistics.append(messages.getString("on") + "\n"); statistics.append("RFC 1323 Time Stamping: "); if (TimestampsEnabled == 0) statistics.append(messages.getString("off") + "\n"); else statistics.append(messages.getString("on") + "\n"); statistics.append("RFC 1323 Window Scaling: "); if (MaxRwinRcvd < 65535) WinScaleRcvd = 0; if ((WinScaleRcvd == 0) || (WinScaleRcvd > 20)) { statistics.append(messages.getString("off") + "\n"); report.put("window_scaling", "0"); } else { statistics.append(messages.getString("on") + "; " + messages.getString("scalingFactors") + " - " + messages.getString("server") + "=" + WinScaleRcvd + ", " + messages.getString("client") + "=" + WinScaleSent + "\n"); report.put("window_scaling", "1"); } statistics.append("\n"); if ((tests & TEST_SFW) == TEST_SFW) { switch (c2sResult) { case SFW_NOFIREWALL: statistics.append(messages.getString("server") + " '" + host + "' " + messages.getString("firewallNo") + "\n"); emailText += messages.getString("server") + " '" + host + "' " + messages.getString("firewallNo") + "\n%0A"; break; case SFW_POSSIBLE: statistics.append(messages.getString("server") + " '" + host + "' " + messages.getString("firewallYes") + "\n"); emailText += messages.getString("server") + " '" + host + "' " + messages.getString("firewallYes") + "\n%0A"; break; case SFW_UNKNOWN: case SFW_NOTTESTED: break; } switch (s2cResult) { case SFW_NOFIREWALL: statistics .append(messages.getString("client2") + " " + messages.getString("firewallNo") + "\n"); emailText += messages.getString("client2") + " " + messages.getString("firewallNo") + "\n%0A"; break; case SFW_POSSIBLE: statistics .append(messages.getString("client2") + " " + messages.getString("firewallYes") + "\n"); emailText += messages.getString("client2") + " " + messages.getString("firewallYes") + "\n%0A"; break; case SFW_UNKNOWN: case SFW_NOTTESTED: break; } } // diagnosis.append("\nEstimate = " + prtdbl(estimate) + " based on packet size = " // + (CurrentMSS*8/1024) + "kbits, RTT = " + prtdbl(avgrtt) + "msec, " + "and loss = " + loss + "\n"); diagnosis.append("\n"); diagnosis.append(messages.getString("theoreticalLimit") + " " + prtdbl(estimate) + " " + "Mbps\n"); emailText += messages.getString("theoreticalLimit") + " " + prtdbl(estimate) + " Mbps\n%0A"; diagnosis.append(messages.getString("ndtServerHas") + " " + prtdbl(Sndbuf / 2048) + " " + messages.getString("kbyteBufferLimits") + " " + prtdbl(swin / rttsec) + " Mbps\n"); emailText += messages.getString("ndtServerHas") + " " + prtdbl(Sndbuf / 2048) + " " + messages.getString("kbyteBufferLimits") + " " + prtdbl(swin / rttsec) + " Mbps\n%0A"; diagnosis.append(messages.getString("yourPcHas") + " " + prtdbl(MaxRwinRcvd / 1024) + " " + messages.getString("kbyteBufferLimits") + " " + prtdbl(rwin / rttsec) + " Mbps\n"); emailText += messages.getString("yourPcHas") + " " + prtdbl(MaxRwinRcvd / 1024) + " " + messages.getString("kbyteBufferLimits") + " " + prtdbl(rwin / rttsec) + " Mbps\n%0A"; diagnosis.append(messages.getString("flowControlLimits") + " " + prtdbl(cwin / rttsec) + " Mbps\n"); emailText += messages.getString("flowControlLimits") + " " + prtdbl(cwin / rttsec) + " Mbps\n%0A"; diagnosis.append("\n" + messages.getString("clientDataReports") + " '" + prttxt(c2sData) + "', " + messages.getString("clientAcksReport") + " '" + prttxt(c2sAck) + "'\n" + messages.getString("serverDataReports") + " '" + prttxt(s2cData) + "', " + messages.getString("serverAcksReport") + " '" + prttxt(s2cAck) + "'\n"); pub_diagnosis = diagnosis.getText(); } }
From source file:com.mirth.connect.client.ui.Frame.java
/** * Builds the content panel with a title bar and settings. *//*from w ww. j a v a 2s . co m*/ private void buildContentPanel(JXTitledPanel container, JScrollPane component, boolean opaque) { container.getContentContainer().setLayout(new BorderLayout()); container.setBorder(null); container.setTitleFont(new Font("Tahoma", Font.BOLD, 18)); container.setTitleForeground(UIConstants.HEADER_TITLE_TEXT_COLOR); JLabel mirthConnectImage = new JLabel(); mirthConnectImage.setIcon(UIConstants.MIRTHCONNECT_LOGO_GRAY); mirthConnectImage.setText(" "); mirthConnectImage.setToolTipText(UIConstants.MIRTHCONNECT_TOOLTIP); mirthConnectImage.setCursor(new Cursor(Cursor.HAND_CURSOR)); mirthConnectImage.addMouseListener(new java.awt.event.MouseAdapter() { public void mouseClicked(java.awt.event.MouseEvent evt) { BareBonesBrowserLaunch.openURL(UIConstants.MIRTHCONNECT_URL); } }); ((JPanel) container.getComponent(0)).add(mirthConnectImage); component.setBorder(new LineBorder(Color.GRAY, 1)); component.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_NEVER); component.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_NEVER); container.getContentContainer().add(component); }