Search function Not Working - java

I have a text Field where the user enter a world to search a JTable when the user click a button called btnSearch.
every time I try to perform a search nothing happen and an Exception is thrown (see error below) when debug it show that the error occur at the if statement condition. could you please explain what I should do to fix the problem
the Error:
Exception in thread "AWT-EventQueue-0" java.lang.NoSuchMethodError:com.mysql.jdbc.StringUtils.isEmptyOrWhitespaceOnly(Ljava/lang/String;)Z
The Code behind the search button:
btnSearch.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent arg0) {
String entry =txtSearchData.getText();
if (StringUtils.isEmptyOrWhitespaceOnly(entry)){
}else{
}
txtSearchData.setText(" ");
}
});

The only explanation I can find is you are using 2 mysql jdbc jars:
one that has StringUtils.isEmptyOrWhitespaceOnly defined, and which is used when you compile your code;
another one that does not have StringUtils.isEmptyOrWhitespaceOnly defined, and which is used when you run your code.
You should use only one version, both for compiling and running.
Check you project dependencies and make sure there is only one mysql jdbc driver.

Related

Tool is delaying output in eclipse plugin developemnt

I am developing plugin for eclipse. It will run my clang tool. In clang tool i am writing simple pass to check that every case and default statement must have the break statement.
I am running my clang tool using process builder.
I am using job API to run my tool and Display class to print the error.
when i run my plugin i am facing some issue.
Let say i commented my break statement of one of the case or default statement , it should print error in console that every case and default statement must have the break statement.
it is printing error after i type something else or some space or trying to uncomment after my comment .
similarly when i do uncomment , it should not print the error , but it is printing , but again when i type something or some space or trying to comment , error disappear.
following is the link of my code
https://github.com/sunilsarode/eclipse_plugin/blob/master/ccchecker/src/ccchecker/handlers/SampleHandler.java
following image show the first case not printing error on my eclipse console on which i am developing a plugin .
and this shows that second case printing error on my eclipse console on which i am developing a plugin .
any help in this ?
EDIT:
I want my plugin-in to output something on console view (not on development console ) or some dot kind of thing on the gutter of the text editor and when i click or hover on that dot , i want to show some popup with error message.
I tried to print message on console view by crating console using this link https://wiki.eclipse.org/FAQ_How_do_I_write_to_the_console_from_a_plug-in%3F
it works , but new problem is , i lost focus from text editor to console that i have created and because of this i am unable to test the problem i mentioned in question.
sorry too much i am expecting.
Following image show that text editor lost its focus to console view and the button you have mentioned is not there at console view but it is there at console of eclipse on which i am writing a code.
Following keypress method and addKeyListener is not working when i press the Ctrl+s. In order to get the save event we have to use the ICommandService with save command.
((StyledText) editor.getAdapter(Control.class)).addKeyListener(new KeyListener() {
#Override
public void keyPressed(KeyEvent keyEvent) {
if (((keyEvent.stateMask & SWT.CTRL) == SWT.CTRL) && (keyEvent.keyCode == 's')) {
// System.out.println("From Display I am the Key down !!" + keyEvent.keyCode);
Job job = new Job("My job") {
#Override
protected IStatus run(IProgressMonitor arg0) {
// TODO Auto-generated method stub
StringBuilder builder = runCCChecker(path);
syncWithUi(builder);
return Status.OK_STATUS;
}
};
job.setUser(true);
job.schedule();
}
}
#Override
public void keyReleased(KeyEvent arg0) {
}
});
In order to show the warning at each line I am using IMarker interface.
In order to run my tool only on current active file of eclipse editor on which I am firing save command , I am using IPartService service.
following is the link of my code
https://github.com/sunilsarode/eclipse_plugin/blob/master/ccchecker/src/ccchecker/handlers/SampleHandler.java
It is working fine. If anybody find any issue please let me know.

Handle Logout Button Action of JavaFX Application

Here is part of my code that shows error. This is done inside public void start method. I have already done the Login part, whenever user logs in the id and password remains in the TextField. Which is why I have created a logout button so that when user clicks on it, I want the useridtextfield & passwordtextfield to be empty.
LogoutButton.setOnAction(e->
UserIdTextField==null;
PasswordTextField==null;);
I have searched over the internet about this problem but got no solution regarding JavaFX Logout handling. I have no idea about FXML so I would appreciate any help.
The syntax for a lambda expression with multiple statements is
logoutButton.setOnAction(e -> {
/* statements */
});
(I.e. you need to delimit the statements with { ... }.)
As pointed out in the comments, comparing the text fields to null is probably not what you want to do here, but it will at least compile.

editing components added by netbeans in java

I am building gui in netbeans... Or trying to is more like it. I keep getting an error in my code in the gray area that netbeans adds which evidently is a area that I can not edit.
it currently says this...
answerBox.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Answer Call" }));
answerBox.addPopupMenuListener(new javax.swing.event.PopupMenuListener() {
public void popupMenuWillBecomeVisible(javax.swing.event.PopupMenuEvent evt) {
}
public void popupMenuWillBecomeInvisible(javax.swing.event.PopupMenuEvent evt) {
answerBoxPopupMenuWillBecomeInvisible(evt);
}
public void popupMenuCanceled(javax.swing.event.PopupMenuEvent evt) {
}
});
the error is on this line
answerBoxPopupMenuWillBecomeInvisible(evt);
In order to fix it when it says I need to remove answerBox from the beginning of the line, and I don't recall even adding a popupmenu in the first place so I am trying to figure out how to
hot to edit this line of code to see if it fixes my problem?
how can I delete things like this from the designer mode if they are giving me problems?
It appears that the event method answerBoxPopupMenuWillBecomeInvisible may no longer exist.
You could go into the "Events" tab of the property sheet and remove the associated event.
Failing that, you could open the file in something like NotePad++ and simply remove the entire listener registration code block

How do I update the appearance of my JButton when it's clicked?

I'm working on a Java7 Swing "wizard" type of project that needs to validate a web address before continuing on to the next step of the wizard. The validation requires accessing a URL over the internet to verify that expected resources are available. In some cases, this can take a few seconds which can be long enough to confuse a user.
As a quick solution to this, I would like to disable the "next" button and change the display text while the validation is running so the user knows that the wizard is working and not hung up on anything. The problem is that when I add the code to modify the JButton, none of the changes happen until after the validation has completed. This is the case even if I change the button and call revalidate() before I execute the validation methods.
Here is an excerpt of what I've tried:
// create next button
next = new JButton("Next", new ImageIcon(getClass().getResource("/navigate_right.png")));
next.setActionCommand("MYACTION");
next.addActionListener(new ActionListener()
{
#Override
public void actionPerformed(ActionEvent e)
{
System.out.println("Is this the event dispatch thread? "
+ javax.swing.SwingUtilities.isEventDispatchThread());
System.out.println("Changing button");
next.setEnabled(false);
next.setText("Testing Connection");
next.getRootPane().revalidate();
System.out.println("Validating Service");
boolean isValidLocation = ServiceValidator.serviceExists(locationField.getText());
// ...etc...
When I run this code, the lines "Changing button" and "Validating Service" both get printed before the actual button changes in the display. How can I get the JButton to change before System.out.println("Validating Service"); is printed?
The problem is that when I add the code to modify the JButton, none of the changes happen until after the validation has completed.
Your code is executing on the EDT, so you long running code prevents the GUI from repainting itself until the task is finished executing. You need to use a separate Thread for the long running task, maybe a SwingWorker. Read the section from the Swing tutorial on Concurrency for more information.

CodeName One, Action event not working- need explanation

I'm trying to get and action event to fire on my HelloWorld. im using the GUI and when it auto creates the:
protected void onMain_Button1Action(Component c, ActionEvent event) {
// If the resource file changes the names of components this call will break notifying you that you should fix the code
super.onMain_Button1Action(c,event);
}
I know its not going to work because there is no void of the same type in the superclass.
protected void onMain_Button1Action(Component c, ActionEvent event) {
// If the resource file changes the names of components this call will break notifying you that you should fix the code
Dialog.show("Test", "it works", "OK",null);
}
And I'm still getting nothing. I've looked for other tutorials on how to use codenames as one but i cant find any. And I dont get the one made by the author. if any one can toss me a line i would be most appreciative.
You need to save the resource file in the designer and NOT delete the call to super. If you are using Eclipse you should refresh the project after saving in the designer using F5.

Categories

Resources