Register a SA Forums Account here!
JOINING THE SA FORUMS WILL REMOVE THIS BIG AD, THE ANNOYING UNDERLINED ADS, AND STUPID INTERSTITIAL ADS!!!

You can: log in, read the tech support FAQ, or request your lost password. This dumb message (and those ads) will appear on every screen until you register! Get rid of this crap by registering your own SA Forums Account and joining roughly 150,000 Goons, for the one-time price of $9.95! We charge money because it costs us money per month for bills, and since we don't believe in showing ads to our users, we try to make the money back through forum registrations.
 
  • Post
  • Reply
lamentable dustman
Apr 13, 2007

🏆🏆🏆

Mobius posted:

I'd like to use a simple web framework on a personal project that I may make open-source in the future. I know Struts from work, but that's really overkill for this. I'm thinking about WEB4J. Has anyone here used it? Or have other recommendations, instead? I'm looking for something that will both get the job done and give me a chance to learn something practical.

If you want something practical I would say SpringMVC if you don't know much about Spring. There is also Play if you want to learn Scala and the mentioned Grails if you want to learn Groovy.

Adbot
ADBOT LOVES YOU

baquerd
Jul 2, 2007

by FactsAreUseless

Harold Ramis Drugs posted:

Would that be using the "(Job)" cast in front of the call? If I do that, the program will compile but break when I try to run it with a Null Pointer Exception. Here's what I did:

code:
	
	waitJob = (Job)prime.work;
	waitJob.run(100);

Then you have a null object in your node or the node being returned is null, you'll need to test for those before calling any object methods. You should also check for the job instance or use generics (the latter is probably beyond the scope of your class)

code:
if (prime.data instanceof Job) {
  Job waitJob = (Job) prime.data;
  if (waitJob != null) {
    waitJob.run(100)
  }
}
//does not show test for prime itself being null
Edit: you have some confused loops going on. You do not need both a while loop and a for loop.

Harold Ramis Drugs
Dec 6, 2010

by Y Kant Ozma Post
Those loops are for code later on down the line. I'm just trying to get this one thing sorted out first.

I tried your code in debug, and it skipped your entire block which leads me to believe that it doesn't even recognize the data as being a Job. However, when I put this print statement below it:

code:

System.out.println(prime.data.getClass() + "\n" + prime + "\n" + prime.data);
I got this output:

code:
class LinkedList$Node
Job@76f9aa66
Job@76f9aa66
(toString() in the Node class just prints the data).

carry on then
Jul 10, 2010

by VideoGames

(and can't post for 10 years!)

According to that, the node's data is... a node. The next two lines indicate that there's a Job somewhere down the chain. What happens if you do prime.data.data.getClass()? Also, this indicates there may be a problem when these Jobs are being inserted.

carry on then fucked around with this message at 05:13 on Apr 23, 2012

baquerd
Jul 2, 2007

by FactsAreUseless

carry on then posted:

According to that, the node's data is... a node. The next two lines indicate that there's a Job somewhere down the chain. What happens if you do prime.data.data.getClass()? Also, this indicates there may be a problem when these Jobs are being inserted.

The other side of the problem here is that the .next object variable on every node is returning a Job. Is Job a subclass of Node? If not, your list implementation is all hosed up. Also, when you say it skips over the entire block, are you still assigning prime.next, or is it just skipping over the first Node?

Harold Ramis Drugs
Dec 6, 2010

by Y Kant Ozma Post
There may have been a problem with an abstract method. I extended a separate class from LinkedList called LinkedQueue, and when I extended the add method I might have hosed something up. Investigating...

Contra Duck
Nov 4, 2004

#1 DAD
If you want help post the whole thing to pastebin or something similar. People are generally willing to help but it's very hard for people to help you debug your linked list when you don't actually post the code from it.

fletcher
Jun 27, 2003

ken park is my favorite movie

Cybernetic Crumb
I want to use log4j for a console application I'm writing. In the class that has my main() method I'm adding a ConsoleAppender to my Logger instance. How do I get a Logger instance in a different class that has the same appender? Do I have to use an external log4j properties file?

edit: ah, I just use my package name when instantiating the logger and add the ConsoleAppender, then all other loggers use it.

http://logging.apache.org/log4j/1.2/manual.html

quote:

For example, the logger named "com.foo" is a parent of the logger named "com.foo.Bar". Similarly, "java" is a parent of "java.util" and an ancestor of "java.util.Vector". This naming scheme should be familiar to most developers.

fletcher fucked around with this message at 19:49 on Apr 23, 2012

Pie Colony
Dec 8, 2006
I AM SUCH A FUCKUP THAT I CAN'T EVEN POST IN AN E/N THREAD I STARTED
This isn't really a java question per se but it involves java. For a class project (the class is unrelated to concurrency) I'm implementing an algorithm that I want to be parallelized, but I'm not really an expert on the subject. I know the basics, but am interested in how to implement this in the most efficient way.

The algorithm is something like this (I've implemented a non-parallel version):

-------
There are 100 nodes divided into 4 groups.

At each iteration of the algorithm, the node calculates a direction and a distance to move. The direction can be calculated independently for each node, but the distance depends on the locations of all other nodes in the same group.

After each node has been evaluated, some number of nodes get thrown out of each group and replaced with nodes from the other groups.
-------

So I'm thinking of creating it in a master worker style, where 4 threads calculate the distance and direction, then the master does the switching of the nodes between each group. Would this be a good idea?

ComptimusPrime
Jan 23, 2006
Computer Transformer
You can do master slave to break down the 4 sections. But if you want to make it become truly scalable to as many cores as are present in the system then it will be a bit more complex of an algorithm.

One question would be this: Does each node only care about where the other nodes are at the beginning of each calculation? At the end? Or at some point in between? (e.g. if node 1 carries out the distance computation, does the result effect node 2?)

I would first write it out linearly and then look for sections of the code that can be broken out in to separate tasks.

Doctor w-rw-rw-
Jun 24, 2008

Pie Colony posted:

This isn't really a java question per se but it involves java. For a class project (the class is unrelated to concurrency) I'm implementing an algorithm that I want to be parallelized, but I'm not really an expert on the subject. I know the basics, but am interested in how to implement this in the most efficient way.

The algorithm is something like this (I've implemented a non-parallel version):

-------
There are 100 nodes divided into 4 groups.

At each iteration of the algorithm, the node calculates a direction and a distance to move. The direction can be calculated independently for each node, but the distance depends on the locations of all other nodes in the same group.

After each node has been evaluated, some number of nodes get thrown out of each group and replaced with nodes from the other groups.
-------

So I'm thinking of creating it in a master worker style, where 4 threads calculate the distance and direction, then the master does the switching of the nodes between each group. Would this be a good idea?
Writing the threads yourself might be too low-level, but this is a class project so it'll probably teach you something.

Consider using the Executor framework. Specifically:

http://docs.oracle.com/javase/6/docs/api/java/util/concurrent/Executors.html#newFixedThreadPool(int)
http://docs.oracle.com/javase/6/docs/api/java/util/concurrent/ThreadPoolExecutor.html

You could just have a thread pool managed by the framework, and have the runnables schedule their successors.

Or if you want to go full-blown overkill, use Quartz Scheduler with the in-memory task store.

Then mavenize it. :D

(I played around with Quartz recently and mixed Guice in for good measure too)

If you really want to get to know parallelization/concurrency better, read Java Concurrency in Practice. It's *the* reference.

Thom Yorke raps
Nov 2, 2004


Harold Ramis Drugs posted:

Would that be using the "(Job)" cast in front of the call? If I do that, the program will compile but break when I try to run it with a Null Pointer Exception. Here's what I did:

code:
					waitJob = (Job)prime.work;
					waitJob.run(100);

It would be waitJob = (Job)prime.data; right? Alternatively you can do ((Job)prime.data).run(100); if you don't want to store it in a variable.

Helg56
Feb 16, 2012

by Y Kant Ozma Post
Hey all, I have been stuck on something that I thought would be easy, but it is turning out to be very problemantic.

I have a text file that holds a user name, password, and account names. I am trying to remove a specific account name from the file... I already have the function finding the correct account name in the file, and creating a temp file for the new file, but i cant delete the old file and rename the temp file to what the old file was. (Thus just editing the file)

Here is my code, I have tried everything I feel and cant figure it out.

Any help is greatly Appreciated. :)

code:

public static void removeAccount(String username) throws IOException{
		
	String removeToAccount;
	String accountName;

	BufferedReader removebuf = new BufferedReader(new InputStreamReader(System.in));
	System.out.print("Account Name you wish to remove: ");
	accountName = removebuf.readLine();

	String filename = username + ".txt";
	String line;

	File in = new File(filename);
	File temp = new File("temp.txt");
	BufferedReader br = new BufferedReader(new FileReader(in));
	BufferedWriter pw = new BufferedWriter(new FileWriter(temp));
		
	while ((line = br.readLine()) != null) {
	if (line.equals(accountName)){
	     continue;
	        }
	        
	        pw.write(line);
	        pw.newLine();
	        pw.flush();
	      }
		
	br.close();
	pw.close();

	try{
	    in.delete();
            temp.renameTo(in);
	}catch(Exception e){
	    e.printStackTrace();
	    System.out.println("Could not Delete File");
	    }
}
One last thing, where does printStackTrace() print to? I want to see it, but dont figure out how to print it.

Thanks again! :)

Helg56
Feb 16, 2012

by Y Kant Ozma Post
Kind of a weird development, I can get it to delete the old file and rename the temp file on a mac(my partners computer), but with the exact same code I cant get it to work on my PC.

I am using windows 7 64bit, running java 1.7, and using eclipse.

Doctor w-rw-rw-
Jun 24, 2008

Helg56 posted:

stuff

I wonder if using FileUtils in Apache Common's io package might work better, if it's not overkill to pull the library in. It'll reduce your boilerplate there by a lot, I wager.

printStackTrace prints to standard error (stderr). I generally use a logging framework such as log4j or logback in order to log the errors, because then you can redirect the logging output to log files, or filter stuff out as you like. It's definitely a staple of Java development.

Helg56
Feb 16, 2012

by Y Kant Ozma Post

Doctor w-rw-rw- posted:

I wonder if using FileUtils in Apache Common's io package might work better, if it's not overkill to pull the library in. It'll reduce your boilerplate there by a lot, I wager.

I am omly allowed to use the java built in functions. :(
It is a school project.

ComptimusPrime
Jan 23, 2006
Computer Transformer
Are you buy chance trying to carry this out on the root drive of your Windows install (a.k.a C:\)?

If so, I suggest placing the file in your User directory and trying to run your program again.

I also suggest you trim the ends off of that input.

Edit:

Also, if you want, google "java FilePermission".

ComptimusPrime fucked around with this message at 02:37 on Apr 26, 2012

Kruegel
Jan 7, 2004
BSBSBSBS TEH END
file.delete() returns a success, which should help with your debugging.
code:
if(in.delete())
  temp.renameTo(in);
else
  System.out.println("WHY WONT THIS loving DELETE");
Also, check this out:
http://stackoverflow.com/questions/991489/i-cant-delete-a-file-in-java

You can also try file.setWritable(true); and see if it has any effect.

Kruegel fucked around with this message at 04:15 on Apr 26, 2012

I. M. Gei
Jun 26, 2005

CHIEFS

BITCH



Okay this is just driving me nuts.

I'm trying to use a JOptionPane window to do something based on which button the user clicks, but it isn't doing jack poo poo and I can't figure out why.

Here's the copy/paste of the code I'm dealing with:
code:
public static int welcome( )
{   JOptionPane b = new JOptionPane( );
    Object message = "Would you like to create a new Input File?";
    Object[] possibleOptions = { "Create New Input File", "Open Existing Input File", "Cancel" };
    String title = "Input Console";

    b.showOptionDialog( null, message, title, JOptionPane.YES_NO_CANCEL_OPTION, JOptionPane.QUESTION_MESSAGE, null, possibleOptions, JOptionPane.CANCEL_OPTION );
    Object selectedValue = b.getValue( );
    if( selectedValue == null ) {
        return JOptionPane.CLOSED_OPTION; }
    else {
        if( possibleOptions[0].equals( selectedValue ) ) {
            return JOptionPane.YES_OPTION; }
        else if( possibleOptions[1].equals( selectedValue ) ) {
            return JOptionPane.NO_OPTION; }
        else if( possibleOptions[2].equals( selectedValue ) ) {
            return JOptionPane.CANCEL_OPTION; }
        return JOptionPane.CLOSED_OPTION; } }
For some reason "b.getValue( )" keeps returning "uninitializedValue" and I can't figure out why. It's supposed to return a value based on the user's option selection, but it's not doing that at all.

What am I doing wrong here?


EDIT: Okay, I just surrounded the b.showOptionDialog( :words: ) line with JOptionPane.setValue( ) as a quick fix, and that seems to have solved the problem. Although I'm still curious as to whether there's a better way of going about this than that.

I. M. Gei fucked around with this message at 02:54 on Apr 27, 2012

I. M. Gei
Jun 26, 2005

CHIEFS

BITCH



New question time!


Does anybody know how to make a JOptionPane window with drop-down menus? Or, more specifically, does anybody know how to make a JOptionPane window with MULTIPLE drop-down menus... preferably all lined up into rows and columns? And by "MULTIPLE" I mean 70.

Yes, I am trying to put exactly 70 drop-down menus in a single JOptionPane window.

Any help would be greatly appreciated.

I. M. Gei fucked around with this message at 04:14 on Apr 27, 2012

baquerd
Jul 2, 2007

by FactsAreUseless

Dr. Gitmo Moneyson posted:

Does anybody know how to make a JOptionPane window with drop-down menus? Or, more specifically, does anybody know how to make a JOptionPane window with MULTIPLE drop-down menus... preferably all lined up into rows and columns? And by "MULTIPLE" I mean 70.

Yes, I am trying to put exactly 70 drop-down menus in a single JOptionPane window.

Any help would be greatly appreciated.

Other than making UI designers cry, why?

As for your questions, first you need to look at the docs because you're not quite doing it right and you're calling a static method on your object instead of calling an instance method.

code:
To create and use an JOptionPane directly, the standard pattern is roughly as follows:
     JOptionPane pane = new JOptionPane(arguments);
     pane.set.Xxxx(...); // Configure
     JDialog dialog = pane.createDialog(parentComponent, title);
     //...
As for the 70 drop downs, you're going to want to make a JPanel and arrange the dropdowns using a LayoutManager like GridLayout or GridBagLayout. Have some example code:
code:
import java.awt.GridLayout;

import javax.swing.Box;
import javax.swing.JComboBox;
import javax.swing.JOptionPane;
import javax.swing.JPanel;

public class MoarDropdowns {
  public static void main(String[] args) {
    JPanel pane = new JPanel();
    pane.setLayout(new GridLayout(0, 10));
    
    for (int i = 0; i < 70; i++) {
      Integer[] values = new Integer[5];
      for (int j = 0; j < 5; j++) {
        values[j] = (int)(Math.random() * 10000);
      }
      pane.add(new JComboBox(values));
      pane.add(Box.createGlue());
    }
    
    JOptionPane.showOptionDialog(null, pane, "Madness and Death",
      JOptionPane.DEFAULT_OPTION, JOptionPane.WARNING_MESSAGE,
      null, null, null);
  }
}

I. M. Gei
Jun 26, 2005

CHIEFS

BITCH



baquerd posted:

As for your questions, first you need to look at the docs because you're not quite doing it right and you're calling a static method on your object instead of calling an instance method.

code:
To create and use an JOptionPane directly, the standard pattern is roughly as follows:
     JOptionPane pane = new JOptionPane(arguments);
     pane.set.Xxxx(...); // Configure
     JDialog dialog = pane.createDialog(parentComponent, title);
     //...
Can you clarify what you mean here? I'm pretty new to Swing and I'm not sure what you mean by "calling an instance method" as opposed to calling a static one.

baquerd posted:

As for the 70 drop downs, you're going to want to make a JPanel and arrange the dropdowns using a LayoutManager like GridLayout or GridBagLayout. Have some example code:
code:
import java.awt.GridLayout;

import javax.swing.Box;
import javax.swing.JComboBox;
import javax.swing.JOptionPane;
import javax.swing.JPanel;

public class MoarDropdowns {
  public static void main(String[] args) {
    JPanel pane = new JPanel();
    pane.setLayout(new GridLayout(0, 10));
    
    for (int i = 0; i < 70; i++) {
      Integer[] values = new Integer[5];
      for (int j = 0; j < 5; j++) {
        values[j] = (int)(Math.random() * 10000);
      }
      pane.add(new JComboBox(values));
      pane.add(Box.createGlue());
    }
    
    JOptionPane.showOptionDialog(null, pane, "Madness and Death",
      JOptionPane.DEFAULT_OPTION, JOptionPane.WARNING_MESSAGE,
      null, null, null);
  }
}
This helps a lot, although I'm going to need to break it up so that the rows and columns are labeled on the left and top.

If you want, I can put together a rough MSPaint of what I want to make that might give you a better idea of what I'm trying to do.

baquerd
Jul 2, 2007

by FactsAreUseless

Dr. Gitmo Moneyson posted:

Can you clarify what you mean here? I'm pretty new to Swing and I'm not sure what you mean by "calling an instance method" as opposed to calling a static one.

This helps a lot, although I'm going to need to break it up so that the rows and columns are labeled on the left and top.

If you want, I can put together a rough MSPaint of what I want to make that might give you a better idea of what I'm trying to do.

Instance methods are methods that are called on a particular object instance (this terminology applies to any object, not just Swing objects). Static methods are methods that belong to a class and do not require an object instance. You are creating a JOptionPane, then ignoring the instance you just created and are calling the JOptionPane's class's static method via the object instance (which isn't great practice as it leads to confusion like this).

I'd be happy to code such a UI for you, and I'd estimate this would cost around $100 to create a class that will allow you to conveniently set up and retrieve data from the option pane in whatever manner you desire. If you prefer, you might start here if you'd like to make your own UI:

http://docs.oracle.com/javase/tutorial/uiswing/layout/index.html
http://docs.oracle.com/javase/tutorial/uiswing/components/combobox.html

I. M. Gei
Jun 26, 2005

CHIEFS

BITCH



baquerd posted:

Instance methods are methods that are called on a particular object instance (this terminology applies to any object, not just Swing objects). Static methods are methods that belong to a class and do not require an object instance. You are creating a JOptionPane, then ignoring the instance you just created and are calling the JOptionPane's class's static method via the object instance (which isn't great practice as it leads to confusion like this).

Assuming you mean what I think you do here, I'm using Eclipse, and anytime I call my b object instead of doing things straight from the JOptionPane class, Eclipse gives me warning messages saying the static field JOptionPane.whatever should be accessed in a static way.

Is this just Eclipse being stupid or something?

baquerd
Jul 2, 2007

by FactsAreUseless

Dr. Gitmo Moneyson posted:

Assuming you mean what I think you do here, I'm using Eclipse, and anytime I call my b object instead of doing things straight from the JOptionPane class, Eclipse gives me warning messages saying the static field JOptionPane.whatever should be accessed in a static way.

Is this just Eclipse being stupid or something?

Eclipse is trying to tell you what I told you, that accessing a static method via an object instance is bad practice.

code:
//instance method
b.createDialog(title).show();

//instance method, compiler error
JOptionPane.createDialog(title).show();

//static method
JOptionPane.showOptionDialog(/* ... */);

//static method, bad practice
b.showOptionDialog(/* ... */);
Edit: added .show() for completeness

baquerd fucked around with this message at 06:14 on Apr 27, 2012

I. M. Gei
Jun 26, 2005

CHIEFS

BITCH



baquerd posted:

Eclipse is trying to tell you what I told you, that accessing a static method via an object instance is bad practice.

code:
//instance method
b.createDialog(title).show();

//instance method, compiler error
JOptionPane.createDialog(title).show();

//static method
JOptionPane.showOptionDialog(/* ... */);

//static method, bad practice
b.showOptionDialog(/* ... */);
Edit: added .show() for completeness

:raise: Soooooo would this code below count as bad practice or good practice?
code:
public static int welcome( )
{   JOptionPane b = new JOptionPane( );
    Object message = "Would you like to create a new Input File?";
    Object[] possibleOptions = { "Create New Input File", "Open Existing Input File", "Cancel" };
    String title = "Input Console";
    b.setValue( b.showOptionDialog( null, message, title, b.YES_NO_CANCEL_OPTION, b.QUESTION_MESSAGE, null, possibleOptions, b.CANCEL_OPTION ) );
    Object selectedValue = b.getValue( );
    if( selectedValue == null ) {
        return b.CLOSED_OPTION; }
    else {
        if( (new Integer(0)).equals( selectedValue ) ) {
            return b.YES_OPTION; }
        else if( (new Integer(1)).equals( selectedValue ) ) {
            return b.NO_OPTION; }
        else if( (new Integer(2)).equals( selectedValue ) ) {
            return b.CANCEL_OPTION; }
        else {
            return b.CLOSED_OPTION; } } }
Because Eclipse is telling me it's bad practice. Where do the "JOptionPane"s go? Everywhere the "b"s are now?

Janitor Prime
Jan 22, 2004

PC LOAD LETTER

What da fuck does that mean

Fun Shoe

Dr. Gitmo Moneyson posted:

Where do the "JOptionPane"s go? Everywhere the "b"s are now?

Yes, that's the standard way of referring to class constants.

I. M. Gei
Jun 26, 2005

CHIEFS

BITCH



MEAT TREAT posted:

Yes, that's the standard way of referring to class constants.

Cool, I think I've got it all corrected now.


Now I gotta do that thing with the drop-down menus... :smithicide:

Max Facetime
Apr 18, 2009

Dr. Gitmo Moneyson posted:

Cool, I think I've got it all corrected now.


Now I gotta do that thing with the drop-down menus... :smithicide:

You can have Eclipse change all of those automatically every time you save the file.

Look in Window->Preferences->Java->Editor->Save Actions and add "Change non static accesses to static members using declaring type" to the list of Additional Actions.

I. M. Gei
Jun 26, 2005

CHIEFS

BITCH



Okay I think I got the drop-down menus set up. Is there a way to add a simple horizontal divider/boundary/line-thingy to a JOptionPane or JPanel window? So I can separate some of my drop-down menu rows and make the window a little easier to look at?

Tamba
Apr 5, 2010

Use a JSeparator

baquerd
Jul 2, 2007

by FactsAreUseless

Dr. Gitmo Moneyson posted:

:raise: Soooooo would this code below count as bad practice or good practice?
code:
public static int welcome( )
{   JOptionPane b = new JOptionPane( );
    Object message = "Would you like to create a new Input File?";
    Object[] possibleOptions = { "Create New Input File", "Open Existing Input File", "Cancel" };
    String title = "Input Console";
    b.setValue( b.showOptionDialog( null, message, title, b.YES_NO_CANCEL_OPTION, b.QUESTION_MESSAGE, null, possibleOptions, b.CANCEL_OPTION ) );
    Object selectedValue = b.getValue( );
Because Eclipse is telling me it's bad practice. Where do the "JOptionPane"s go? Everywhere the "b"s are now?

You're still missing the idea that you're actually creating two JOptionPanes. You have no need for a object instance at all:

code:
Object selectedValue = JOptionPane.showOptionDialog( null, message, title, b.YES_NO_CANCEL_OPTION, b.QUESTION_MESSAGE, null, possibleOptions, b.CANCEL_OPTION );

Hidden Under a Hat
May 21, 2003
My software is all of the sudden uncompilable to NetBeans. Here is the error I get upon trying to run it:

code:
Exception in thread "AWT-EventQueue-0" java.lang.RuntimeException: Uncompilable source code - missing method body, or declare abstract
        at com.labrx.icon.BioreactorCode.<init>(BioreactorCode.java:75)
Now if I remove all reference to this class, it will just say the same thing about another class, and so on with every class in my program. Keep in mind this code worked just fine an hour ago. From the time it worked until now when I get this error, I had created and worked on a new class that extends JPanel and has lots of GroupLayout that I coded myself without using the GUI builder. Since I thought the new class was probably the issue, I deleted it but I still get the same error. If I clean and build it, the program runs fine though. Anyone encounter this before?

Janitor Prime
Jan 22, 2004

PC LOAD LETTER

What da fuck does that mean

Fun Shoe

Hidden Under a Hat posted:

My software is all of the sudden uncompilable to NetBeans. Here is the error I get upon trying to run it:

code:
Exception in thread "AWT-EventQueue-0" java.lang.RuntimeException: Uncompilable source code - missing method body, or declare abstract
        at com.labrx.icon.BioreactorCode.<init>(BioreactorCode.java:75)
Now if I remove all reference to this class, it will just say the same thing about another class, and so on with every class in my program. Keep in mind this code worked just fine an hour ago. From the time it worked until now when I get this error, I had created and worked on a new class that extends JPanel and has lots of GroupLayout that I coded myself without using the GUI builder. Since I thought the new class was probably the issue, I deleted it but I still get the same error. If I clean and build it, the program runs fine though. Anyone encounter this before?

If a clean a build fixes it, then that means your code is fine and NetBeans is at fault. Try closing NetBeans, and deleting the var/cache/index/ folder of NetBeans. It's normally stored in your home directory under .netbeans/version/

I. M. Gei
Jun 26, 2005

CHIEFS

BITCH



baquerd posted:

You're still missing the idea that you're actually creating two JOptionPanes. You have no need for a object instance at all:

code:
Object selectedValue = JOptionPane.showOptionDialog( null, message, title, b.YES_NO_CANCEL_OPTION, b.QUESTION_MESSAGE, null, possibleOptions, b.CANCEL_OPTION );

I assume the "b"s inside those parentheses should be "JOptionPane"s, then? Because Eclipse gives me warning messages anytime I type "b.something" instead of "JOptionPane.something" in the parentheses.

So basically you're telling me that the b object was worthless all along. Good to know...



Okay, onto my next question: How do I get a user's selected value from a JComboBox drop-down menu? My goal is to write a series of these values into a .txt file.

EDIT: Actually nevermind my next question, I think I figured it out already. I just.... have to rewrite a bunch of the new code I typed last night. :negative:

I. M. Gei fucked around with this message at 08:53 on Apr 28, 2012

Hidden Under a Hat
May 21, 2003

MEAT TREAT posted:

If a clean a build fixes it, then that means your code is fine and NetBeans is at fault. Try closing NetBeans, and deleting the var/cache/index/ folder of NetBeans. It's normally stored in your home directory under .netbeans/version/

I can't find this folder anywhere. I'm using Mac OS X 10.6.

Janitor Prime
Jan 22, 2004

PC LOAD LETTER

What da fuck does that mean

Fun Shoe

Hidden Under a Hat posted:

I can't find this folder anywhere. I'm using Mac OS X 10.6.

On Linux systems, directories starting with a dot are hidden, maybe OS X is the same?

etcetera08
Sep 11, 2008

MEAT TREAT posted:

On Linux systems, directories starting with a dot are hidden, maybe OS X is the same?

Yes, it is. Show hidden folders.

carry on then
Jul 10, 2010

by VideoGames

(and can't post for 10 years!)

Hidden Under a Hat posted:

I can't find this folder anywhere. I'm using Mac OS X 10.6.

In Finder just hit CMD+Shift+G and type in ~/.netbeans, should take you right to it.

Adbot
ADBOT LOVES YOU

Hanpan
Dec 5, 2004

Does Java have any kind of event handling / dispatching ala Actionscript 3? I know it doesn't have delegates so the C# system I was hoping to port over won't work. The only thing I can find on Google is the ActionListener interface, but that seems to be specifically for Swing?

For reference, what I am trying to do is listen for events on a particular object. If I was coding a game, for example, I might want to listen for events for when the player jumps, takes damage or dies so the rest of my game can react accordingly.

  • 1
  • 2
  • 3
  • 4
  • 5
  • Post
  • Reply