wood burning stoves*
The moose likes IDEs, Version Control and other tools and the fly likes JTextField - IllegalArgumentException - Too complicated Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Engineering » IDEs, Version Control and other tools
Bookmark "JTextField - IllegalArgumentException - Too complicated" Watch "JTextField - IllegalArgumentException - Too complicated" New topic
Author

JTextField - IllegalArgumentException - Too complicated

Mor Merhav
Greenhorn

Joined: May 17, 2011
Posts: 6
hi everyone! I'm new to the forum..nice 2 meet you

Maybe you can help me:

I'm building a Client-Server based system for a project in my degree,

and what I'm currently trying to do is:

After login is performed, in the main menu, I want a certain JLabel to show "Welcome <username>! Permission: <Permission>"

I've tried to do this by: userMsg.setText("Welcome "+ms.lg.getCurrentUsername()+"!"+"Permission:"+ms.lg.getCurrentPermission());

And I receive an IllegalArgumentException, saying the Strings that are taked from the outside objects are too complicated...

When I run it, instead of the strings there are null values.

So I've tried thinking a lot on my own but still couldn't find a solution. Perhaps there's a way i'm not familiar with.

Any suggestions?

Thanks in advance,

Mor.
Greg Brannon
Bartender

Joined: Oct 24, 2010
Posts: 557
Build the desired String object into a separate variable and then use that variable in the setText() method.


Learning Java using Eclipse on OpenSUSE 11.2
Linux user#: 501795
Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19656
    
  18

Welcome to the Ranch!

Are you sure it's the call to setText that's throwing the exception, and not the call to ms.lg.getCurrentUsername() or ms.lg.getCurrentPermission()? Why don't you post the full stack trace here?


SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6
How To Ask Questions How To Answer Questions
Mor Merhav
Greenhorn

Joined: May 17, 2011
Posts: 6
Greg Brannon wrote:Build the desired String object into a separate variable and then use that variable in the setText() method.


I've actually tried that but got the same result...

The full stack trace is:
Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18541
    
    8

That isn't a stack trace. In fact I'm not even sure it's a runtime error. It looks more like a message produced by an IDE.

And when I google the interesting bits of the message, I find that it's coming from Eclipse, and more specifically from something called "VE" which is a component of Eclipse.
Mor Merhav
Greenhorn

Joined: May 17, 2011
Posts: 6
Paul Clapham wrote:That isn't a stack trace. In fact I'm not even sure it's a runtime error. It looks more like a message produced by an IDE.

And when I google the interesting bits of the message, I find that it's coming from Eclipse, and more specifically from something called "VE" which is a component of Eclipse.


Yeah I'm sorry I didn't notice that I wrote it was a stack trace.

But there is no stack trace produced, that's all there is.

And yes, VE is the Visual Editor i'm working with to create my GUI.

Anyway , i'm sure there's a way to do it because it's a very basic thing to do and almost every application or website with a login in it does what i'm trying to do.

So still, are there any suggestions :D?
Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18541
    
    8

It appears that your IDE doesn't like the expression "ms.lg" for some reason. You should investigate why that is.
Mor Merhav
Greenhorn

Joined: May 17, 2011
Posts: 6
Paul Clapham wrote:It appears that your IDE doesn't like the expression "ms.lg" for some reason. You should investigate why that is.


I already investigated it, or tried to that is.

Meaning, I tried to create a new string first, and then using it in setText, but it gave the same IllegalArgumentException.

What I tried to do was:



So I figured that there's a problem with JLabel's setText() method. Namely, that it works only with Strings that are not constructed by other strings from different objects. That is in my opinion due to the complexity in pointer arithmetics, or something of the sort.

What do you think?
Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18541
    
    8

Mor Merhav wrote:So I figured that there's a problem with JLabel's setText() method. Namely, that it works only with Strings that are not constructed by other strings from different objects. That is in my opinion due to the complexity in pointer arithmetics, or something of the sort.

What do you think?


If we were just talking about Java, then that would be nonsense. The setText() method simply accepts a String value, and it neither knows nor cares where it came from or how it was created. However you're talking about an error message from VE (which I know nothing about).

Besides the error message you posted specifically pointed to "ms.lg" being the alleged problem. Nothing about setText at all.

So you should be looking at "ms.lg" and figuring out what's up with that.
Darryl Burke
Bartender

Joined: May 03, 2008
Posts: 4523
    
    5

What do you think?

I think you should get rid of the unnecessary String constructor and break up that expression in several lines, and then see whether your IDE still has a problem with any line.

So I figured that there's a problem with JLabel's setText() method.
There isn't.


luck, db
There are no new questions, but there may be new answers.
Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19656
    
  18

This is definitely not a problem in Swing but in Eclipse, so off to the IDEs forum we go.
Mor Merhav
Greenhorn

Joined: May 17, 2011
Posts: 6
Darryl Burke wrote:
What do you think?

I think you should get rid of the unnecessary String constructor and break up that expression in several lines, and then see whether your IDE still has a problem with any line.

So I figured that there's a problem with JLabel's setText() method.
There isn't.


I've tried your suggestion, but I get the same problem...

About ms.lg, I'm using it quite often in other places in my project (even in the same object) and it never produces any kind of problem,

So how would you suggest I should investige it further?
Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18541
    
    8

Here's a suggestion: you used "ms.log" and "ms.lg". Are those the same thing? If so, why? Do you get this "too complicated" message for both of them?

It's quite unfair of you to ask us how to investigate this problem. All we know is that you have something called "ms". That is almost zero information to start from. You, on the other hand, have the entire source code to look at.
Mor Merhav
Greenhorn

Joined: May 17, 2011
Posts: 6
Paul Clapham wrote:Here's a suggestion: you used "ms.log" and "ms.lg". Are those the same thing? If so, why? Do you get this "too complicated" message for both of them?

It's quite unfair of you to ask us how to investigate this problem. All we know is that you have something called "ms". That is almost zero information to start from. You, on the other hand, have the entire source code to look at.


"ms.log" is not my doing, I just quoted someone here who didn't notice or just had a typo mistake. There's only "ms.lg"...

And i'm sorry if I was being unfair, what I meant was that I looked at the code myself and I'm using ms.lg in many other places in my program and it never produces any problem, except when I try using it to get a String to send to setTexT().

All I want to do is display a message for the different kinds of users in my system. for example:

"Welcome Nom1fan! Permission: Customer"

"Welcome Nom2fan! Permission: Admin"

If there is any other way I can do it except the way i'm trying to and not succeeding i'll be happy to hear it. I'm just a beginner you guys are experts :D

Anyway, if you need any kind of information about my code/program that I could supply for you, to help you help me, just ask ! :thumbup:

 
wood burning stoves
 
subject: JTextField - IllegalArgumentException - Too complicated
 
Similar Threads
Problem getting log4j.properties picked up when I use security.manager ?
can't upload
Serialization and ClassCastException
NX: Writng String[] to datafile
HashMap/Tree map question