jcomponent Questions

3

Solved

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?
Tobietobin asked 31/3, 2013 at 8:15

8

Solved

I have a JPanel full of JTextFields... for (int i=0; i<maxPoints; i++) { JTextField textField = new JTextField(); points.add(textField); } How do I later get the JTextFields in that JPanel?...
Haemachrome asked 16/12, 2008 at 2:21

6

Solved

I'm trying to place a series of JLabels at specific X and Y coordinates on a JPanel (and set its height and width, too). No matter what I do, each label winds up immediately to the right of the pre...
Hyman asked 25/8, 2012 at 5:7

3

I have added a button to a JPanel. I want to remove the button if the JPanel contains the button. Is there any way to check whether the JPanel contains the button?
Dartboard asked 5/9, 2011 at 10:13

4

Solved

I have this code to get all the elements I need and do some processing. The problem is I need to specify every panel I have to get the elements inside it. for (Component c : panCrawling.getCompone...
Hubert asked 27/6, 2011 at 16:13

4

Solved

In Swing, what's the best way to make the JSplitPane to split two jpanels with 50% size each. It looks like if I don't set preferred sizes on the panels it always makes the first panel almost invi...
Rutharuthann asked 22/2, 2010 at 14:27

1

Solved

I am in the process of learning and creating a custom JButton/Component. I have the most of what I need, except I do not know how to call actionPerformed on my ActionListners. Code: package myPro...
Connie asked 14/8, 2015 at 3:55

3

Solved

I have a very simple problem. I am learning Java, and was given an assignment to draw a car. I did this all in one class that extends JPanel, and did the drawing within paintComponent(). I realize...
Reimburse asked 18/9, 2014 at 20:6

3

I want to start building my own customized JComponent's for a project at work. I have a simple example below that should just create a ball on the screen. (I found most of it on the internet) but i...
Incestuous asked 5/5, 2014 at 18:54

2

Solved

I always see advices in this site of overriding getPreferredSize() instead of using setPreferredSize() as shown in these previous threads for example. Use of overriding getPreferredSize() instead...
Confrere asked 10/1, 2014 at 19:33

2

So in a recent answer, someone commented this (in regards to painting): "This is probably some kind of illness of 90% of Swing Programmers: When they make their own component, they always extend...
Guidepost asked 26/12, 2013 at 16:18

1

Solved

Now this might sound very strange, which is also the reason I think it's a bug in Java itself. I'm currently making custom components for my applications. These components (which extent JComponent...
Zapata asked 17/11, 2013 at 23:29

1

I'm playing around with Java Swing and i'm really confused when comes to JPanel vs JComponent. According to CoreJava Vol 1 (cay horstmann): Instead of extending JComponent, some programmers pref...
Fidelity asked 1/10, 2013 at 17:32

2

Solved

I am writing a code for basic GUI. There i need a Text Area. But i can not make the Text Area in my desirable size. i use setPreferredSize method to set the dimension of the Text Area. But it did n...
Brunell asked 12/9, 2013 at 14:42

6

Solved

I've always wanted to create custom components in Java, or customize existing ones, but my searches never resulted in anything useful. So I decided to ask the StackOverflow community: Where ...
Emotion asked 5/5, 2009 at 1:19

4

Solved

It's my first Post here, so forgive me please if i'm doing something wrong. My Problem is: I am trying to add Components to a JPanel with defined values for Size etc. But when i add them to the P...
Flavoprotein asked 14/1, 2013 at 14:53

1

Solved

I have a jScrollPane and a button on a form. The button adds a component to the jScrollPane. I'm using a FlowLayout with a center alignment to arrange the components within the jScrollPane. The f...
Medical asked 4/1, 2013 at 0:51

1

My understanding: Unlike most of the components/operations in Swing call to JComponent.repaint() is thread-safe i.e. though a repaint request is made from another thread (i.e. not from EDT), the ac...
Agonic asked 25/12, 2012 at 14:52

4

Solved

I have a java program that opens a popup menu when right clicked in a JPanel. When any of the popup menu items are clicked, I want to print the location of the right click that triggered the popupm...
Avigdor asked 1/12, 2012 at 15:22

1

Solved

Imagine you have a JScrollPane and many JLabels or any other JComponents added to it. How would you check if a certain component is visible/partially visible/not visible to user? (scrolling) I ha...
Ervinervine asked 29/11, 2012 at 14:19

1

Solved

I have a custom component that extends JComponent, which overrides the method paintComponent(Graphics g) but when I try to add it to my JPanel it just doesn't work, nothing is drawn. Here is my co...
Brigette asked 6/10, 2012 at 11:13

1

Solved

I don't understand the wrapping behavior in a JTextPane. If I insert a short text, then a JComponent and then again the short text I can see the inserted stuff in one line if the frame is large eno...
Mcclure asked 27/8, 2012 at 10:13

3

Solved

I'm currently working on a project in which I need a very simple editor for GUI-like objects. This editor would be a canvas on which well known GUI widgets can be placed. For example one can place ...
Affection asked 16/8, 2012 at 14:58

3

Solved

What's the difference between Component.isShowing() and Component.isDisplayable()? I want to use them to decide wheter I should stop/start a Timer.
Clave asked 15/8, 2012 at 11:51

1

Solved

Are there some rules, or good/bad experiences with AncestorListener, ComponentListener or HierarchyListener listening for visibility of changes with JPanel and JComponents? Is one of them better o...
Hornbill asked 4/6, 2012 at 11:14

© 2022 - 2024 — McMap. All rights reserved.