Example usage for javax.swing JPanel setToolTipText

List of usage examples for javax.swing JPanel setToolTipText

Introduction

In this page you can find the example usage for javax.swing JPanel setToolTipText.

Prototype

@BeanProperty(bound = false, preferred = true, description = "The text to display in a tool tip.")
public void setToolTipText(String text) 

Source Link

Document

Registers the text to display in a tool tip.

Usage

From source file:MainClass.java

public static void main(String args[]) {
    JFrame frame = new JFrame("Tooltip");
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

    JPanel panel = new JPanel();
    panel.setToolTipText("<HtMl>Tooltip<br>Message");
    frame.add(panel, BorderLayout.CENTER);

    JButton button = new JButton("Hello, World") {
        public JToolTip createToolTip() {
            JToolTip tip = super.createToolTip();
            tip.setBackground(Color.YELLOW);
            tip.setForeground(Color.RED);
            return tip;
        }//from  ww  w.  j av  a2  s .  c  om

        public boolean contains(int x, int y) {
            if (x < 100) {
                setToolTipText("x < 100");
            } else {
                setToolTipText("else");
            }
            return super.contains(x, y);
        }
    };

    button.setToolTipText("Hello, World");
    frame.add(button, BorderLayout.NORTH);

    frame.setSize(300, 150);
    frame.setVisible(true);
}

From source file:Main.java

public static void main(String[] args) {
    JTextPane text = new JTextPane() {
        @Override/*w w w  .  ja v a2  s . c  o m*/
        public String getToolTipText() {
            return ((JComponent) getParent()).getToolTipText();
        }

        @Override
        public String getToolTipText(MouseEvent event) {
            return ((JComponent) getParent()).getToolTipText(event);
        }
    };
    text.setText("Lorem ipsum dolor sit");
    ToolTipManager.sharedInstance().registerComponent(text);

    JFrame frame = new JFrame("Testing");
    JPanel panel = new JPanel(new BorderLayout());
    panel.setToolTipText("tooltip from parent");
    frame.setContentPane(panel);
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    frame.add(text);
    frame.pack();
    frame.setVisible(true);
}

From source file:lu.lippmann.cdb.common.gui.MultiPanel.java

public static final void main(String[] args) {
    int w = 1024, h = 768;

    JPanel panel1 = new JPanel();
    panel1.setToolTipText("Panel 1");
    JPanel panel2 = new JPanel();
    panel2.setToolTipText("Panel 2");
    JPanel panel3 = new JPanel();
    panel3.setToolTipText("Panel 3");
    JPanel panel4 = new JPanel();
    panel4.setToolTipText("Panel 4");
    JPanel panel5 = new JPanel();
    panel5.setToolTipText("Panel 5");

    final ListOrderedMap<JComponent, Integer> mapPanels = new ListOrderedMap<JComponent, Integer>();

    //add in increasing order or in the order you want to maintain ...
    mapPanels.put(panel4, 5);/*w ww.j  a v  a 2s  .co m*/
    mapPanels.put(panel5, 5);
    mapPanels.put(panel3, 10);
    mapPanels.put(panel1, 30);
    mapPanels.put(panel2, 50);

    MultiPanel mp = new MultiPanel(mapPanels, w, h, false);
    JFrame f = new JFrame("MultiPanel test");
    f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    f.setSize(w, h);
    f.getContentPane().add(mp);
    f.setVisible(true);
}

From source file:com.atlassian.theplugin.idea.bamboo.tree.BuildTreeNode.java

public static void addTooltipToPanel(BambooBuildAdapter build, JPanel p) {
    final JToolTip jToolTip = p.createToolTip();
    jToolTip.setTipText(buildTolltip(build, 0));
    final int prefWidth = jToolTip.getPreferredSize().width;
    int width = prefWidth > MAX_TOOLTIP_WIDTH ? MAX_TOOLTIP_WIDTH : 0;
    p.setToolTipText(buildTolltip(build, width));
}

From source file:org.jfree.chart.demo.LeftPanel.java

public LeftPanel(ArrayList<ChartPanel> graphics, ArrayList<Graphic> Grafs, ArrayList<JFreeChart> charts,
        ArrayList<XYSeries> Series) {
    //setBackground(new Color(152 ,134, 202));
    //setBackground(new Color(234 ,247, 202));
    setSize(800, 530);//from   www  . j  a  v  a 2  s  . c  o  m
    setLayout(null);
    setBackground(new Color(176, 199, 246));

    JTabbedPane tabbedPane = new JTabbedPane(JTabbedPane.TOP);
    tabbedPane.setBackground(new Color(174, 250, 127));

    tabbedPane.setFont(new Font("Arial", 15, 16));
    tabbedPane.setOpaque(false);

    tabbedPane.setBounds(7, 6, 750, 505);
    tabbedPane.setAlignmentY(Component.TOP_ALIGNMENT);
    add(tabbedPane);

    JPanel panel = new JPanel();
    panel.setBackground(new Color(176, 199, 246));
    panel.setToolTipText("Graphic 1");
    panel.add(graphics.get(0));
    panel.add(new bottom_slider(new Color(176, 199, 246), charts, Grafs.get(0), 0));
    tabbedPane.addTab("Graphic 1", null, panel, null);
    panel.setLayout(null);

    JPanel panel_2 = new JPanel();
    panel_2.add(graphics.get(1));
    tabbedPane.addTab("Graphic 2", null, panel_2, null);
    panel_2.setLayout(null);
    panel_2.setBackground(new Color(176, 199, 246));
    panel_2.add(new bottom_slider(new Color(176, 199, 246), charts, Grafs.get(1), 1));

    JPanel panel_1 = new JPanel();
    panel_1.add(graphics.get(2));
    tabbedPane.addTab("Graphic 3", null, panel_1, null);
    panel_1.setLayout(null);
    panel_1.setBackground(new Color(176, 199, 246));
    panel_1.add(new bottom_slider(new Color(176, 199, 246), charts, Grafs.get(2), 2));
    panel_1.setBackground(new Color(176, 199, 246));

    JPanel panel_3 = new JPanel();
    panel_3.add(graphics.get(3));
    tabbedPane.addTab("Graphic 4", null, panel_3, null);
    panel_3.setLayout(null);
    panel_3.setBackground(new Color(176, 199, 246));
    panel_3.add(new bottom_slider(new Color(176, 199, 246), charts, Grafs.get(3), 3));

    JPanel panel_4 = new JPanel();
    panel_4.add(graphics.get(4));
    tabbedPane.addTab("Graphic 5 ", null, panel_4, null);
    panel_4.setLayout(null);
    panel_4.setBackground(new Color(176, 199, 246));
    panel_4.add(new bottom_slider(new Color(176, 199, 246), charts, Grafs.get(4), 4));

    JPanel panel_5 = new JPanel();
    panel_5.add(graphics.get(5));
    tabbedPane.addTab("Graphic 6", null, panel_5, null);
    panel_5.setLayout(null);
    panel_5.setBackground(new Color(176, 199, 246));
    panel_5.add(new bottom_slider(new Color(176, 199, 246), charts, Grafs.get(5), 5));

    JPanel panel_6 = new JPanel();
    panel_6.add(graphics.get(6));
    tabbedPane.addTab("Graphic 7", null, panel_6, null);
    panel_6.setLayout(null);
    panel_6.setBackground(new Color(176, 199, 246));
    panel_6.add(new bottom_slider(new Color(176, 199, 246), charts, Grafs.get(6), 6));

    JPanel panel_7 = new JPanel();
    panel_7.add(graphics.get(7));
    tabbedPane.addTab("Graphic 8", null, panel_7, null);
    panel_7.setLayout(null);
    panel_7.setBackground(new Color(176, 199, 246));
    panel_7.add(new bottom_slider(new Color(176, 199, 246), charts, Grafs.get(7), 7));

    JPanel panel_8 = new JPanel();
    panel_8.add(new Bottom_panel(Grafs, Series, 5, 390, 735, 50));
    graphics.set(8, Grafs.get(8).get_ChartPanel(740, 390));
    panel_8.add(graphics.get(8));

    tabbedPane.addTab("Graphic 9", null, panel_8, null);
    panel_8.setLayout(null);
    panel_8.setBackground(new Color(176, 199, 246));

    JPanel panel_9 = new JPanel();
    panel_9.add(graphics.get(9));
    tabbedPane.addTab("Graphic 10", null, panel_9, null);
    panel_9.setLayout(null);
    panel_9.setBackground(new Color(176, 199, 246));

}

From source file:com.devoteam.srit.xmlloader.core.report.derived.StatText.java

@Override
public JPanel generateShortRTStats() {
    JPanel panel = new JPanel();
    panel.setLayout(new javax.swing.BoxLayout(panel, javax.swing.BoxLayout.Y_AXIS));
    panel.add(new JLabel(this.counter.globalDataset.getText()));
    panel.setToolTipText(generateRTStatsToolTip());
    return panel;
}

From source file:com.emental.mindraider.ui.dialogs.ConnectUriqaServerJDialog.java

/**
 * Constructor./*from w  w  w.  jav a  2  s.  c  o m*/
 */
public ConnectUriqaServerJDialog() {
    super(Messages.getString("ConnectUriqaServerJDialog.title"));
    getContentPane().setLayout(new BorderLayout());

    // north
    JPanel north = new JPanel();
    north.add(new JLabel(Messages.getString("ConnectUriqaServerJDialog.serverUrl")));

    uriqaServerUrl = new JTextField("http://sw.nokia.com/uriqa/", 31);
    uriqaServerUrl.setMinimumSize(new Dimension(TEXT_AREAS_WIDTH, uriqaServerUrl.getPreferredSize().height));
    uriqaServerUrl.addKeyListener(new KeyListener() {

        public void keyPressed(KeyEvent keyEvent) {
            if (keyEvent.getKeyCode() == KeyEvent.VK_ENTER) {
                connect();
            }
        }

        public void keyReleased(KeyEvent keyEvent) {
        }

        public void keyTyped(KeyEvent keyEvent) {
        }
    });
    north.add(uriqaServerUrl);
    getContentPane().add(north, BorderLayout.NORTH);

    // center
    JPanel center = new JPanel();
    center.setLayout(new BorderLayout());

    JPanel centerTop = new JPanel();
    centerTop.add(new JLabel(Messages.getString("ConnectUriqaServerJDialog.resource")));
    String[] knowUriqaUris = new String[] { "http://sw.nokia.com/VOC-1/term", "http://sw.nokia.com/MARS-3/Rank",
            "http://sw.nokia.com/MARS-3", "http://sw.nokia.com/schemas/nokia/MARS-3.1.rdf" };
    resourceUri = new JComboBox(knowUriqaUris);
    resourceUri.setMinimumSize(new Dimension(TEXT_AREAS_WIDTH, resourceUri.getPreferredSize().height));
    resourceUri.setEditable(true);
    centerTop.add(resourceUri);

    JPanel centerCenter = new JPanel();
    centerCenter.setLayout(new FlowLayout(FlowLayout.LEFT));
    centerCenter.setToolTipText(Messages.getString("ConnectUriqaServerJDialog.loadOverToolTip"));
    centerCenter.add(new JLabel(Messages.getString("ConnectUriqaServerJDialog.loadOver")));
    JCheckBox loadOver = new JCheckBox();
    loadOver.setSelected(true);
    loadOver.setEnabled(false);
    centerCenter.add(loadOver);

    JPanel centerBottom = new JPanel();
    centerBottom.setLayout(new FlowLayout(FlowLayout.LEFT));
    centerBottom.setToolTipText(Messages.getString("ConnectUriqaServerJDialog.addInferedToolTip"));
    centerBottom.add(new JLabel(Messages.getString("ConnectUriqaServerJDialog.addInfered")));
    addInfered = new JCheckBox();
    addInfered.setSelected(true);
    centerBottom.add(addInfered);

    center.add(centerTop, BorderLayout.NORTH);
    center.add(centerCenter, BorderLayout.CENTER);
    center.add(centerBottom, BorderLayout.SOUTH);
    getContentPane().add(center, BorderLayout.CENTER);

    // south
    JPanel south = new JPanel();
    JButton uploadButton = new JButton(Messages.getString("ConnectUriqaServerJDialog.connect"));
    uploadButton.addActionListener(new ActionListener() {

        public void actionPerformed(ActionEvent e) {
            connect();
        }
    });
    south.add(uploadButton);

    JButton cancelButton = new JButton(Messages.getString("ConnectUriqaServerJDialog.cancel"));
    cancelButton.addActionListener(new ActionListener() {

        public void actionPerformed(ActionEvent e) {
            dispose();
        }
    });
    south.add(cancelButton);
    getContentPane().add(south, BorderLayout.SOUTH);

    // show
    pack();
    Gfx.centerAndShowWindow(this);
}

From source file:com.devoteam.srit.xmlloader.core.report.derived.StatCount.java

@Override
public JPanel generateShortRTStats() {
    JPanel panel = new JPanel();
    panel.setLayout(new javax.swing.BoxLayout(panel, javax.swing.BoxLayout.Y_AXIS));
    panel.add(new JLabel(Utils.formatdouble(this.counter.globalDataset.getValue())));
    panel.setToolTipText(generateRTStatsToolTip());

    addMouseListenerForGraph(panel);//from   w  w w  . ja  va 2  s. c  o m

    return panel;
}

From source file:com.devoteam.srit.xmlloader.core.report.derived.StatPercent.java

@Override
public JPanel generateShortRTStats() {
    JPanel panel = new JPanel();
    panel.setLayout(new javax.swing.BoxLayout(panel, javax.swing.BoxLayout.Y_AXIS));
    panel.add(new JLabel(Utils.formatdouble(this.cumulated)));
    panel.add(new JLabel(Utils.formatdouble(this.counter.globalDataset.getValue()) + "%"));
    panel.setToolTipText(generateRTStatsToolTip());

    addMouseListenerForGraph(panel);// ww w . j  a v  a  2  s  . c  o  m

    return panel;
}

From source file:com.devoteam.srit.xmlloader.core.report.derived.StatCount.java

@Override
public JPanel generateLongRTStats() {
    // Panel we will return with all information of this counter
    JPanel panel = new JPanel();

    // Layout for this panel
    panel.setLayout(new javax.swing.BoxLayout(panel, javax.swing.BoxLayout.Y_AXIS));

    // Color of background for this panel
    panel.setBackground(new java.awt.Color(248, 248, 248));

    // We add as a Tooltip the long description of this counter
    panel.setToolTipText(template.complete);

    // We add this html code as a JLabel in the panel
    panel.add(new JLabel(generateLongStringHTML()));

    // We return the panel
    return panel;
}