Solved

Readable output

Posted on 2006-12-01
3
225 Views
Last Modified: 2010-03-31
Hey again,

objects was kind enough to supply me with the following code which solved my previous problem:

JComboBox comboxChanged;

public void actionPerformed(ActionEvent, e) {
comboxChanged = (JComboBox) e.getSource();
itemChanged();
}

public void itemchanged() {
switch(comboxChanged.getSelectedIndex()) {
case 0:
// something;
break;
case 1:
// something else;
break;
etc ...
}


Problem arrises when I try to output the variable combox, the output is just a string of rubbish about the comboBox [ bounds, colors etc ].  How can I turn this useless info into somthing useful ?

Kind Regards,
0
Comment
Question by:3nigmatic
  • 2
3 Comments
 
LVL 8

Accepted Solution

by:
colr__ earned 300 total points
ID: 18058159
comboBox is a non-string object, so when you call toString() on it, it prints out a string representation of the objetc, not any text that object may contain.

Use getSelectedItem() to get a reference to the selected object in comboBox. Then, depending on what that selected object is, you can get the info you need.

The selected object depends on what you added to the comboBox - if they were String's, then you already have what you need. If not, call any methods on that object that will give you the string you're looking for.
0
 
LVL 2

Author Comment

by:3nigmatic
ID: 18058166
Hey,

Thats almost it, getSelectedItem() prints out what has been selected ... I am trying to get ahold of the "name" of the combobox that was changed rather than the item that was selected.

Is this possible ?

Thanks for your time.
0
 
LVL 2

Author Comment

by:3nigmatic
ID: 18058373
Resolved the issue myself using setName() and getName() ... bit inefficient but it does the job and thats all I require at this time, thanks anyway.
0

Featured Post

What is SQL Server and how does it work?

The purpose of this paper is to provide you background on SQL Server. It’s your self-study guide for learning fundamentals. It includes both the history of SQL and its technical basics. Concepts and definitions will form the solid foundation of your future DBA expertise.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
java.io.BufferedReader   readLine()  //returns the entire file ? 4 73
servlet filter example 37 63
Java exception bubble up 2 18
Android development question 2 37
Java Flight Recorder and Java Mission Control together create a complete tool chain to continuously collect low level and detailed runtime information enabling after-the-fact incident analysis. Java Flight Recorder is a profiling and event collectio…
Introduction This article is the second of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers the basic installation and configuration of the test automation tools used by…
The viewer will learn how to implement Singleton Design Pattern in Java.
This tutorial covers a step-by-step guide to install VisualVM launcher in eclipse.

809 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question