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 7933315
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T21:17:39+00:00 2026-06-03T21:17:39+00:00

My program will alert users when data (stock name & price) in the database

  • 0

My program will alert users when data (stock name & price) in the database matches with the data (stock name and price) from Yahoo Finance. With the help of HarryJoy i’m able to implement a pop up notification.

Problem is the pop up location on the screen is based on the database loop (int db). The frame will pop even if data doesn’t match.

How can I set a counter or some method to pop up the frame only when database data = Yahoo Finance data? Also, my notification panels appears to be behind the main frame. How can make the panels appear on top of my main frame?

I hope I’ve given enough information, please ask if still unclear. Any guidance will be appreciated! Thanks!

In the database (using code sample only to display my explanation in order, source code below).

Object 1 = match
Object 2 = doesn't match (hence there's a gap)
Object 3 = match
Object 4 = match

Screenshot:

PopUp

Code:

 for (int db=0; db<= rowCount; db++) 
    {                   
        Object popSymbol = table.getModel().getValueAt(db, 0); 
        String popupSymbol = popSymbol.toString(); 

        Object popValue = table.getModel().getValueAt(db, 1);                          
        String str = popValue.toString(); 
        double popStockValue = Double.valueOf(str).doubleValue(); 

        String stockNameDB = popupSymbol;       
        StockPara stock = YahooStock.getInstance().getStockPrice(stockNameDB);
        double stockPriceDB = Math.round(stock.getPrice()); 

        final JFrame popUpFrame;
        final JPanel popupPanel;                    

        if (stockPriceDB == popStockValue)                      
        {
            String header = "Stock: "  + stock.getTicker() + " is now @ " +  stock.getPrice();          
            String message = "";  

            popUpFrame = new JFrame();
            popUpFrame.setSize(320,90);                         
            popUpFrame.setUndecorated(true);                                    
            popUpFrame.getContentPane().setLayout(null);    

            popupPanel = new JPanel();
            popupPanel.setBorder(new LineBorder(new Color(0, 0, 0)));
            popupPanel.setBounds(0, 0, 320, 90);
            getContentPane().add(popupPanel);
            popupPanel.setBackground(new Color(255, 255, 224));
            popupPanel.setLayout(null);
            popUpFrame.add(popupPanel);                 

            // Other labels, images, etc. 

            Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
            Insets toolHeight = Toolkit.getDefaultToolkit().getScreenInsets(popUpFrame.getGraphicsConfiguration());
            popUpFrame.setLocation(screenSize.width - popUpFrame.getWidth(), screenSize.height - toolHeight.bottom - (popUpFrame.getHeight() * (db+1)));

        } 
    }
  • 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-03T21:17:41+00:00Added an answer on June 3, 2026 at 9:17 pm

    To solve your issue quickly, simply create an additional counter (int counter = 0;). Then use that counter instead of db to position your popUpFrame and right after that increment counter.

    int counter = 0; // Initiate outside de loop
    ...
    for(int db=0; db<= rowCount; db++) {
        ...
        if (stockPriceDB == popStockValue) {
             ...
             popUpFrame.setLocation(screenSize.width - popUpFrame.getWidth(), 
                screenSize.height - toolHeight.bottom - (popUpFrame.getHeight() * (counter+1)));
             counter++;
        }
    }
    

    To bring your frame to the front use:

    popUpFrame.toFront()
    

    and to force it to be always on top (although I would really not recommend that because it is more annoying for the user than anything else):

    popUpFrame.setAlwaysOnTop(true);

    This is not necessarily supported by all platforms.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

My program will alert users when data (stock name & price) in the database
I have a search program that will be looking at a database from a
As we all know Java program will start executing from the public static void
I have a program that will let me manage users on our terminal server
My program will sometimes be launched from another program. If that's the case, I
I created a server program that will be started as root. After it is
I have a java program that will work with a variety of Java Beans.
when I ran a program which will cause the segmentation fault as root user
I am compiling my program that will run on linux gcc 4.4.1 C99. I
I'm writing a program which will use scan conversion on triangles to fill in

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.