A Briarwood

Greenhorn
+ Follow
since Apr 15, 2011
Merit badge: grant badges
For More
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
0
Received in last 30 days
0
Total given
0
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by A Briarwood

I guess what my question boils down to is: Should I be trying to avoid situations in which ((JFrame)getParent().getParent().getParent()).setSize(...) is the way a child component accesses its parent? (That's why I specified the child-parent relationship.)

I just included the longer example to suggest MVC as a possible solution.
Let's say I'm building a Java Swing GUI, and I've got a frame which contains a panel, containing another panel, which contains a button. (Assume the panels are reusable, and so I've made them into individual classes.)

Frame → FirstPanel → SecondPanel → Button

In reality, the line of children could be more complex, but I just want to keep this example simple.

If I want the button to control one of its parent components (eg. resize the frame), what is the best way to implement functionality between two GUI classes that aren't necessarily one directly inside the other? I don't like the idea of stringing getParent() methods together, or of passing the instance of Frame down through its children so that it can be accessed from SecondPanel. Basically, I don't want to daisy-chain my classes together one way or another. Is this an instance in which the button should be updating a model and not the parent component directly? Then the parent is notified of the model's change and updates itself accordingly?

I've put together a little example that should compile and run on its own to illustrate my problem. This is two JButtons in a JPanel, in another JPanel, in a JFrame. The buttons control the size of the JFrame.

What I don't like, is that the controller needs to exist in the JFrame so that the frame can register itself to receive events. But the controller then has to be passed all the way down to the SecondPanel (lines 112, 131, and 143) so that the panel can communicate with the model. I feel like there is something inefficient going on here (and the classes become too tightly coupled). Let me know if my problem isn't clear.

Yes, that worked. Thanks.

But why does setting a minimum size affect whether or not the divider can resize the panel?
12 years ago
Hello all,

I've got a JSplitPane with a left pane and a right. In the right pane I've got several components added to a JPanel using the default FlowLayout. If I resize the right edge of the JFrame using the mouse, the components in the FlowLayout rearrange themselves properly, but if I try to do the same thing using the divider, it doesn't allow me to "squish" the components and move them to the next line.

Is there a way to make the divider resize the right panel the way the edge of the frame does?

Here's a little self-contained example depicting the problem I'm having.

12 years ago

Pat Farrell wrote:I download the Netbean bundle which includes the Netbeans IDE, the latest JDK, Glassfish and Apache Tomcat.

To run a JEE application, you need a servlet container, like Glassfish, Tomcat, JBoss, etc.



I understand what I need to run JEE, but what I'm asking about is the way the software itself is bundled. It's the equivalent of locking your keys in your car.

Anyway, this was probably a pointless topic, so I'm marking it as solved.
12 years ago
I'm setting up Java EE on my Ubuntu system. I've downloaded the most recent setup for "Java EE SDK with Java 6 JDK", which is java_ee_sdk_6u2_jdk-linux.sh.

When trying to run the .sh file, it tells me that I need to have Java 6 installed because it needs access to the jar command (from the JDK). I thought the JDK 6 was included in the bundle . . . but I then need to download it separately so I can install the file that it's bundled in? Seems like a catch 22.

I mean, I'll do it, but it seems silly bundle the JDK 6 with Java EE if you have to download JDK 6 separately to run it.

Am I missing something here?
12 years ago