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
20
votes
3 answers

How to include custom panel with NetBeans GUI Builder?

I have written a class that extends JPanel. Is it possible to use this in the NetBeans GUI Builder and have it survive all of the automatic code generation? I have used the customised code option in the GUI builder to instantiate the object as the…
Curyous
  • 8,716
  • 15
  • 58
  • 83
20
votes
3 answers

Draw a line in a JPanel with button click in Java

I want to draw a line in a JPanel. This is my GUI and I want a line in the JPanel in white. I find many examples but the problem is the how to use it. In many exmples, always they draw in a JFrame that extends from a JPanel. I want to add the Panel…
Ali Ben Messaoud
  • 11,690
  • 8
  • 54
  • 87
20
votes
3 answers

Concerns about the function of JPanel: paintcomponent()

hello I'm new in java programming, and i need someone explaining me these lines of code: public class drawpanel extends JPanel { public void paintComponent(Graphics g) { super.paintComponent(g); ... } } I dont…
jose gabriel
  • 754
  • 2
  • 8
  • 21
20
votes
2 answers

How to increase the slow scroll speed on a JScrollPane?

I am adding a JPanel in a JScrollPane in my project. All is working fine, but there is one problem about mouse scroll using the mouse-Wheel in JPanel. It's speed is very slow on scrolling. How to make it faster? My code is : JPanel panel = new…
Ronak Jain
  • 2,402
  • 2
  • 24
  • 38
19
votes
6 answers

How to set border on jPanel?

My projects constists of two classes, GoBoard extends JPanel. GoTest.java: import javax.swing.*; import java.awt.Graphics; import java.io.*; import java.awt.*; import javax.swing.border.Border; import javax.swing.border.LineBorder; class GoTest{ …
DarkLeafyGreen
  • 69,338
  • 131
  • 383
  • 601
19
votes
4 answers

How to show/hide JPanels in a JFrame?

The application I am developing is a game. What I want to do is have JPanels that appear in the JFrame, like a text or message window, and then disappear when they are no longer used. I have designed these JPanels in Netbeans as external classes…
aharlow
  • 267
  • 1
  • 4
  • 9
19
votes
8 answers

Java get JPanel Components

I have a JPanel full of JTextFields... for (int i=0; i
Devoted
  • 177,705
  • 43
  • 90
  • 110
19
votes
6 answers

Java Swing - How to disable a JPanel?

I have several JComponents on a JPanel and I want to disable all of those components when I press a Start button. At present, I am disabling all of the components explicitly by component1.setEnabled(false); : : But Is there anyway by which I can…
Amit
  • 33,847
  • 91
  • 226
  • 299
19
votes
2 answers

Zoom JPanel in Java Swing

I have an existing Java Swing application. In the middle of the application is a single JPanel which I want to be able to zoom in and out of. The JPanel has a number of JComponents on it (mostly other JPanels and JLabels). Also mouse position will…
sboy031
  • 205
  • 2
  • 5
19
votes
1 answer

Changing Panels using the Card layout

Hi Im sorry if this has already been posted but I looked hard and found other codes that I could not understand very well. I am new to java programming and would like someone to point me in the right direction on how I could change to desired panels…
user1906515
18
votes
4 answers

Java - Vertical "FlowLayout" with Horizontal Scrolling

As described in the title, I've been trying to set up sort of a vertical flow layout with horizontal scrolling. The components within the layout will be JLabels. Let me draw a picture: +-------------------------+ <--- window |Label1 Label4 …
RyanB
  • 707
  • 1
  • 5
  • 18
18
votes
2 answers

Dynamically remove Component from JPanel

I am adding and deleting components dynamically in a JPanel. Adding and deleting functionality works fine but when I delete the component it deletes the last component rather than the component to be deleted. How can I solve this issue?
ManthanB
  • 404
  • 2
  • 5
  • 21
18
votes
2 answers

How do I draw an image to a JPanel or JFrame?

How do I draw an Image to a JPanel or JFrame, I have already read oracle's tutorial on this but I can't seem to get it right. I need the image "BeachRoad.png" to be displayed on a specific set of coordinates. Here is what I have so far. public class…
Saucymeatman
  • 587
  • 3
  • 6
  • 8
18
votes
2 answers

How to layout multiple panels on a jFrame? (java)

I am in the process of making my own java socket game. My game is painting alright to the full screen (where it says "paint graphics here", but im painting to the whole jframe at the moment). I want to add a textbox with a scroll bar for displaying…
Code Doggo
  • 2,146
  • 6
  • 33
  • 58
18
votes
4 answers

Convert JPanel to image

Is there a way to convert a JPanel (that has not yet been displayed) to a BufferedImage? thanks, Jeff
Jeff Storey
  • 56,312
  • 72
  • 233
  • 406