Start a Discussion

yconic is the place where you can give and get the help you need for your life as a student. To help keep our community an enjoyable, helpful and safe place for all members, please adhere to the following guidelines.

1. Be nice to people. It's okay to provide constructive criticism, but there is no need to insult other members. For example, "X major is over-saturated right now. You might have trouble finding a job" is fine. "Your major is dumb. Have fun working in fast food," is not helpful nor appropriate.

2. Ask actual questions. If you're looking for help with something, titling a thread "HELP, I DON'T KNOW WHAT TO DO" isn't going to appeal to the members that may be best suited to help you. Be specific and title your post with relevant information.

3. Don't abuse the anonymous feature by pretending to be multiple people. Surprise, surprise, we know who posts what :)

4. Please only tag relevant interests when you create a new thread. Adding unrelated interests is unlikely to get you the help you're looking for and can frustrate other members.

5. Avoid spamming. This includes replying to your own thread for the sole purpose of moving it up the discussion feed.

yconic is the place where you can give and get the help you need for your life as a student. To help keep our community an enjoyable, helpful and safe place for all members, please adhere to the following guidelines.

1. Be nice to people. It's okay to provide constructive criticism, but there is no need to insult other members. For example, "X major is over-saturated right now. You might have trouble finding a job" is fine. "Your major is dumb. Have fun working in fast food," is not helpful nor appropriate.

2. Ask actual questions. If you're looking for help with something, titling a thread "HELP, I DON'T KNOW WHAT TO DO" isn't going to appeal to the members that may be best suited to help you. Be specific and title your post with relevant information.

3. Don't abuse the anonymous feature by pretending to be multiple people. Surprise, surprise, we know who posts what :)

4. Please only tag relevant interests when you create a new thread. Adding unrelated interests is unlikely to get you the help you're looking for and can frustrate other members.

5. Avoid spamming. This includes replying to your own thread for the sole purpose of moving it up the discussion feed.

yconic is the place where you can give and get the help you need for your life as a student. To help keep our community an enjoyable, helpful and safe place for all members, please adhere to the following guidelines.

1. Be nice to people. It's okay to provide constructive criticism, but there is no need to insult other members. For example, "X major is over-saturated right now. You might have trouble finding a job" is fine. "Your major is dumb. Have fun working in fast food," is not helpful nor appropriate.

2. Ask actual questions. If you're looking for help with something, titling a thread "HELP, I DON'T KNOW WHAT TO DO" isn't going to appeal to the members that may be best suited to help you. Be specific and title your post with relevant information.

3. Don't abuse the anonymous feature by pretending to be multiple people. Surprise, surprise, we know who posts what :)

4. Please only tag relevant interests when you create a new thread. Adding unrelated interests is unlikely to get you the help you're looking for and can frustrate other members.

5. Avoid spamming. This includes replying to your own thread for the sole purpose of moving it up the discussion feed.

yconic is the place where you can give and get the help you need for your life as a student. To help keep our community an enjoyable, helpful and safe place for all members, please adhere to the following guidelines.

1. Be nice to people. It's okay to provide constructive criticism, but there is no need to insult other members. For example, "X major is over-saturated right now. You might have trouble finding a job" is fine. "Your major is dumb. Have fun working in fast food," is not helpful nor appropriate.

2. Ask actual questions. If you're looking for help with something, titling a thread "HELP, I DON'T KNOW WHAT TO DO" isn't going to appeal to the members that may be best suited to help you. Be specific and title your post with relevant information.

3. Don't abuse the anonymous feature by pretending to be multiple people. Surprise, surprise, we know who posts what :)

4. Please only tag relevant interests when you create a new thread. Adding unrelated interests is unlikely to get you the help you're looking for and can frustrate other members.

5. Avoid spamming. This includes replying to your own thread for the sole purpose of moving it up the discussion feed.

CompSci Question...

I have a programming-related question that I thought the engineering, mathematics and computer science hopefuls here would be able to help me with.

I am currently working on a project in the Java language for ICS4U at school. It is a GUI development-focused project. I am using the NetBeans IDE and the Java Swing API for GUI design.

I have a list of items, and beside them are buttons that are used to work with the list (e.g. add item, remove item). I need some buttons to be disabled when there are no items in the list, or when an item is not selected. Having these buttons enabled in those situations allows for a runtime error to occur if they are pressed.

How do I make my program listen for when the list is empty, or when nothing is selected? What event listeners should I use?

Can't you just compare your labels beside the buttons to everything on your list? Then set enable to true/false from there? Could probably easily make a for loop considering that your list is in an array... I don't think I'm understanding the program properly. What's the runtime error anyway?

I'm using DefaultListModel to display the list contents and JList to allow for selection. Sorry for not mentioning that. The runtime error is that a NullPointerException (because there is no item selected) is thrown and the program crashes. I could catch the thrown exception, but this could only occur after the exception is thrown (button is pressed). It makes more sense and looks better if the buttons are disabled in those two situations.

The only non-property related code that can be invoked when the GUI frame launches must be an event handling method (e.g. actionPerformed). This must be accompanied by an event listener to "listen" for when the event for which the event handling method is written occurs. That's why I was wondering what listener I could use for when the list is empty, or when nothing is selected.

Just fyi, this is *not* a computer science question. It's barely even a programming question--gui development is very cut-and-paste.

I don't mean to sound like an ass; if this was actually a computer science question I could help you with it. But the problem is that most high schoolers seem to be under the impression that programming, especially mudane stuff like this, is computer science. It's not. By the way, if this is stuff you're interested in for a career, save yourself the money and stress of university and go to a tech school.

Stating the fact that this is not a computer science question I wouldn't call bashing. The reason I preemptively apologized for potentially "sounding like an ass" was because I was worried the guy might take offense to calling the development of graphical user interfaces "cut-and-paste." I didn't intend to insult his ability--I was trying to say that he's doing it wrong, to some extent. The best gui code you'll write will be something taken pretty much verbatim from a polished interface, so usually the best idea for these things would be to search the internet for some examples.

Also, I am sick of all the people going into comp sci that want a programming degree because universities sucked at telling them what the programs actually involved. These people would be far more suited for a software engineering degree or an IT program. I'm trying to do my part in shattering the misconception so people don't make the wrong decisions.

To be honest, that handful of concepts I mentioned are easily understandable by a high schooler with a little bit of calculus, if they are willing to think about them a bit. A starting point, as I said. Or should I be referring this guy to the X11 and OpenGL manuals for graphical development when he's having trouble with a button? Send him towards the study of advanced algorithms, operating systems, and compilers in his time of need? You too ought to consider having some reasonable expectations. :P

I've met people long graduated in the workplace in development that had not a clue what a binary search was, and wouldn't be able to perform any modular arithmetic outside of mod-2 (odd/even). The amount of actual CS background people working in development have varies wildly.

Oh, I should mention, Eclipse is the golden standard for the Java IDE. You may want to take a look into that.

@greygoose wroteJust fyi, this is *not* a computer science question. It's barely even a programming question--gui development is very cut-and-paste.

I don't mean to sound like an ass; if this was actually a computer science question I could help you with it. But the problem is that most high schoolers seem to be under the impression that programming, especially mudane stuff like this, is computer science. It's not. By the way, if this is stuff you're interested in for a career, save yourself the money and stress of university and go to a tech school.