Questions tagged [contentpane]

92 questions
2
votes
1 answer

Swing's GroupLayout and setContentPane - losing Components?

After experimentation, it appears to me that Swing's GroupLayout tends to lose Components intended for re-use across my GUI. But I haven't seen anything in the documentation that makes this single-use rule clear. This makes me wonder if I have made…
Arvanem
  • 1,043
  • 12
  • 22
2
votes
1 answer

Referencing coordinates of a JPanel in a JFrame

Hi I am having trouble with referencing the origin of a JPanel within my JFrame. My JPanel was set up like so in the constructor I want to add a line that is on the left edge of my JPanel. table = new JPanel(); …
Yoshi
  • 115
  • 11
1
vote
1 answer

If Statement only lets me change content pane background color by clicking a menu button once. How do I make it change every time I click?

I'm learning Java and am loving experimenting to learn new things; however, I am stuck on what I believe is a logic flaw with my program. What I want to do is have the background of my content pane change to a random color every time I click the…
Ardemesh
  • 11
  • 2
1
vote
2 answers

How to make the JFrame contentPane transparent but the JFrame visible?

I wanted to know how to make the JFrame's contentPane transparent but the JFrame visible. I saw many pages but all showed on how to make the JFrame border visible but the contentPane visible. I tried using setOpacity() but that requires the JFrame…
Learner
  • 77
  • 6
1
vote
1 answer

How to reset or refresh Jframe with new values

I have a Jframe that the user enters new information through a Joptionpane, it is added to an array which is then appended and displayed to a contentpane.. the cycle then repeats till the user enters "STOP". Currently the program is outputting the…
JpersaudCodezit
  • 143
  • 2
  • 13
1
vote
0 answers

Difference between jframe.add() and jframe.getcontentpane().add()

I want know difference between fallowing code Jframe myframe= new Jframe(); myframe.add(new jbutton()); And Contentpane cp=Myframe.getcontentpane(); cup.add(new jbutton());
SHAMBANNA
  • 302
  • 2
  • 11
1
vote
2 answers

Swing & AWT: ContentPane items not showing in JFrame

I'm creating a basic Java Swing app but I am having problems with my content pane as it is not showing my objects. This is my main class this will be calling up other classes in future and is just calling up the Frame.java: public class Main { …
Tom T
  • 59
  • 1
  • 1
  • 12
1
vote
1 answer

Java receipt program not displaying results

I have created a simple application that reads a series of products * quantity sold and generates a final order receipt that includes the sold item name, quantity and total for each item as well as the total for the whole receipt (including 6% sales…
NOSDUH
  • 111
  • 2
  • 12
1
vote
1 answer

Why does getContentPane().getWidth() return 0?

I have a class Window that extends JFrame and a class Content that extends JPanel. An object of Content is added to an object of Window. Class Window: public class Window extends JFrame { private Content content; public Window() { …
so.koni
  • 35
  • 5
1
vote
4 answers

JFrame displaying white bars around content

So I've made a class WindowDisp which extends JFrame: public class WindowDisp extends JFrame{ private static final long serialVersionUID = 3245091489595286109L; private int height, width; private JPanel panel; private JLabel…
user2649681
  • 750
  • 1
  • 6
  • 23
1
vote
1 answer

JFrame not sizing correctly

When I set the size of the JFrame its set the size of the frame itself including the borders. I tried creating a new content Panel and set that size instead of setting the size of the frame itself but it isn't working here is the code: frame = new…
Bram Hoven
  • 13
  • 6
1
vote
1 answer

3 Level List with Hover-to-Content Pane in CSS

I am not certain if a content pane is the right term to be using for this, but what I am trying to achieve is definitely close to that description. I am attempting to write a webpage that has a section with a List, with Sublists that when hovered…
1
vote
1 answer

Why must I use getContentPane() instead of "this" when setting a BoxLayout for a JFrame?

Why must I use getContentPane() instead of this keyword as a parameter argument for BoxLayout when setting a JFrame's layout to BoxLayout. To give a JPanel a BoxLayout, I must use this as a parameter. I think this is because a JFrame has several…
poetryrocksalot
  • 697
  • 2
  • 10
  • 19
1
vote
3 answers

Why is my frame not resizing?

When you choose a state, the frame's content pane removes its components. Then depending on the state you chose, another class takes the content pane and adds onto it. After doing so, the frame gets packed to resize accordingly. I want free control…
Vince
  • 14,470
  • 7
  • 39
  • 84
1
vote
1 answer

When resetting the ContentPane, button function no longer works properly Java swing

I have the following actionevent on a button which takes me from the home screen to the second screen. public void advancedBtnAction(ActionEvent evt, JFrame frame) { frame.remove(this.getContentPane()); …
BrandonW
  • 17
  • 4