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

  • Home
  • SEARCH
  • 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 613213
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T17:58:41+00:00 2026-05-13T17:58:41+00:00

I am trying to construct a basic control that will display an undecorated JFrame

  • 0

I am trying to construct a basic control that will display an undecorated JFrame right below it when a button is clicked. I am trying to mimic drop down type functionality, but with my own Frame instead of a panel. My component contains a class member of the JFrame derived control that I would like it to show. In certain situations, when setVisible is called, the contents of this JFrame are not painted. This appears to be happening when I am trying to display the JFrame on my left most monitor, which uses negative x coordinates (my primary monitor is the middle monitor). The strange thing is this issue appears only on my Windows 7 machine, but not on an XP machine.

Here is a very basic sample that demonstrates the problem. As you can see, it is very basic sample that should simply hide and display the DropFrame. I have omitted the code from initComponents, in this case all it does it add a button to each frame and the necessary ActionListeners for each button.

Code:

public class NewJFrame extends javax.swing.JFrame {
private javax.swing.JButton jButton2;
private DropFrame f = new DropFrame();

/** Creates new form NewJFrame */
public NewJFrame() {
    initComponents();
}

private void initComponents() {
    //Create button and add it to the frame...
    pack();
}

private void jButton2ActionPerformed(java.awt.event.ActionEvent evt)        {                                         
    SwingUtilities.invokeLater(new Runnable() 
    {
        public void run() {
            Point p = jButton2.getLocationOnScreen();
            f.setLocation(p.x, p.y + 25);
            f.setVisible(true);
        }
    });

}                                        

/**
* @param args the command line arguments
*/
public static void main(String args[]) {
    java.awt.EventQueue.invokeLater(new Runnable() {
        public void run() {
            new NewJFrame().setVisible(true);
        }
    });
} }

public class DropFrame extends javax.swing.JFrame {
private javax.swing.JButton jButton1;  

/** Creates new form NewJFrame1 */
public DropFrame() {
    initComponents();
}

private void initComponents() {
    //Create button and add to frame...
    pack();
}                   

private void jButton1ActionPerformed(java.awt.event.ActionEvent evt)    {                                         
    this.setVisible(false);
} }                                                  

The problem does not exist if I create a new DropFrame on each button click, as opposed to reusing and setting the visibility of the same Frame, but this is not desired.
Any ideas on why my DropFrame is not painted sometimes?

  • 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-05-13T17:58:41+00:00Added an answer on May 13, 2026 at 5:58 pm

    Here are a couple of things to look at:

    #1
    What version of the JVM are you running? Sun make a lot of changes to the graphics pipeline in the different releases of 1.6. Pre update 10 releases behave quite differently from later releases. (Note: Firefox 3.6+ requires update 10 or higher for applets to work.)

    #2
    In your init components add these lines:

        Point location = getLocation();
        setLocation(new Point(0, 0));
        setLocation(location);
        pack();
    

    The call to setLocation() eventually Component.notifyNewBounds(boolean resized, boolean moved), which traverses the component hierarchy setting each component’s bounds.

    By default this is done “lazily” which seems to cause Java some issues when calculating where a component is (or where it should be). The above code forces the bounds to be computed up front.

    #3
    If you’re running u10 or higher, start your application with the argument

    -Dsun.java2d.d3d=false
    

    This disables the DirectX pipeline. If that makes the problem go away, update your display drivers.

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

Sidebar

Ask A Question

Stats

  • Questions 378k
  • Answers 378k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer Use ReflectionTestUtils to set a different implementation manually in your… May 14, 2026 at 9:06 pm
  • Editorial Team
    Editorial Team added an answer Not so much that you should be concerned. It's certainly… May 14, 2026 at 9:06 pm
  • Editorial Team
    Editorial Team added an answer Not really, no. You can only store bits in it,… May 14, 2026 at 9:06 pm

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.