Win a copy of Practical SVG this week in the HTML/CSS/JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Opaque

 
wayne whitman
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ok, I'm a Java/Swing newbie, so can anyone tell me why this panel displays transparent when I run the application that calls it? The main gui comes up opaque.

public void displayRIP(byte[] response) {
JFrame rip = new JFrame("RIP Display");
rip.getContentPane().setLayout(new FlowLayout());
rip.setSize(400,200);

JPanel display = new JPanel();
display.setSize(400,200);
rip.getContentPane().add(display);

display.setOpaque(true);

JTextField tf0;
tf0 = new JTextField(8);
JTextField tf1;
tf1 = new JTextField(8);

rip.setVisible(true);
display.setVisible(true);

Thanks for any help!
 
pete stein
Bartender
Posts: 1561
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
My guess is that your problem lies in code that hasn't been posted here. Could you have an EDT that is blocked by a Thread.sleep call or by a CPU-intensive process? My recommendation is that you post a small compilable program that demonstrates your problem.

Also, when posting your code, please use code tags so that your code will retain its formatting and be readable. To do this, you will need to paste already formatted code into the forum, highlight this code, and then press the "code" button at the top of the forum Message editor prior to posting the message. Another way is to place the tag [code] at the top of your block of code and the tag [/code] at the bottom, like so:

 
Michael Dunn
Ranch Hand
Posts: 4632
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
add this line and it should give you an idea of what is happening

display.setBorder(BorderFactory.createLineBorder(Color.BLACK));
 
Tell me how it all turns out. Here is a tiny ad:
the new thread boost feature brings a LOT of attention to your favorite threads
https://coderanch.com/t/674455/Thread-Boost-feature
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!