I am creating a JDBC application, which the user interface consists of 2 tabs. First tab is to insert data, second is to update. When the user click on the second tab, I need to execute the method "getUpdates()". I need to execute this method each time that the user navigates to this second tab. How can I do it?
(For more information, these two tabs are separate Java beans, which extends the class "Common GUI". "Common GUI" extends from JPanel. They get displayed in class "Main GUI", as tabs)
Please help!
If you are using JTabbedPane then you could use JTabbedPane#addChangeListener as seen in this example
Related
This question is conceptual, and I am asking on this help forum in order to look for a lead to go off and research, and will not contain any code examples other than one to demo what I am using to grab the element value described below, here is some background:
The test I am writing involves signing in to the same application using two driver sessions each of which open a webdriver chrome window. Each one logs in to our app as a different user, and then from one, you can see the "online/offline" status of the other.
We use one class of methods for the first session, and another class of methods for the second session, and if a feature file title appears in a third class containing a LinkedList of strings, then the system knows to open the second session, and we then call methods in the relevant class to run jobs in the appropriate window.
In the current test case I am creating, the objective is to assert in a window we shall call "A", that the element being checked has a specific CSS property, namely its color property. It is grey when the other window that we shall call "B" does not have focus, and it is green, meaning online, when it does have focus, and is logged in.
The logged in side I can take care of, and manually I can see that it is working, but after this log in, when I use from the class that runs commands for window "A" the following line, directly after the last line that directs window "B" to have focus and do something, then it writes the value for "offline" in to the variable shown, as the window "B" has had to lose focus in order to check the element in window "A".
String color = seleniumClient.getWebDriver().findElement(By.xpath("//div[#id='user-content-button']/span/span")).getCssValue("background-color");
I am not able to influence the development of our app, as I am a QA, but I am asking if anyone knows how to maybe freeze the state of the chrome session for window A showing window B to be online before I run the above line, or any other way that I can get my test to see the correct state when the focus is not on the window "B"
Thanks.
How do I get the same name after a successful login?
I have user class that set user.setName after verifying the user name and password from text file in login JFrame and user.getName in other frame to greet user in the main menu.
There's lots of different ways to do it, but basically it boils down to Passing Information to a Method or a Constructor.
One thing you should do is to try and decouple the process. Your "main menu" doesn't care where or how the user name is generated/gained, it only needs it. Equally, your login process doesn't care what happens after the user is validated.
To that end, you should take the time to understand the model-view-controller paradigm, you will see it a lot and will help you solve similar questions.
Basically, a "controller" will display the login view, the login view will gather the credentials and the this information will be feed back through the model for validation. When successful, the controller can pass control on to the next controller which will actually display the "main menu", providing the login model as part of the information.
Again the "how" depends a lot on the overall solution, but you want to get to the point where you have the ability to change either or both the main menu and login windows and it won't have any affect on the other
You can also have a look at:
Open JFrame, only after successfull login verification with database. Using Eclipse?
Java and GUI - Where do ActionListeners belong according to MVC pattern?
Open a JPanel after pressing a button in a JFrame
for more details and ideas
So i am writing an eclipse plugin, which adds a custom-launch action to the toolbar. It extends AbstractLaunchToolbarAction , thus it also has that dropdown menu with launch history and so on. This menue is filled up with actions, containing the lauch-configurations.
At this point, when i open dropdown menu and select one launch configuration from the history, it works fine and runs the configuration.
However, my aim would be to alter this behaivor, to do something more.
My problem is that i cannot find the place where the launch configuration from the menu is processed, thus i cannot do anything with it...
So far i just create the menue by calling the fillMenu(Menu m)
So my question is, how (in code) does eclipse proccess the exceution of the history launch-configuration? Where does the actual launching take place.
Figured it out... The menu consists of Action elements, which have method 'run' ... This method gets called when the Action is clicked.
I have a question. I am creating a User Interface for an UML-model.
When I execute my User Interface (the application), I first want a "main menu"-frame to pop up, giving me 3 different choices (Buttons to push).
For example, I want the "main menu"- frame to show me this:
Customer(button1)
Product(button2)
Order(button3)
When I for example click on the "Customer"-button I want it to access the "Customer"- frame which is a separate frame where there will be other buttons, textfields etcetera.
Bear in mind that I am a noob in Java, it's the first semester in school.
How do I make this possible?
We are building our own Web Browser in Java. It doesn't have to be anything too complicated, we just want several things to do so we could distinguish our project from others.
What we want to know is this:
Is it possible to somehow embed a JTextField object into a JMenuItem?
To be more precise, we want our address bar (text field) to show when we click on a certain item within our menu.
Well, menu items are used for invoking an Action which causes the menu to close.
So you would just have your menu item Action display a popup dialog or something like that.
Or, if you really want to keep the popup open, the you could probably create a sub menu and then just add the JTextField to the sub menu. Remember, you can add any Component to JMenu.
Or, if you just want the text field to display on the main menu, then you just add the text field to the main menu. Of course you would lose functionality like being able to use the keyboard to navigate up and down the menu list.
All the suggestions are a hack at best, so I agree with the original comment to your question.
It's done in the standard OS X "help" menu, so I wouldn't call it an interface "quirk".
A quick google turned up this old link from 2004:
http://coding.derkeiler.com/Archive/Java/comp.lang.java.gui/2004-12/0149.html