I am working on an eclipse RCP project. As I was going through the walkthroughs I came across preference page and started working around it.
Now I need to change the values of the ComboFieldEditor dynamically. As in when I make a selection on a TextFieldEditor the values of the ComboFieldEditor must change. I tried searching for an answer and even tried one of the solutions I found on Stack Overflow, but I always ended up with NullPointerException. Can someone help me in this regard?
Technically I want to change the values in the ComboFieldEditor dynamically. As in, when a listener is triggered I want to put new values in my combobox. I tried this solution but I kept getting a NullPointerException.
Ok. This is something that I did for the time being.
I created a class named CustomComboFieldEditor and added all the methods present in the ComboFieldEditor. I changed the methods that helped to input the values in the combo box. Works fine for me as of now.
I am sure its not the prettiest of all ways and I bet I would be crucified for this solution, but time and situation forced me into using it. Anyother way would be appreciated.
Thanks :)
Related
I'm designing a program where you are registering for an organization. To reach the registration page however, you first need to login using another member's access key.
I have put in a switch statement assigning different passwords to different user names. I have then used an if statement to check if the password is correct according to the member entered and if not, to display a message indicating such. This works perfectly fine, however, if you input a member's name that isn't of the three I've hardcoded for, the code allows you to completely bypass the password field, basically making the security measures useless.
If anyone has any suggestions on how to fix this, I would really appreciate it. I'm assuming it's something simple but I am extremely new to coding, particularly the GUI and just can't figure it out.
I'm using NetBeans GUI builder.
Thank you!
Image of my code
I managed to change it slightly where that error no longer occurs. It is not completely perfect according to my intentions however this works for my needed functions.
If you have any further suggestions on how to improve this even more, I would still really appreciate it.
Thank you for all the assistance!
Adjusted code
(I also changed the messages to buttons for aesthetic purposes)
I'm doing android app from a book, for some reason the exact method source code I wrote myself does not work as expected and I am trying to debug it.
I have two exact chunks of code, my method and the sample method.
How to compare them in eclipse?
Select both files by clicking the first, then while holding CTRL click on the second.
Now both of them got selected.
Now click one of them (doesn't matter which one) with the right mouse button.
From the appearing context menu choose:
Compare
Each other
Now you can do a text compare.
Did I get right that neither of the sample method nor your method do what they should?
Then there are two possibilities why the code won't do what it should:
The book is obsolet
You made something wrong
either way, google for your specific problem, maybe someone else has encountered it as well and already solved it.
for your Question: already answered in another comment
use beyond compare, it's a great tool for comparing classes, and methods! download beyond compare
Do you know if IDEA has a shortcut which will bring me to the last method I was looking into, not necessary changing it, just looking into. I know that there is Ctrl+Alt+Left/Right but it is slightly different.
If you are on a Mac, press Command+Shift+A.
If you are on a Windows, press Ctrl+Shift+A.
This will bring up a searchable list of ALL of the possible shortcuts. Just type what you want to do and it'll come up there. Very handy. I use it all the time.
Hope that helps. Good luck :)
EDIT:
Just took a look myself. Doesn't look like there is anything like what you wanted. The closest thing is moving to the the next method or the previous method, but this is just in order of how you have them written in the code, not in the order that you look at them. Sorry!
I am currently working on an android project where I need to create a SettingsActivity where I will have a variable number of checkboxes depending on an int from an SQLite database. I figured that the best way to do this was to create a for loop inside the SettingsActivity .java code, which would create a new checkbox preference for each time it runs the loop(as of now I only have a theoretical idea of how it would work). My problem would be to create the checkbox preference in .java rather than the XML. I searched the internet and could only find one example that had about 300 lines of code in it, and I can't believe that it needs to be as complicated as it was in that example. Does anyone have a helpful link, an idea how to do this or even knows a better way to make a variable number of checkboxes?
Sorry that I don't have any relevant code to post, but here is the link to the example I found http://grepcode.com/file/repository.grepcode.com/java/ext/com.google.android/android/1.5_r4/android/preference/CheckBoxPreference.java
http://developer.android.com/reference/android/preference/CheckBoxPreference.html
It also inherits a lot of methods from Preference: http://developer.android.com/reference/android/preference/Preference.html.
You can pass the constructor an attribute set where you specify summaryOn and summaryOff and the title
The link you posted is the source code of android. You don't need to implement that in your application as it's already in the android environment
I would like to know if when debugging in Eclipse, is there a feature/way to focus on a variable and "back-track" where the variable got its value..? I hope I'm being clear enough, but I can see if this appears as a weird question.
The thing is, I have two similar classes, both using a #Resource instance of the same class. One of the classes runs fine but the other one gets a NullPointerException for the instance variable in question. And I can't see how this is. So if you know a way to "back-track" in the Eclipse debugger to see "how old" and where a value in a variable is set I would greatly appreciate it!
And if there's no such feature for some obvious reason and this question in stupid I apologize in advance...
You'd have to set a field breakpoint on the field in question before the value is set and catch it when it happens. "Standard" debuggers don't have the back-in-time feature. Omniscient debuggers do, though. These record every single action taken by a VM so that you can ask these kinds of questions at any point during execution. They're not widely used and have understandably high performance penalties. There are at least a couple of open source ones out there: TOD and ODB.
Unfortunately this is not possible in the standard Eclipse debugger. There is a commercial product called "Chronon Time-Travelling Debugger", which I have not tried but sounds as if it might do what you want, and is available for a 30-day free trial.