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
ShinAli
May 2, 2003

The Kid better watch his step.
Not anything Java specific but Eclipse is a Java thing sort of so whatever.

Eclipse at this point is the only IDE I'll ever use in a long time, yet this bug pops up once in a while and I waste about an hour loving with it.

It pops up randomly, but sometimes it doesn't recognize a class in the entire code or just a single line. I clean and build and everything but it doesn't go away. The code will still compile because javac isn't as retarded as Eclipse but I depend on IntelliSense quite a bit when I don't have a javadoc on hand.

If it still compiles I suppose it isn't a big problem, but it happened one too many times and I just want to get rid of it.

EDIT: I'll throw in a real problem too, I guess.

I'm using a Combobox on a GUI I've created, and whenever I fill the combobox up, the little down arrow button on the right of it disappears. I do a repaint on the componenet but nothing. Then again, I really don't understand repaint that well as everytime I tried to use it, it never really works for me.

ShinAli fucked around with this message at 18:01 on Apr 15, 2008

Adbot
ADBOT LOVES YOU

ShinAli
May 2, 2003

The Kid better watch his step.

Twitchy posted:

Have you tried calling revalidate on the panel it's in?

I'll try it right now.

ShinAli fucked around with this message at 21:14 on Apr 15, 2008

ShinAli
May 2, 2003

The Kid better watch his step.

ShinAli posted:

I'll try it right now.

That didn't work :( This is how I fill up the combobox

code:
cbxServiceList.setModel(new javax.swing.DefaultComboBoxModel(serviceNames));
serviceNames being an array of Strings. I have it do the revalidate right after it gets filled.

ShinAli
May 2, 2003

The Kid better watch his step.

Werthog posted:

Popping in not for Java coding help, but NetBeans: Anybody know how to set the contents of a JComboBox from an array or list? There's a box to type your "pre-generation code," but I really don't know what to put there, and it's surprisingly hard to find clear instructions online.

ShinAli posted:

code:
cbxServiceList.setModel(new javax.swing.DefaultComboBoxModel(serviceNames));
serviceNames being an array of Strings.

Like every other Java Swing component, you'd have to jump through hoops and set up a model for ComboBox. Luckily, there is a default model that'll just take in an array of Strings in the constructor. Declaring or using an DefaultComboBoxModel object in the custom code text box should make it work.

ShinAli
May 2, 2003

The Kid better watch his step.
Not really a question but I thought it'd be a useful little tid bit to post.

In all of my time of using Java, I've always assumed passing Objects in method parameters will pass by reference and primitives pass by value. This is actually not the case at all.

Everything is passed by value. This doesn't mean what you think about Objects though, as the references to the Objects themselves are the ones that are passed by value. Here is an example:

code:
// Point is an object containing two integers called X and Y
Point pnt = new Point(2,5);
System.out.println(pnt.toString());
// over ridden toString method returns 'X = 2, Y = 5'
changePoint(pnt);
System.out.println(pnt.toString());
// prints 'X = 6, Y = 3'

void changePoint(Point temp) {
  temp.setX(6);
  temp.setY(3);
  temp = null;
}
In the changePoint method the passed value of temp's reference is changed to null, not temp's actual reference. The passed reference value can still modify the same Object via methods and the sort.

Sorry if most of you all already knew this, but I think it's something useful to know for a the newbie passer-by Java programmers. It blew my mind to the point I'll always remember this and will never make a mistake like that.

ShinAli
May 2, 2003

The Kid better watch his step.
Yeah I think I need to re-write it :psyduck:

Does "pass by reference" usually mean passing by value the copy of the reference? Or does real "passing by reference" mean that you can modify the original reference? If it's the former, then Objects passing by reference is actually correct and I'm just retarded :saddowns:

ShinAli
May 2, 2003

The Kid better watch his step.
That or they should explain what passing by reference actually does :(

I guess I should feel fortunate that a lot of Java schools probably don't even touch on that. Oh well, I'm going into SEGFAULT territory this coming fall :v:

ShinAli
May 2, 2003

The Kid better watch his step.

ynef posted:

Row 16 in the file that the JVM complains about says: "Graphics2D g = (Graphics2D) drawSpace.getGraphics();" -- at that point, however, drawSpace is not initialized to anything and is therefore null.

This. A tip to spot these kind of problems right away is using a debugger in Eclipse or NetBeans. They both will display all visible variables and indicate their value, which makes "NullPointerException" easier to deal with on multi statement line of code.

Adbot
ADBOT LOVES YOU

ShinAli
May 2, 2003

The Kid better watch his step.
Quick question about servers and all that. I've made a quick little lightweight Java NIO server for Comet based connections, as I've quickly found out that the "workaround" Comet implementations is pretty unreliable for a high load event distribution. What I'll be doing is packaging the server inside a WAR file and have it deployable inside a real HTTP server like Tomcat/Glassfish/WebLogic/etc. I know those some of those servers already have an NIO if configured properly (Glassfish has grizzly, Tomcat has NIO HTTP protocol), but I want the WAR file to be able to be deployed on any Java server.

I'm not that knowledgeable in server administration, but last time I tried to make a web service endpoint (using Java's lightweight HTTP server) inside of BEA WebLogic, it bitched a whole lot and I ended up not trying to deploy under WebLogic (worked in Glassfish just fine, though). I got around that by not being retarded and made it use the server it's being deployed on as the endpoint, but I need the lightweight NIO server running within the server I'm deploying to. I'm sure Glassfish would have no problem with this, but I'm also sure other servers are a lot more strict (like WebLogic!). Would this be a configuration issue? Should I get around this by running another VM?

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