How to convert a character into an integer!!
I'm a bigginer in Java Programming...
my problem is that I want to conver the word (red) into a real integer VALUE to be used in a switch case!!
here's a part of the code which make a problem to me
String s=c1.getSelectedItem();
switch (s)
case "red";
l1.setBackground(Color.red);
break;
case "yellow";
l1.setBackground(Color.yellow);
break;
case "green";
l1.setBackground(Color.green);
break;
It didn't work, so I need a value like 1 to be assigned to the word (red) and another value like 2 to be assigned to the word (green)...etc
HOW?.........ANY HELP?
first of all, there has to be a better way than this, but since you're only using red yellow and green, you could put it inside a char like this
char r = ((String) c1.getSelectedItem).charAt(0);
switch (s)
case 'r':
l1.setBackground(Color.red);
break;
case 'y'
l1.setBackground(Color.yellow);
break;
case 'g':
l1.setBackground(Color.green);
break;
}also I noticed you use ; instead of :
a case expects a : after case value, and not a ;
secondary, you could also work with getSelectedIndex Id think, but i'm not sure since I do not know what you're asking a selection from.
if it's a JList with strings representing colors, you could design a specialisation class of Color with a custom toString (used by the default ListCellRenderer) and then have it return the color object (getselectedItem returns an Object value, so you can cast that into your custom color and assign that to your background, you wouldnt even need a switch case, but I have to agree it's not very simple if you're new to java)
anyways I hope this helped, i'd first try it with : instead of ; tho, i do not know if switch case support strings since strings are objects and not primitives. so if that doesnt work try to work with the char, if you get duplicates i'd work with getSelectedIndex() which returns an int (you can work with a Color object array with similar running indices where index 0 in the color array is in index 0 of your list array, once again removing the need for a switch case
well I think i'm done now ;)
PS: you can use the forums [ code ] and [ code ] tags to make your copy/pasted code much clearer to see. (use them without the spaces, I had to add those or it was not visible)
Similar Messages
-
How to Convert Latin Character into English
Hi Experts,
Can you please suggest how to covert Latin Characters into English like- ó to o, ú to u and so on.is there any FM ??
Logic: Jesúsó converted to --> JesusoPre unicode, I used the TRANSLATE statement. Post-unicode, there's no problem with these characters. What are you doing with them that requires the stripping out of accents etc.?
-
How to convert word doc into pdf - which product of adobe i need to use- what upgrades - am a newbie
How to convert word doc into pdf - which product of adobe i need to use- what upgrades - am a newbie - simple answers please - Thanks in advance.
@Pipeline2007 - which version of Microsoft Office have you got? Older versions of Acrobat aren't compatible with the latest versions of Office, see this link for info:
http://helpx.adobe.com/acrobat/kb/compatible-web-browsers-pdfmaker-applications.html -
How to convert jpeg files into word
How to convert jpeg files into Word
Hi Eugene,
I don't think you can convert an image to a Word document, but you could place the JPEG into a Word document using the Insert > Object command in Word.
For other questions relating to Word, you will probably have more luck getting an answer if you post on the Microsoft forums (we can help if you're using Acrobat, or another Adobe product, but you'll find the Word experts on the Microsoft forums.)
Best,
Sara -
How to convert Date format into day in ssrs reports?
Hi
How to convert date format into day?
10/01/2010 as like Monday like that?=weekdayname(datepart("w",Fields!mydate.Value))
-Vaibhav Chaudhari -
How to convert Doc file into image
hello frnds
Can any body guide me how to convert doc file into image and show into swf loader.
actually i have to convert doc files into swf files in runtime so that i have to use this flow.
is it possible to convert doc file into byte array and than convert into image.
Thanks And Regards
Vineet OshoYou can convert any DisplayObject to byeArray using this function ImageSnapshot.captureBitmapData().getPixels()
-
How to convert system Date into DD-MMM-YYYY Format
hi friends,
please help me How to convert system Date into DD-MMM-YYYY Format.
Regards
YogeshHI..
data: w_dt(11) type c,
w_month(2),
w_mon(3).
w_month = p_date+4(2). **p_date = given date**
case w_month.
when '01'.
w_mon = 'Jan'.
when '02'.
w_mon = 'Feb'.
when '03'.
w_mon = 'Mar'.
when '04'.
w_mon = 'Apr'.
when '05'.
w_mon = 'May'.
when '06'.
w_mon = 'Jun'.
when '07'.
w_mon = 'Jul'.
when '08'.
w_mon = 'Aug'.
when '09'.
w_mon = 'Sep'.
when '10'.
w_mon = 'Oct'.
when '11'.
w_mon = 'Nov'.
when '12'.
w_mon = 'Dec'.
endcase.
Now...
concatenate p_date6(2) '-' w_mon '-' p_date0(4) into w_dt.
write w_dt. -
How to convert a optionset into multi selection picklist in crm 2011 using javasacript??
hi,
where user want to select not only one but multiple value
from a pick list. I tried examples but it shows some errors.
How to do it??Hey I meet a problème on my development see my result :
link : https://social.microsoft.com/Forums/getfile/652331
a multiple select list on my crm 2013 I do this process on this forum :
link : https://social.microsoft.com/Forums/en-US/2db47a59-165d-40c9-b995-6b3262b949eb/how-to-convert-a-optionset-into-multi-selection-picklist-in-crm-2011-using-javasacript?forum=crmdevelopment
my development :
// var_sc_optionset >> Provide schema-name for Option Set field
// var_sc_optionsetvalue >> Provide schema-name for field which will store the multi selected values for Option Set
// OS >> Provide Option Set field object
// OSV >> Provide text field object which will store the multi selected values for Option Set
//Method to convert an optionset to multi select Option Set
function ConvertToMultiSelect(var_sc_optionset, var_sc_optionsetvalue, OS, OSV)
if( OS != null && OSV != null )
OS.style.display = "none";
Xrm.Page.getControl(var_sc_optionsetvalue).setVisible(false);
// Create a DIV container
// var addDiv = document.createElement("<div style='overflow-y:auto; color:#000000; height:160px; border:1px #6699cc solid; background-color:#ffffff;' />");
var addDiv = document.createElement("div");
addDiv.style.overflowY = "auto";
addDiv.style.height = "160px";
addDiv.style.border = "1px #6699cc solid";
addDiv.style.background = "#ffffff";
addDiv.style.color = "#000000";
OS.parentNode.appendChild(addDiv);
// Initialise checkbox controls
for( var i = 1; i < OS.options.length; i++ )
var pOption = OS.options[i];
if( !IsChecked( pOption.text , OS, OSV) ){
// var addInput = document.createElement("<input type='checkbox' style='border:none; width:25px; align:left;' />" );
var addInput = document.createElement("input" );
addInput.setAttribute("type","checkbox");
addInput.setAttribute("style","border:none; width:25px; align:left;");
else {
// var addInput = document.createElement("<input type='checkbox' checked='checked' style='border:none; width:25px; align:left;' />" );
var addInput = document.createElement("input" );
addInput.setAttribute("type","checkbox");
addInput.setAttribute("checked","checked");
addInput.setAttribute("style","border:none; width:25px; align:left;");
// var addLabel = document.createElement( "<label />");
var addLabel = document.createElement( "label");
addLabel.innerText = pOption.text;
// var addBr = document.createElement( "<br />"); //it's a 'br' flag
var addBr = document.createElement( "br"); //it's a 'br' flag
OS.nextSibling.appendChild(addInput);
OS.nextSibling.appendChild(addLabel);
OS.nextSibling.appendChild(addBr);
///////Supported functions
// Check if it is selected
function IsChecked( pText , OS, OSV)
if(OSV.value != "")
var OSVT = OSV.value.split(";");
for( var i = 0; i < OSVT.length; i++ )
if( OSVT[i] == pText )
return true;
return false;
// var_sc_optionsetvalue >> Provide schema-name for field which will store the multi selected values for Option Set
// OS >> Provide Option Set field object
// Save the selected text, this field can also be used in Advanced Find
function OnSave(OS, var_sc_optionsetvalue)
var getInput = OS.nextSibling.getElementsByTagName("input");
var result = '';
for( var i = 0; i < getInput.length; i++ )
if( getInput[i].checked)
result += getInput[i].nextSibling.innerText + ";";
//save value
control = Xrm.Page.getControl(var_sc_optionsetvalue);
attribute = control.getAttribute();
attribute.setValue(result);
I have to do 2 field one is option list field and the second is textfield,
option list field : new_books
textfiled : new_picklistvalue
my js is on onload event see :
link : https://social.microsoft.com/Forums/getfile/652333
thanks you for you'r help -
Hi..
I am currently working on Internationalization. I have created property files for the textual content and using PropertyResourceBundles. Now I want to use ListResourceBundles. So what I want to know is..
How to convert Property files into Java Objects.. I think Orielly(in their book on Internationalization) has given an utitlity for doing this. But I did not get a chance to look into that. If anyone has come across this same issue, can you please help me and send the code sample on how to do this..
TIA,
CKHi Mlk...
Thanks for all your help and suggestions. I am currently working on a Utility Class that has to convert a properties file into an Object[][].
This will be used in ListResourceBundle.
wtfamidoing<i>[0] = currentKey ;
wtfamidoing<i>[1] = currentValue ;I am getting a compilation error at these lines..(Syntax error)
If you can help me.. I really appreciate that..
TIA,
CK -
How to convert HL7 file into an XML
Hi All,
I am new to HL7,can any one tell how to convert HL7 file into an XML.Give sample demo or related links.
My sample HL7 file is as follows how can I convert.
FHS|^~\&||Tax ID123^Lab Name123^L|||201110191435||HL7.txt||1234567|123||
PID|seqno|123||john^chambers^^Dr^Dr|2456 california ave^San jose^CA^85254|19601212|M
FHS|^~\&||Tax ID123^Lab Name123^L|||File Creaqted Date|File Security|FileName||File HeaderComment||Facility|FileCreatedDateTime|File Security|File Name|File Header Comment|FileControlId|Reference File Control ID|
PID|seqno|patientId||LastName^FirstName^MiddleName^Title^Degree|Street^City^State^zip|patientDOB|gender
<Report>
<FileHeader>
<FileSendingApplication> </FileSendingApplication>
<TaxID>Tax ID123</TaxID>
<LabName>Lab Name123</LabName>
<FileSendngFacilityType>L</FileSendngFacilityType>
<FileReceivingApplication></FileReceivingApplication>
<FileReceivingFacility></FileReceivingFacility>
<FileCreatedDateTime>201110191435</FileCreatedDateTime>
<FileSecurity></FileSecurity>
<FileName>HL7.txt</FileName>
<FileHeaderComment></FileHeaderComment>
<FileControlId>1234567</FileControlId>
<ReferenceFileControlID></ReferenceFileControlID>
<FileHeader>
<Patient>
<seqno> </seqno>
<patientId>Tax ID123</patientId>
<LastName>Lab Name123</LastName>
<FirstName>L</FirstName>
<MiddleName></MiddleName>
<Title> </Title>
<Degree></Degree>
<Street></Street>
<City></City>
<State>HL7.txt</State>
<Zip></Zip>
<patientDOB>1234567</patientDOB>
<gender></gender>
<Patient>
</Report>
Thanks
ManiHi Prabu,
With input as in single line I'm able to get the the output but with the multiple lines of input,error was occured.Any suggestions.
Error while translating. Translation exception. Error occured while translating content from file C:\temp\sampleHL7.txt Please make sure that the file content conforms to the schema. Make necessary changes to the file content or the schema.
The payload details for this rejected message can be retrieved. Show payload...
Thanks
Mani -
HT204382 How to convert VOB files into MP4 ? Tks
Hi, anyone knows how to convert VOB files into MP4 ones ?
Tkshttp://forums.macrumors.com/showthread.php?t=812985
The procedure is dated and I will assume that the DVD is not copy-protected since discussion of such things is verboten. -
How to convert database table into xml file
Hi.
How to convert database table into XML file in Oracle HTML DB.
Please let me know.
Thanks.This not really a specific APEX question... but I search the database forum and found this thread which I think will help
Exporting Oracle table to XML
If it does not I suggest looking at the database forum or have a look at this document on using the XML toolkit
http://download-east.oracle.com/docs/html/B12146_01/c_xml.htm
Hope this helps
Chris -
How to convert select-options into parameters
hi Abapers,
i have an urgent requirement, iwant to know how to convert select-options into parameters
on selection screen,is it possible to do.TABLES: spfli.
SELECTION-SCREEN BEGIN OF BLOCK test.
SELECT-OPTIONS:
s_carrid FOR spfli-carrid NO INTERVALS NO-EXTENSION.
SELECTION-SCREEN END OF BLOCK test.
Greetings,
Blag. -
How to convert table content into html format?
Hi,
Experts,
How to convert internal data into HTML format is there any function module or piece of code to download content into HTML.
Thank u,
Shabeer Ahmed.Then use this code....
REPORT ytest_table_html1.
* D A T A D E C L A R A T I O N
*-HTML Table
DATA:
t_html TYPE STANDARD TABLE OF w3html WITH HEADER LINE,
" Html Table
*- Declare Internal table and Fieldcatalog
it_flight TYPE STANDARD TABLE OF sflight WITH HEADER LINE,
" Flights Details
it_fcat TYPE lvc_t_fcat WITH HEADER LINE.
" Fieldcatalog
*-Variables
DATA:
v_lines TYPE i,
v_field(40).
*-Fieldsymbols
FIELD-SYMBOLS: <fs> TYPE ANY.
* S T A R T - O F - S E L E C T I O N
START-OF-SELECTION.
SELECT *
FROM sflight
INTO TABLE it_flight
UP TO 20 ROWS.
* E N D - O F - S E L E C T I O N
END-OF-SELECTION.
*-Fill the Column headings and Properties
* Field catalog is used to populate the Headings and Values of
* The table cells dynamically
CALL FUNCTION 'LVC_FIELDCATALOG_MERGE'
EXPORTING
i_structure_name = 'SFLIGHT'
CHANGING
ct_fieldcat = it_fcat[]
EXCEPTIONS
inconsistent_interface = 1
program_error = 2.
DELETE it_fcat WHERE fieldname = 'MANDT'.
t_html-line = '<html>'.
APPEND t_html.
CLEAR t_html.
t_html-line = '<thead>'.
APPEND t_html.
CLEAR t_html.
t_html-line = '<tr>'.
APPEND t_html.
CLEAR t_html.
t_html-line = '<td><h1>Flights Details</h1></td>'.
APPEND t_html.
CLEAR t_html.
t_html-line = '</tr>'.
APPEND t_html.
CLEAR t_html.
t_html-line = '</thead>'.
APPEND t_html.
CLEAR t_html.
t_html-line = '<table border = "1">'.
APPEND t_html.
CLEAR t_html.
t_html-line = '<tr>'.
APPEND t_html.
CLEAR t_html.
*-Populate HTML columns from Filedcatalog
LOOP AT it_fcat.
CONCATENATE '<th bgcolor = "green" fgcolor = "black">'
it_fcat-scrtext_l
'</th>' INTO t_html-line.
APPEND t_html.
CLEAR t_html.
ENDLOOP.
t_html-line = '</tr>'.
APPEND t_html.
CLEAR t_html.
DESCRIBE TABLE it_fcat LINES v_lines.
*-Populate HTML table from Internal table data
LOOP AT it_flight.
t_html-line = '<tr>'.
APPEND t_html.
CLEAR t_html.
*-Populate entire row of HTML table Dynamically
*-With the Help of Fieldcatalog.
DO v_lines TIMES.
READ TABLE it_fcat INDEX sy-index.
CONCATENATE 'IT_FLIGHT-' it_fcat-fieldname INTO v_field.
ASSIGN (v_field) TO <fs>.
t_html-line = '<td>'.
APPEND t_html.
CLEAR t_html.
t_html-line = <fs>.
APPEND t_html.
CLEAR t_html.
t_html-line = '</td>'.
APPEND t_html.
CLEAR t_html.
CLEAR v_field.
UNASSIGN <fs>.
ENDDO.
t_html-line = '</tr>'.
APPEND t_html.
CLEAR t_html.
ENDLOOP.
t_html-line = '</table>'.
APPEND t_html.
CLEAR t_html.
*-Download the HTML into frontend
CALL FUNCTION 'GUI_DOWNLOAD'
EXPORTING
filename = 'C:\Flights.htm'
TABLES
data_tab = t_html
EXCEPTIONS
file_write_error = 1
no_batch = 2
gui_refuse_filetransfer = 3
invalid_type = 4
no_authority = 5
unknown_error = 6
header_not_allowed = 7
separator_not_allowed = 8
filesize_not_allowed = 9
header_too_long = 10
dp_error_create = 11
dp_error_send = 12
dp_error_write = 13
unknown_dp_error = 14
access_denied = 15
dp_out_of_memory = 16
disk_full = 17
dp_timeout = 18
file_not_found = 19
dataprovider_exception = 20
control_flush_error = 21
OTHERS = 22.
IF sy-subrc <> 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.
*-Display the HTML file
CALL METHOD cl_gui_frontend_services=>execute
EXPORTING
document = 'C:\Flights.htm'
operation = 'OPEN'
EXCEPTIONS
cntl_error = 1
error_no_gui = 2
bad_parameter = 3
file_not_found = 4
path_not_found = 5
file_extension_unknown = 6
error_execute_failed = 7
synchronous_failed = 8
not_supported_by_gui = 9
OTHERS = 10.
IF sy-subrc <> 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.
none of the above function modules r obsolete... -
How to convert DataServices.Result into an Arraylist or ArrayCollection?
I want to use an ArrayCollection or an ArrayList as a data provider
for a dataGrid, and then later in a Graph.
The problem is that the starting point is the FLEX Builder 4 created "datasource.lastResult" value Objects.
I don't know how to access anything but the Column names.
The fields returned are:
gmtdate,hostname,CPUBusy
I want to show CPU busy for "N" number of hosts.
So I need to change my result from the SQL query in Action Script into:
gmtdate, hostname1_CPUbusy, hostname2_CPUbusy, hostnameN_CPUbusy
Are there any samples of how to convert the .lastResult into an ArrayList?
The result set is Object based and I can't figure out how to read it.
Thanks,
DavidI wish I could change it, but Oracle SQL does not allow for an unknown number of hosts.
Nor does this version of Oracle have the new pivot function.
David
Maybe you are looking for
-
Conversion of postscript (converted from secure or encrypted pdf) to pdf
I have a postscript file which has been created from secure or encrypted (opening restriction) pdf. Now when i use distiller to convert this postscript file to pdf then distiller cannot produce a pdf file. The log file contains following text: This P
-
How do I fix my case fans??
I have two 80 mm case fans (12v). I was wondering what the allignment of the fans should be. Should These fans blow air INTO the case or should they SUCK OUT the air from the case. I currently use a 350 Watt CODEGEN PSU with a single fan which sucks
-
Why did Lion download updates I didn't select?
A couple of days ago I checked for updates for my Lion - I was in particular looking for the Java update to fix the recently reported security issue - and selected 2 items including the Java update for downloading. I checked the size of the items an
-
How to get al object's type used inside a function group
Hello There, I want to create a program to get all the objects used inside a Function group, for example all the data structure type (not the field name of fieds ortable name used in import/export but their data types) used in import/export/table par
-
my iphone 3g is stuck on the screen with the apple on it as if it is rebooting has anyone had thisproblem?