Questions tagged [jpanel]

JPanel is a container in the Java Swing Framework that allows custom rendering using layout managers. JPanels can be nested for flexibility. There is also a jQuery plugin with the same name that provides accordions, tabs, and fieldsets from simple container mark up.

JPanel is a container in the Java Swing Framework that allows custom rendering using layout managers. JPanels can be nested for flexibility. There is also a jQuery plugin with the same name that provides accordions, tabs, and fieldsets from simple container mark up.

Resources:

7557 questions
17
votes
2 answers

Add ButtonGroup to JPanel

JPanel.add(ButtonGroup); Is not working. I MUST add it to a JPanel because I am using tabs. This is getting really frustrating.I hace not found a way yet
ntakouris
  • 898
  • 1
  • 9
  • 22
17
votes
4 answers

How to make a JPanel expand to max width in another JPanel

I feel I need to rephrase the question a bit. Updated question below. I have a JPanel that contains: myjpanel.setLayout(new BoxLayout(selectors, BoxLayout.PAGE_AXIS)); It contains the following three panels: JPanel with fixed size 'x' and…
Martin Nielsen
  • 1,865
  • 6
  • 30
  • 54
17
votes
3 answers

Scrolling a JPanel

I want a JPanel with a size and defined position. Inside the JPanel, I've certain number of elements (buttons) inserted horizontally. Because my JPanel has a defined width, if I add much buttons, I couldn't see that. In this case, I need a scrollbar…
Chu
  • 468
  • 1
  • 5
  • 21
16
votes
5 answers

Java JPanel inside JScrollPane?

I have a JFrame, in this JFrame I have a JPanel that I draw on, this Panel can be any size and so I placed it into a JScrollpane to let me scroll when the panel is larger than the window screen size. Unfortunately does not work as I…
FiniteRed
  • 810
  • 3
  • 10
  • 20
16
votes
2 answers

How do I know if I'm on the event dispatch thread?

1.Consider my code is on some line of a JPanel that I have, am I automatically on EDT? 2.Same question for all other classes which are not belong to GUI, JPanels or other view classes, simple logical class. 3.If I have JPanel which I'm playing…
JavaSa
  • 5,813
  • 16
  • 71
  • 121
16
votes
5 answers

setting horizontal and vertical margins

What is the method to set horizontal and vertical margins in a panel? (The same we have in html style="margins:30px")
Suhail Gupta
  • 22,386
  • 64
  • 200
  • 328
16
votes
5 answers

add JMenuBar to a JPanel?

I've got a JMenuBar and a JPanel. I'd like to add the JMenuBar to the JPanel. How would I do so?
Skizit
  • 43,506
  • 91
  • 209
  • 269
16
votes
5 answers

Display a jpg image on a JPanel

What would be the most appropriate image type to display a jpg image (loaded from a local folder) on a JPanel? Cheers.
burntsugar
  • 57,360
  • 21
  • 58
  • 81
16
votes
3 answers

paintComponent() vs paint() and JPanel vs Canvas in a paintbrush-type GUI

I got some interesting ideas and criticism from this, this and this post (see last post for the code of the GUI in question). Nevertheless, I'm still quite confused about some things. Mainly, what is the least expensive way of displaying…
Alex
  • 944
  • 4
  • 15
  • 28
15
votes
2 answers

adding multiple jPanels to jFrame

I want to add two jPanels to a JFrame side by side. the two boxes are jpanels and the outer box is a jframe I have these lines of code. I have one class called seatinPanel that extends JPanel and inside this class I have a constructor and one…
dave
  • 419
  • 1
  • 5
  • 10
15
votes
2 answers

Export JPanel Graphics to .png or .gif or .jpg

I'm trying to develop some sort of paint using Java. I have a JComponent that is located inside of a JPanel. I already can draw lines and rectangles into that JComponent. Now, how can I export this drawings as an image (png, gif, jpg)? I tried…
tiiin4
  • 539
  • 4
  • 7
  • 19
15
votes
5 answers

Making a JPanel manually resizable

I have a JFrame with BorderLayout as the layout manager. In the south border, I have a JPanel, I want this JPanel's size to be adjustable by the user, i.e. the user can click on the edge of the border and drag it up to make it larger. Is there any…
saralk
  • 333
  • 1
  • 3
  • 9
15
votes
2 answers

What's so special about CardLayout vs manual adding/removal of JPanels?

There have been many times on StackOverflow where a user asks a question like this... I have a main JPanel that contains a child JPanel. When the user clicks a button, the child JPanel should change to a different JPanel. How can I achieve…
wattostudios
  • 8,666
  • 13
  • 43
  • 57
14
votes
5 answers

IntelliJ gui creator: JPanel gives runtime null pointer exception upon adding any component

I am having a problem with IntelliJ's java gui creation. Most of the code behind the panel is unfortunately hidden within the gui creator and not editable by me. I created a blank JPanel "questionPanel" with the ItelliJ GridLayoutManager. When I try…
kevin948
  • 648
  • 1
  • 8
  • 21
14
votes
3 answers

Substance Look and Feel is making my colors brighter?

I'm trying to call setBackground on a JPanel, so that it matches the color of my JFrame, but the color is some how brighter than the one I type in. I've have tried setting HSB, RGB, HEX code, they all give me the same color, a brighter version of my…
Handsken
  • 664
  • 11
  • 26