Search in sources :

Example 11 with JToolTip

use of javax.swing.JToolTip in project UniversalMediaServer by UniversalMediaServer.

the class CustomJLabel method createToolTip.

public JToolTip createToolTip() {
    JToolTip tip = new HyperLinkToolTip();
    tip.setComponent(this);
    return tip;
}
Also used : JToolTip(javax.swing.JToolTip)

Example 12 with JToolTip

use of javax.swing.JToolTip in project UniversalMediaServer by UniversalMediaServer.

the class CustomJComboBox method createToolTip.

public JToolTip createToolTip() {
    JToolTip tip = new HyperLinkToolTip();
    tip.setComponent(this);
    return tip;
}
Also used : JToolTip(javax.swing.JToolTip)

Example 13 with JToolTip

use of javax.swing.JToolTip in project UniversalMediaServer by UniversalMediaServer.

the class CustomJSpinner method createToolTip.

public JToolTip createToolTip() {
    JToolTip tip = new HyperLinkToolTip();
    tip.setComponent(this);
    return tip;
}
Also used : JToolTip(javax.swing.JToolTip)

Example 14 with JToolTip

use of javax.swing.JToolTip in project jsql-injection by ron190.

the class TabManagers method buildI18nTab.

private void buildI18nTab(String keyLabel, String keyTooltip, Icon icon, Component manager) {
    final JToolTipI18n[] tooltip = new JToolTipI18n[] { new JToolTipI18n(I18n.valueByKey(keyTooltip)) };
    JLabel labelTab = new JLabel(I18n.valueByKey(keyLabel), icon, SwingConstants.CENTER) {

        @Override
        public JToolTip createToolTip() {
            JToolTip tipI18n = new JToolTipI18n(I18n.valueByKey(keyTooltip));
            tooltip[0] = (JToolTipI18n) tipI18n;
            return tipI18n;
        }
    };
    labelTab.addMouseListener(new MouseAdapter() {

        @Override
        public void mousePressed(MouseEvent e) {
            TabManagers.this.setSelectedComponent(manager);
            super.mousePressed(e);
        }
    });
    this.addTab(I18n.valueByKey(keyLabel), icon, manager);
    this.setTabComponentAt(this.indexOfTab(I18n.valueByKey(keyLabel)), labelTab);
    I18nView.addComponentForKey(keyLabel, labelTab);
    I18nView.addComponentForKey(keyTooltip, tooltip[0]);
    labelTab.setToolTipText(I18n.valueByKey(keyTooltip));
    labelTab.addMouseListener(new TabSelectionMouseHandler());
}
Also used : JToolTip(javax.swing.JToolTip) MouseEvent(java.awt.event.MouseEvent) MouseAdapter(java.awt.event.MouseAdapter) JLabel(javax.swing.JLabel) JToolTipI18n(com.jsql.view.swing.text.JToolTipI18n)

Example 15 with JToolTip

use of javax.swing.JToolTip in project triplea by triplea-game.

the class TripleAFrame method getArrowKeyListener.

private KeyListener getArrowKeyListener() {
    return new KeyListener() {

        @Override
        public void keyPressed(final KeyEvent e) {
            isCtrlPressed = e.isControlDown();
            // scroll map according to wasd/arrowkeys
            final int diffPixel = computeScrollSpeed();
            final int x = mapPanel.getXOffset();
            final int y = mapPanel.getYOffset();
            final int keyCode = e.getKeyCode();
            if (keyCode == KeyEvent.VK_RIGHT) {
                getMapPanel().setTopLeft(x + diffPixel, y);
            } else if (keyCode == KeyEvent.VK_LEFT) {
                getMapPanel().setTopLeft(x - diffPixel, y);
            } else if (keyCode == KeyEvent.VK_DOWN) {
                getMapPanel().setTopLeft(x, y + diffPixel);
            } else if (keyCode == KeyEvent.VK_UP) {
                getMapPanel().setTopLeft(x, y - diffPixel);
            }
            // I for info
            if (keyCode == KeyEvent.VK_I || keyCode == KeyEvent.VK_V) {
                String unitInfo = "";
                if (unitsBeingMousedOver != null && !unitsBeingMousedOver.isEmpty()) {
                    final Unit unit = unitsBeingMousedOver.get(0);
                    final UnitAttachment ua = UnitAttachment.get(unit.getType());
                    if (ua != null) {
                        unitInfo = "<b>Unit:</b><br>" + unit.getType().getName() + ": " + ua.toStringShortAndOnlyImportantDifferences(unit.getOwner(), true, false);
                    }
                }
                String terrInfo = "";
                if (territoryLastEntered != null) {
                    final TerritoryAttachment ta = TerritoryAttachment.get(territoryLastEntered);
                    if (ta != null) {
                        terrInfo = "<b>Territory:</b><br>" + ta.toStringForInfo(true, true) + "<br>";
                    } else {
                        terrInfo = "<b>Territory:</b><br>" + territoryLastEntered.getName() + "<br>Water Territory";
                    }
                }
                String tipText = unitInfo;
                if (unitInfo.length() > 0 && terrInfo.length() > 0) {
                    tipText = tipText + "<br><br><br><br><br>";
                }
                tipText = tipText + terrInfo;
                if (tipText.length() > 0) {
                    final Point currentPoint = MouseInfo.getPointerInfo().getLocation();
                    final PopupFactory popupFactory = PopupFactory.getSharedInstance();
                    final JToolTip info = new JToolTip();
                    info.setTipText("<html>" + tipText + "</html>");
                    final Popup popup = popupFactory.getPopup(mapPanel, info, currentPoint.x, currentPoint.y);
                    popup.show();
                    new Thread(() -> {
                        Interruptibles.sleep(5000);
                        popup.hide();
                    }, "popup waiter").start();
                }
            }
        }

        @Override
        public void keyTyped(final KeyEvent e) {
        }

        @Override
        public void keyReleased(final KeyEvent e) {
            isCtrlPressed = e.isControlDown();
        }
    };
}
Also used : KeyEvent(java.awt.event.KeyEvent) UnitAttachment(games.strategy.triplea.attachments.UnitAttachment) PopupFactory(javax.swing.PopupFactory) JToolTip(javax.swing.JToolTip) TerritoryAttachment(games.strategy.triplea.attachments.TerritoryAttachment) Popup(javax.swing.Popup) KeyListener(java.awt.event.KeyListener) Point(java.awt.Point) Unit(games.strategy.engine.data.Unit) TripleAUnit(games.strategy.triplea.TripleAUnit) Point(java.awt.Point)

Aggregations

JToolTip (javax.swing.JToolTip)15 Dimension (java.awt.Dimension)3 JToolTipI18n (com.jsql.view.swing.text.JToolTipI18n)2 Point (java.awt.Point)2 MouseAdapter (java.awt.event.MouseAdapter)2 MouseEvent (java.awt.event.MouseEvent)2 JLabel (javax.swing.JLabel)2 JTextArea (javax.swing.JTextArea)2 Unit (games.strategy.engine.data.Unit)1 TripleAUnit (games.strategy.triplea.TripleAUnit)1 TerritoryAttachment (games.strategy.triplea.attachments.TerritoryAttachment)1 UnitAttachment (games.strategy.triplea.attachments.UnitAttachment)1 Font (java.awt.Font)1 FontMetrics (java.awt.FontMetrics)1 KeyEvent (java.awt.event.KeyEvent)1 KeyListener (java.awt.event.KeyListener)1 Popup (javax.swing.Popup)1 PopupFactory (javax.swing.PopupFactory)1