Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7800739
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T00:44:06+00:00 2026-06-02T00:44:06+00:00

I want to create a "preview window" for my "main window", so if I

  • 0

I want to create a "preview window" for my "main window", so if I take mouse pointer to a particular button or place then it show main window preview in a small window, and when I click on that "preview window" then it should return to the "main window". For example Windows 7 task bar creates a preview for each opened application. How can I can offer this feature to my users?

E.G.

enter image description here

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-02T00:44:07+00:00Added an answer on June 2, 2026 at 12:44 am

    An extremely simplistic implementation.

    Show component previews as tool tip

    import java.awt.*;
    import java.awt.image.*;
    import java.awt.event.*;
    import javax.swing.*;
    
    class ShowPreviews {
    
        class ToolTipListener extends MouseAdapter {
    
            JWindow toolTip;
            JLabel label;
            Component preview;
    
            ToolTipListener(Component preview) {
                this.preview = preview;
            }
    
            @Override
            public void mouseEntered(MouseEvent me) {
                if (toolTip==null) {
                    toolTip = new JWindow();
                    label = new JLabel();
                    toolTip.add(label);
                }
                label.setIcon( new ImageIcon(
                    getScaledImageOfComponent(preview, .6) ) );
                toolTip.pack();
                Component c = (Component)me.getSource();
                int x = c.getLocationOnScreen().x+(c.getWidth()/2);
                int y = c.getLocationOnScreen().y+c.getHeight();
    
                toolTip.setLocation(x,y);
                toolTip.setVisible(true);
            }
    
            @Override
            public void mouseExited(MouseEvent me) {
                toolTip.setVisible(false);
                toolTip.dispose();
            }
    
            public Image getScaledImageOfComponent(
                Component component, double scale) {
                BufferedImage bi = new BufferedImage(
                    (int)(component.getWidth()*scale),
                    (int)(component.getHeight()*scale),
                    BufferedImage.TYPE_INT_RGB);
    
                Graphics2D g = bi.createGraphics();
                g.scale(scale, scale);
                component.paint(g);
                g.dispose();
    
                return bi;
            }
        }
    
        ShowPreviews() {
            JPanel gui = new JPanel(new BorderLayout(2,2));
    
            final CardLayout cards = new CardLayout();
            final JPanel cardPanel = new JPanel(cards);
    
            JPanel treePanel = new JPanel();
            JTree tree = new JTree();
            tree.setVisibleRowCount(5);
            tree.expandRow(2);
            treePanel.add(new JScrollPane(tree));
            cardPanel.add(treePanel, "tree");
    
            JPanel labelPanel = new JPanel(new GridLayout(0,1,2,2));
            for (int ii=1; ii<7; ii++) {
                labelPanel.add(new JLabel("Label " + ii));
            }
            cardPanel.add(new JScrollPane(labelPanel), "label");
    
            JToolBar uiSelectors = new JToolBar();
            // we should use a ButtonGroup for the cards,
            // but plain buttons look better on hover.
            JButton treeButton = new JButton("Tree");
            treeButton.addActionListener(new ActionListener(){
                public void actionPerformed(ActionEvent ae) {
                    cards.show(cardPanel, "tree");
                }
            });
            uiSelectors.add(treeButton);
    
            treeButton.addMouseListener( new ToolTipListener(treePanel));
    
            JButton labelButton = new JButton("Label");
            labelButton.addActionListener(new ActionListener(){
                public void actionPerformed(ActionEvent ae) {
                    cards.show(cardPanel, "label");
                }
            });
            uiSelectors.add(labelButton);
    
            labelButton.addMouseListener( new ToolTipListener(labelPanel));
    
            gui.add(uiSelectors, BorderLayout.NORTH);
            gui.add(cardPanel, BorderLayout.CENTER);
    
            JOptionPane.showMessageDialog(null, gui);
        }
    
        public static void main(String[] args) {
            // start the GUI on the EDT
            SwingUtilities.invokeLater(new Runnable() {
                @Override
                public void run() {
                    new ShowPreviews();
                }
            });
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

We want to create a widget platform for a particular website. I couldn't find
I want to create a dynamic object in Python and then add attributes to
I want to create and then open a txt file using the ShellExecute command.
I want to create an view in Oracle which calculates an "utilization rate in
I want to create JSON , format is like "header": { "b":"aaaa", "c":"00", "d":"zzzzz",
I want to create a Link in my Quartz-Job in grails like this: createLink(controller:"auto",
I have two branches: master and dev I want to create a "feature branch"
I want to create an inline-block that will take on some unknown width and
I want to create a string with this exact text: nuke.execute("Write1", 1, 10, 1)
I want to create the following element: <exercises xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="mySchema.xsd"> If I use something

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.