Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

JTextField - IllegalArgumentException - Too complicated

 
Mor Merhav
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 563
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Build the desired String object into a separate variable and then use that variable in the setText() method.
 
Rob Spoor
Sheriff
Pie
Posts: 20668
65
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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?
 
Mor Merhav
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Sheriff
Posts: 21416
33
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Sheriff
Posts: 21416
33
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It appears that your IDE doesn't like the expression "ms.lg" for some reason. You should investigate why that is.
 
Mor Merhav
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Sheriff
Posts: 21416
33
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 5148
11
Java Netbeans IDE Opera
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Rob Spoor
Sheriff
Pie
Posts: 20668
65
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This is definitely not a problem in Swing but in Eclipse, so off to the IDEs forum we go.
 
Mor Merhav
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Sheriff
Posts: 21416
33
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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:

 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic