Java Code Examples for javax.swing.JTextPane#setToolTipText()

The following examples show how to use javax.swing.JTextPane#setToolTipText() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: LatencyFrame.java    From JRakNet with MIT License 6 votes vote down vote up
/**
 * Creates a latency test frame.
 */
protected LatencyFrame() {
	// Frame and content settings
	this.setResizable(false);
	this.setSize(FRAME_WIDTH, FRAME_HEIGHT);
	this.setTitle("JRakNet Latency Test");
	this.getContentPane().setLayout(null);

	// Client latencies
	JTextPane txtpnClientLatencies = new JTextPane();
	txtpnClientLatencies.setEditable(false);
	txtpnClientLatencies.setText("Client latencies");
	txtpnClientLatencies.setBackground(UIManager.getColor("Button.background"));
	txtpnClientLatencies.setBounds(10, 10, 350, 20);
	this.getContentPane().add(txtpnClientLatencies);

	// The list of the connected clients
	txtPnClientLatencies = new JTextPane();
	txtPnClientLatencies.setToolTipText("This is the list of the connected clients and their latencies");
	txtPnClientLatencies.setEditable(false);
	txtPnClientLatencies.setBackground(UIManager.getColor("Button.background"));
	txtPnClientLatencies.setBounds(10, 30, 350, 165);
	this.getContentPane().add(txtPnClientLatencies);
}
 
Example 2
Source File: VersionPane.java    From bigtable-sql with Apache License 2.0 5 votes vote down vote up
public void mouseMoved(MouseEvent ev) {
JTextPane editor = (JTextPane) ev.getSource();
editor.setEditable(false);
  Point pt = new Point(ev.getX(), ev.getY());
  int pos = editor.viewToModel(pt);
  if (pos >= 0) {
    Document eDoc = editor.getDocument();
    if (eDoc instanceof DefaultStyledDocument) {
      DefaultStyledDocument hdoc =
        (DefaultStyledDocument) eDoc;
      Element e = hdoc.getCharacterElement(pos);
      AttributeSet a = e.getAttributes();
      AttributeSet tagA = (AttributeSet) a.getAttribute(HTML.Tag.A);
      String href = null;
      if (tagA!=null){
          href = (String)tagA.getAttribute(HTML.Attribute.HREF);
      }
      if (href != null) {
          editor.setToolTipText(href);
          if (editor.getCursor().getType() != Cursor.HAND_CURSOR) {
              editor.setCursor(new Cursor(Cursor.HAND_CURSOR));
          }
      }
      else {
          editor.setToolTipText(null);
          if (editor.getCursor().getType() != Cursor.DEFAULT_CURSOR) {
              editor.setCursor(new Cursor(Cursor.DEFAULT_CURSOR));
        }
      }
    }
  }
  else {
      editor.setToolTipText(null);
  }
}
 
Example 3
Source File: BroadcastFrame.java    From JRakNet with MIT License 4 votes vote down vote up
/**
 * Creates a broadcast test frame.
 */
protected BroadcastFrame() {
	// Frame and content settings
	this.setResizable(false);
	this.setSize(FRAME_WIDTH, FRAME_HEIGHT);
	this.setTitle("JRakNet Broadcast Test");
	this.getContentPane().setLayout(null);

	// Discovered MCPE Servers
	JTextPane txtpnDiscoveredMcpeServers = new JTextPane();
	txtpnDiscoveredMcpeServers.setEditable(false);
	txtpnDiscoveredMcpeServers.setBackground(UIManager.getColor("Button.background"));
	txtpnDiscoveredMcpeServers.setText("Discovered servers");
	txtpnDiscoveredMcpeServers.setBounds(10, 10, 350, 20);
	this.getContentPane().add(txtpnDiscoveredMcpeServers);

	// How the client will discover servers on the local network
	JComboBox<String> comboBoxDiscoveryType = new JComboBox<String>();
	comboBoxDiscoveryType.setToolTipText(
			"Changing this will update how the client will discover servers, by default it will look for any possible connection on the network");
	comboBoxDiscoveryType.setModel(new DefaultComboBoxModel<String>(DISCOVERY_MODE_OPTIONS));
	comboBoxDiscoveryType.setBounds(370, 10, 115, 20);
	comboBoxDiscoveryType.addActionListener(new RakNetBroadcastDiscoveryTypeListener());
	this.getContentPane().add(comboBoxDiscoveryType);

	// Used to update the discovery port
	JTextField textFieldDiscoveryPort = new JTextField();
	textFieldDiscoveryPort.setBounds(370, 45, 115, 20);
	textFieldDiscoveryPort.setText(Integer.toString(Discovery.getPorts()[0]));
	this.getContentPane().add(textFieldDiscoveryPort);
	textFieldDiscoveryPort.setColumns(10);
	JButton btnUpdatePort = new JButton("Update Port");
	btnUpdatePort.setBounds(370, 76, 114, 23);
	btnUpdatePort.addActionListener(new RakNetBroadcastUpdatePortListener(textFieldDiscoveryPort));
	this.getContentPane().add(btnUpdatePort);

	// The text containing the discovered MCPE servers
	txtPnDiscoveredMcpeServerList = new JTextPane();
	txtPnDiscoveredMcpeServerList.setToolTipText("This is the list of the discovered servers on the local network");
	txtPnDiscoveredMcpeServerList.setEditable(false);
	txtPnDiscoveredMcpeServerList.setBackground(UIManager.getColor("Button.background"));
	txtPnDiscoveredMcpeServerList.setBounds(10, 30, 350, 165);
	this.getContentPane().add(txtPnDiscoveredMcpeServerList);
}