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
14
votes
1 answer

How to set padding at JLabel

I want to display a Multiline JLabel into JPanel. So I have this code but I'm not able to show the multiline JLabel. public class NotificationFrame extends JFrame{ public NotificationFrame(){ JPanel panelBody = new JPanel(); …
bircastri
  • 2,169
  • 13
  • 50
  • 119
13
votes
4 answers

Add a JFreeChart in to JPanel

if i have a my Jpanel and a my JFreeChart. How can I add this Chart in to the JPanel? XYSeries series = new XYSeries("XYGraph"); series.add(1, 1); series.add(1, 2); series.add(2, 1); series.add(3, 9); series.add(4, 10); // Add the…
Safari
  • 11,437
  • 24
  • 91
  • 191
13
votes
2 answers

Java JTextArea that auto-resizes and scrolls

I have a JTextArea in a JPanel. How can I have the JTextArea fill the whole JPanel and resize when the JPanel resizes and scroll when too much text is typed in?
None
  • 3,875
  • 7
  • 43
  • 67
13
votes
1 answer

How to remove the padding between in the JPanel still using a flow layout?

Here's the portion of my java application GUI that I have a question about. What this GUI consists is a blue JPanel(container) with default FlowLayout as LayoutManager that contains a Box which contains two JPanels(to remove the horizontal spacing…
committedandroider
  • 8,711
  • 14
  • 71
  • 126
13
votes
3 answers

How can I get all the components of a panel in Java Swing?

How can I get all the components of a panel in Java Swing? Is there any method like foreach in C# to deal all the child components of a JPanel?
user1918908
13
votes
5 answers

How to make JLabels start on the next line

JPanel pMeasure = new JPanel(); .... JLabel economy = new JLabel("Economy"); JLabel regularity = new JLabel("Regularity"); pMeasure.add(economy); pMeasure.add(regularity); ... When I run the code above I get this output: Economy Regularity How can…
Jessy
  • 15,321
  • 31
  • 83
  • 100
12
votes
2 answers

java JPanel How to fixed sizes

I want to have a resizable panel, that always has the top green panel of a fixed depth. i.e. all changes in height should effect the yellow panel only. My code below is almost OK, except the green panel varies in size a little. How do I do this? …
ManInMoon
  • 6,795
  • 15
  • 70
  • 133
12
votes
2 answers

JPanel removeAll doesn't get rid of previous components

I have a swing application in which I display images in a JPanel. If the app is unable to produce the image I want to remove the previous one from the JPanel and replace it with a JTextField and message. I can add the text field , but it's drawn on…
jaybee
  • 1,897
  • 2
  • 16
  • 29
12
votes
4 answers

JLabel - Show longer text as multiple lines?

So say I have a really long line that I want to display in a JLabel. How can I do it? Currently, longer lines come up as this: I have to resize the window to see the complete text. How can I make it so that there's linebreaks when the text almost…
user2027425
  • 389
  • 3
  • 5
  • 14
12
votes
3 answers

placing a transparent JPanel on top of another JPanel not working

I am trying to place a JPanel on top of another JPanel which contains a JTextArea and a button and i want to the upper apnel to be transparent. I have tried it by making the setOpaque(false) of the upper panel. but it is not working. Can anyone help…
Nikhil
  • 2,857
  • 9
  • 34
  • 58
12
votes
2 answers

Can I create a BufferedImage from a JPanel without rendering in a JFrame?

Is it possible to create a BufferedImage from a JPanel without first rendering it in a JFrame? I've searched everywhere I can think of and cannot find an answer. Can anyone help? Here is some sample code. If I don't un-comment the JFrame code, my…
Brooke
  • 175
  • 1
  • 1
  • 8
12
votes
2 answers

How to get real JPanel Size?

How should I get real JPanel size in JFrame?
Yoda
  • 17,363
  • 67
  • 204
  • 344
12
votes
6 answers

JPanel setBackground(Color.BLACK) does nothing

I have the folowing custom JPanel and I have aded it to my frame using Netbeans GUI builder but the background won't change! I can see the circle, drawing with g.fillOval(). What's wrong? public class Board extends JPanel{ private Player…
c0dehunter
  • 6,412
  • 16
  • 77
  • 139
11
votes
4 answers

Basic code to display a pdf in an existing JPanel?

I have an existing interface that has a JPanel for displaying pdf files. It is important to display the pdf inside this inteface and not open a new window. How can I display a pdf on the JPanel without using unnecessary code (libraries) if possible?
thewikus
  • 445
  • 1
  • 5
  • 16
11
votes
2 answers

Draw line over multiple panels in Java

I'm trying to draw a line (Red line in the image) over multiple panels, but I can't seem to make it work. How can I make this possible? Any suggestions?
charmae
  • 1,080
  • 14
  • 38