Swapnil Sonawane

Ranch Hand
+ Follow
since Jan 02, 2008
Merit badge: grant badges
For More
Cows and Likes
Cows
Total received
In last 30 days
0
Forums and Threads

Recent posts by Swapnil Sonawane

But isn't it that I will have two matching beans for the interface type defined in the class which is going to make use of it eventually. I mean there will be two beans compatible with the interface type, which throws UnsatisfiedDependencyException according to the documentation. Please correct me if I'm wrong.

Thanks,
Swapnil
12 years ago
Hi,

I've a design like below -

In the absence of DatabaseWriter, I'm currently using getBeanNamesForType method to inject the only available bean. But when I have multiple implementations of the interface, I'm not sure how to do this effectively. Using getBeanNamesForType and iterating over the retrieved list doesn't really look like an elegant way. I want to avoid hard-coding the bean names inside the someMethod(). I'm sure this must be a very common use-case today. What's the standard way of solving this using spring?

Thanks,
Swapnil
12 years ago
I am encountering a problem in using JInternalFrame. I have a JPanel placed inside the content pane of JFrame. It has a button "Show". When I click that button, it opens the JInternalFrame as expected. But the show button stays there for a while, say for a second or two and then it disappears. I wonder why there is that delay. This code is a part of a larger application, so posting code won't help much. But has anybody of you experienced the same behaviour? Thanks.
16 years ago
got it solved after renaming validate() to validateIt()
16 years ago



/***************** MainFrameListener.java *************/


The problem is that once I visit ArenaPanel, I mean click on that menu and then move to other panels, clicking on any other menu options in the MainFrame menu bar activates that button and it listens to ArenaListener. I tried to debug but didn't get it. It's strange.
I am trying to say that even if I remove the save button from the arenapanel the job that should be done after clicking on save button is done without clicking on it and clicking somewhere else in the menu bar. And this happens after I visit arenapanel once and not before that. Strange enough for me



Thanks.
[ October 14, 2008: Message edited by: Swapnil Sonawane ]
16 years ago
/************* ArenaListener.java *******************/

import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import javax.swing.table.*;


/**
* @author Swapnil Sonawane
*/

public class ArenaListener implements ActionListener {

ArenaPanel arenaPanel;

public ArenaListener(ArenaPanel panel) {
arenaPanel = panel;
}

public void actionPerformed(ActionEvent evt) {

String actionCommand = evt.getActionCommand();
if(actionCommand.equals("SAVE")) {
arenaPanel.validate();
}

else if(actionCommand.equals("RESET")) {
arenaPanel.clear();
}

else if(actionCommand.equals("ACT")) {
int selectedIndex = arenaPanel.getActivityIndex();
if((selectedIndex==1) || (selectedIndex==2)) {
arenaPanel.enableDescription(false);
arenaPanel.enableExplanation(false);
arenaPanel.enableTimeFields(false);
}
else {
arenaPanel.enableDescription(true);
arenaPanel.enableExplanation(true);
arenaPanel.enableTimeFields(true);
}

}

}
}
16 years ago
I have 4 java files:

MainFrame.java
MainFrameListener.java
ArenaPanel.java
ArenaListener.java

MainFrame extends JFrame and is the main window of my application. ArenaPanel is one of the several panels I have. MainFrame has a menu bar which has menu buttons to go to different panels. The arenaPanel has a SAVE button, actions for which have been defined in arenaListener. Actions for MainFrame menu have been defined in MainFrameListener. Here are my codes. I have removed the irrelavent parts at places as the codes are very long.

/**************** ArenaPanel.java *************/
16 years ago
I have edited my original code. But now I have switched to GridBagLayout (code not posted). After I include that in the JFrame, it is getting packed, but I don't want that and I haven't done the packing in the code.
16 years ago
I have rectified that part already. But I have some other doubt. Changing the location of LoginPane using setLocation or setBounds method doesn't change its location. Why does this happen?
16 years ago
I will clean up and post something that makes sense. I have to get the things clear.

1) Instead of having those labels and textfields in the loginpanel, I had created an instance of JPanel inside the LoginPanel. This happened because I made a mistake while using the GUI builder. I will rectify this now.
[ October 09, 2008: Message edited by: Swapnil Sonawane ]
16 years ago
Here is my code:

ApplicationDriver.java



MainFrame.java




LoginPanel.java




But I do not get the JPanel inside the JFrame. I can only see the JFrame. I am confused a lot.


EDIT 1: LoginPanel.java and MainFrame.java updated and irrelavent code removed. I got the JPanel inside the JFrame. How can I position it to the center? What if I want to change the content pane? Would simply creating an instance of some other JPanel like LoginPanel and passing it to setContentPane do?

[ October 09, 2008: Message edited by: Swapnil Sonawane ]
[ October 09, 2008: Message edited by: Swapnil Sonawane ]
16 years ago
Congratulations Priya
16 years ago
Vishal, Please modify your name according to Javaranch naming policy.
[ June 28, 2008: Message edited by: Swapnil Sonawane ]
16 years ago
Please modify your name according to Javaranch naming policy.
Please post it somewhere else. This forum is for SCJP certification.