frame.setSize(520, 480); frame.setLocationRelativeTo(null); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); JPanel heroShotPanel = new JPanel(); JLabel heroShot = new JLabel(heroShotImage); heroShotPanel.add(heroShot); start.setToolTipText("Click to use library"); submitPanel.add(start); frame.getContentPane().add(heroShotPanel, BorderLayout.NORTH); frame.getContentPane().add(submitPanel, BorderLayout.SOUTH); frame.setVisible(true); frame.getRootPane().setDefaultButton(start); start.requestFocus();
/** * Method generated by IntelliJ IDEA GUI Designer * >>> IMPORTANT!! <<< * DO NOT edit this method OR call it in your code! * * @noinspection ALL */ private void $$$setupUI$$$() { rootPanel = new JPanel(); rootPanel.setLayout(new GridLayoutManager(2, 3, new Insets(0, 0, 0, 0), -1, -1)); repositoriesLabel = new JLabel(); repositoriesLabel.setText("Additional repositories"); rootPanel.add(repositoriesLabel, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); final Spacer spacer1 = new Spacer(); rootPanel.add(spacer1, new GridConstraints(0, 2, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_WANT_GROW, 1, null, null, null, 0, false)); final Spacer spacer2 = new Spacer(); rootPanel.add(spacer2, new GridConstraints(1, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_VERTICAL, 1, GridConstraints.SIZEPOLICY_WANT_GROW, null, null, null, 0, false)); final JScrollPane scrollPane1 = new JScrollPane(); rootPanel.add(scrollPane1, new GridConstraints(0, 1, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_WANT_GROW, null, null, null, 0, false)); repositoriesTextArea = new JTextArea(); repositoriesTextArea.setMaximumSize(new Dimension(420, 2147483647)); repositoriesTextArea.setMinimumSize(new Dimension(300, 10)); repositoriesTextArea.setPreferredSize(new Dimension(300, 50)); repositoriesTextArea.setText(ResourceBundle.getBundle("com/github/gtache/lsp/LSPBundle").getString("coursier.settings.textarea.basetext")); repositoriesTextArea.setToolTipText("Insert one resolver by line"); scrollPane1.setViewportView(repositoriesTextArea); }
this.add(b); f.getRootPane().setDefaultButton(b); this.getInputMap().put(KeyStroke.getKeyStroke(KeyEvent.VK_Q, 0), EXIT); FullScreenTest.this.setToolTipText( "("+ e.getX() + "," + e.getY() + ")"); GraphicsEnvironment.getLocalGraphicsEnvironment(); GraphicsDevice dev = env.getDefaultScreenDevice(); f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); f.setBackground(Color.darkGray); f.setResizable(false); f.setUndecorated(true); f.add(this); f.pack(); dev.setFullScreenWindow(f);
import javax.swing.JFrame; import javax.swing.JLabel; import javax.swing.SwingUtilities; import javax.swing.ToolTipManager; public class TestTooltips { protected static void initUI() { ToolTipManager.sharedInstance().setInitialDelay(0); ToolTipManager.sharedInstance().setDismissDelay(500); JFrame frame = new JFrame("test"); JLabel label = new JLabel("Label text"); label.setToolTipText("My cool nice and fun tooltip"); frame.add(label); frame.pack(); frame.setVisible(true); } public static void main(String[] args) { SwingUtilities.invokeLater(new Runnable() { @Override public void run() { initUI(); } }); } }
JFrame frame = new JFrame("Tool tip test"); frame.setLocationByPlatform(true); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); text.setFocusable(false); bg.add(text); glassPane.setToolTipText("A tooltip, that shows on both the label and the text"); JLabel other = new JLabel("This component has another tooltip"); other.setToolTipText("Another tooltip");
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.setSize(400, 400); for (JComponent component : SwingUtils.getDescendantsOfType(JComponent.class, frame)) { if (component.getClass().getName().contains("MetalTitlePane")) { component.setToolTipText("Tooltip for frame title bar"); break; frame.setVisible(true);
public void ancestorAdded(AncestorEvent event) { if ( showing ) { return; } Window ttip = SwingUtilities.getWindowAncestor(getParent()); if ( ttip == null || !ttip.isVisible() ) { return; } //ttip.addMouseListener(this); ttip.getLocation(point); ttip.setVisible(false); getParent().remove(JCustomTooltip.this); JComponent c = getComponent(); c.setToolTipText(null); c.removeMouseMotionListener(ToolTipManager.sharedInstance()); popup = PopupFactory.getSharedInstance().getPopup( c, JCustomTooltip.this, point.x, point.y); Window w = SwingUtilities.getWindowAncestor(JCustomTooltip.this); w.addMouseListener(this); w.setFocusableWindowState(true); popup.show(); showing = true; }
}; sampleRate = new JComboBox(rates); sampleRate.setToolTipText("Samples per second"); sampleRate.setSelectedIndex(1); JPanel pSampleRate = new JPanel(new BorderLayout()); pSampleRate.setBorder(new TitledBorder("Sample Rate")); pSampleRate.add( sampleRate ); sampleRate.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent ae) { framesPerWavelength.setMajorTickSpacing(10); framesPerWavelength.setMinorTickSpacing(5); framesPerWavelength.setToolTipText("Frames per Wavelength"); framesPerWavelength.addChangeListener( new ChangeListener(){ public void stateChanged(ChangeEvent ce) { harmonic.setToolTipText( "Add harmonic to second channel, one octave up"); harmonic.addActionListener( new ActionListener(){ play.setBorder( new EmptyBorder(4,4,4,4) ); JButton bPlay = new JButton("Code Key"); bPlay.setToolTipText("Click to make tone!"); Dimension preferredSize = bPlay.getPreferredSize(); bPlay.setPreferredSize( new Dimension( (int)control.getValue() ); volume.setToolTipText("Volume of beep");
rootPanel.setLayout(new GridLayoutManager(9, 4, new Insets(5, 5, 0, 0), -1, -1)); final Spacer spacer1 = new Spacer(); rootPanel.add(spacer1, new GridConstraints(2, 2, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_WANT_GROW, 1, null, null, null, 0, false)); final JLabel label1 = new JLabel(); Font label1Font = this.$$$getFont$$$(null, Font.BOLD, 20, label1.getFont()); if (label1Font != null) label1.setFont(label1Font); label1.setText("Miscellaneous Settings"); rootPanel.add(label1, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); final Spacer spacer2 = new Spacer(); rootPanel.add(spacer2, new GridConstraints(0, 2, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_WANT_GROW, 1, null, null, null, 0, false)); resetCustomAssociationsButton = new JButton(); resetCustomAssociationsButton.setText("Reset custom associations"); alwaysSendRequestsCheckBox.setMargin(new Insets(2, 2, 2, 2)); alwaysSendRequestsCheckBox.setText("Always send requests"); alwaysSendRequestsCheckBox.setToolTipText("Send requests even if a language plugin already supports it"); rootPanel.add(alwaysSendRequestsCheckBox, new GridConstraints(7, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 1, false));
setVisible( true ); ImageIcon icon = new ImageIcon( i + ".gif" ); JButton jb = new JButton( icon ); jb.setToolTipText( i + ".gif" ); my_panel.add( jb ); getContentPane().add( my_panel ); my_panel.setBorder( BorderFactory.createEtchedBorder() );
int index = theList.locationToIndex(e.getPoint()); if (index > -1) { theList.setToolTipText(null); String text = (String) model.getElementAt(index); theList.setToolTipText(text); myTest.setTitle("Example JList"); myTest.setSize(300, 300); myTest.setDefaultCloseOperation(EXIT_ON_CLOSE);
import javax.swing.*; import javax.swing.text.html.*; import java.awt.*; import java.awt.event.*; public class ImageToolTip { public static void main(String[] args) { JFrame frame = new JFrame("Image Tool Tip Frame"); JComponent button = new JButton("Cut"); String tooltiptext = "<html>" + "This is the " + "<img src=\"file:cut.gif\">" + " tool tip text." + "</html>"; button.setToolTipText(tooltiptext); JPanel panel = new JPanel(); panel.add(button); frame.add(panel, BorderLayout.CENTER); frame.setSize(400, 400); frame.setVisible(true); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); } }
newButton.setToolTipText("Clear Log Table."); tb.add(new JLabel(" Font: ")); tb.add(fontCombo); tb.add(fontSizeCombo); tb.addSeparator(); tb.addSeparator();
c.setBackground(color); c.add(new JLabel( "Click button to select a new background color")); b = new JButton("Color"); b.setToolTipText("Click here to change color"); b.addActionListener(this); c.add(b); new JColorChooserExample("JColorChooser Example"); jcce.pack(); jcce.setVisible(true);
import java.awt.*; import javax.swing.*; import javax.swing.JFrame; public class main { public static void main(String[] args){ JFrame piyu=new JFrame("First Java app"); JPanel panel=new JPanel(); JLabel item1,item2; panel.setLayout(new GridLayout()); item1=new JLabel("MY NAME IS XYZ"); item2=new JLabel("YO"); item1.setToolTipText("GAME ON"); panel.add(item1); panel.add(item2); piyu.add(panel); piyu.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); piyu.setSize(300,200); piyu.setVisible(true); } }
JList list = new JList(files); list.setCellRenderer(new FileListCellRenderer()); gui.add(new JScrollPane(list)); label.setIcon(fileSystemView.getSystemIcon(file)); label.setText(fileSystemView.getSystemDisplayName(file)); label.setToolTipText(file.getPath());
JFrame frame = new JFrame("test"); final JLabel label = new JLabel("Label text"); frame.add(label); frame.pack(); frame.setVisible(true); Timer t = new Timer(1000, new ActionListener() { progress = 0; label.setToolTipText("Progress: " + progress + " %"); Point locationOnScreen = MouseInfo.getPointerInfo().getLocation(); Point locationOnComponent = new Point(locationOnScreen);
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); con.add(panel); label1.setToolTipText("Enter Your Username"); label2.setToolTipText("Enter Your Registration no"); label3.setToolTipText("Enter Your Password"); panel.add(label1); panel.add(label2); panel.add(label3); setVisible(true);
add(jScrollPane1); label.setIcon(fileSystemView.getSystemIcon(file)); label.setText(fileSystemView.getSystemDisplayName(file)); label.setToolTipText(file.getPath());
getContentPane().add(combo); setForeground(list.getSelectionForeground()); if (-1 < index) { list.setToolTipText(tooltips[index]); frame.setVisible(true);