Formatting string output in columns to a JtextArea
Hello,
I am pretty new to java and GUI's but i am working on a project that needs to output some statisitcs to a JtextArea. I need have all the data in an array and i want it to appear as
First Name Last Name Points Rebounds Assists Minutes
The last four columns are numbers but are stored as strings. I would like to find a way to format them into colums so that even though each name is a differing number of characters, each column will be flush left. Thanks.
I strongly agree with Camikr, use Jtable is the best solution since you have arrays of data to be displayed
I'll show you few tips that might be helped
if you don't want the header part to appear you do this:
JTable table = new JTable(..)
table.getTableHeader().setPreferredSize(new Dimension(0,0));if you want the table to appear like JLabel maybe you can set like this:
table.setBackground(UIManager.getColor("Panel.background"));
table.setGridColor(UIManager.getColor("Panel.background"));so it will make the background and cell border color to be the same as panel
if you insist to use table another work around is by formatting your jlabel using html code like this
new JLabel("<html><table><td>First Name</td>.......</table></html>");
Similar Messages
-
hi,
i have a textarea that the user uses to enter the text.
eg.
Hello
how r you?
I am
fine.
this text is stored in to the database. i retrieve the string from the database and try to display it on the jsp. but it does show in one single line. i tried to replace new line characters with <br>, but the jsp still shows the <br> as text instead of recognising it as an html tag.
can anyone please help
thanks in advanceYou can probably do this
on the client side(in the browser) using JavaScript replace new line characters(\n or \r) with ASCII representation for new line


then when redisplay it the browser will automatical enter new line. hope this helps(its probably not the best approach,but thats what I could think of during lunch time*_*) -
Format string literal output?
Trying to format the output of sqlplus for a string literal, but can't seem to get it to work. If I SELECT a literal, the literal column's width is always 32 characters long. Kinda makes things look a bit wonky.
For instance, if I try:
SELECT ',' FROM DUAL
My output looks like this:
It's a bit frustrating when I'm trying to do something like:
SELECT lastname, ',' , firstname from mytable;
I'll COL lastname FORMAT to my heart's desire, but not luck.
Weird thing is that two of my servers are behaving differently. They should be set up the same, but obviously there's some environment setting or something that's different. On the "good" server, that one "SELECT ',' from dual;" query returns this:
Any ideas?
Edited by: user9526990 on Mar 12, 2009 2:38 PM
Ok, so the WYSIWYG editor is overriding my formatting. That horizontal line above should just be 32 consecutive hyphens (--- etc), but it's rendering it as a line.
Edited by: user9526990 on Mar 12, 2009 2:39 PMIn all honesty, I think I could just concatenate it and call it good, but at this point I'm just wondering why it doesn't work the same way on both servers.
What happens is that we have a scheduled job that runs this query every night and dumps the output into a file that's used by some other processes:
whenever oserror exit sql.oscode
whenever sqlerror exit sql.sqlcode
spool D:\output\file.txt
set pages 0
set lines 80
set head off
set echo off
set verify off
set feedback off
column owner format a20
column table_name format a33
column mycolumn format a12
select l.owner,',', l.table_name,',', l.mycolumn from tablename l;
spool off
exit
Frankly, that snippet's been with the company longer than I have, so I'm not sure why the original author opted for this method rather than just concatenating. But, as I mentioned, I'm more curious about why it doesn't behave the same way on both boxes now. -
In report layout, can format a long string display as Column mode?
Hi,
Just want to check in report builder any way can format a long string into a column mode?
Example: I have a field to hold 8000 character, and would like to print
30 character in each line, when reach 50 line, then print in column i/o to print next page?
Any idea ? Thanks a lot if you can share your experience with me.
best Regards,
Klnghauhi let say your field name is x
then if your want it word wrap then it's simple just get one field and make it's vertical
elasticity variable. and asign the field to it..
but if you want your field to be displayed as
first colunm and then beside continuation of that column but in 2nd one...
then create 2 formula columns make your field legth been distributed half in each.
so cf_1 is:
decalre
t varchar2(1510);
begin
if length(:x) > 1500
t := substr(x, 1, 1500); -- as 30 x 50 = 1500
else
t := :x;
end if;
return t;
so cf_2 is:
decalre
t varchar2(1510);
begin
if length(:x) > 1500
t := substr(x, 1500, length(:x)-1500); -- as 30 x 50 = 1500
else
t := '';
end if;
return t;
and then in design view
field1 field2
for field1 source is cf_1 and
for field2 source is cf_2
that's all
Enjoy Oracle... -
How to insert a very long string into a column of datatype 'LONG'
Can anyone please tell me how can I insert a very long string into a column of datatype 'LONG'?
I get the error, ORA-01704: string literal too long when I try to insert the value into the table.
Since it is an old database, I cannot change the datatype of the column. And I see that the this column already contains strings which are very long.
I know this can be done using bind variables but dont know how to use it in a simple query.
Also is there any other way to do it?Hello,
To preserve formatting in this forum, please enclose your code output between \ tags. And when executing you code as a pl/sql or sql script
include following lineset define off;
Your code or output goes here
\Regards
OrionNet -
How can i change the Format of my DATE column?
I need to change the date format for a whole column. At present i can do MM-DD-YYYY. I need to change this this to DD-MMM-YYYY.
I know about the to_date function, i tried to apply it to change the format of my whole column by doing the following.....
CREATE TABLE "IT220_DATEHOLIDAY"
"DEPARTID" VarChar(2)NOT NULL ENABLE,
"HOLCODE" VARCHAR2(2)NOT NULL ENABLE,
"DEPARDATE" DATE,
to_date('DATE','DD-MMM-YYYY'), <<<change DATE column to DD-MMM-YYYY
CONSTRAINT "DATEHOLIDAY_PK" PRIMARY KEY ("DEPARTID") ENABLE
ORA-00902: invalid datatype <<<<This was the error message i received.
I am aware that the to_date function is supposed to be used to change strings into a certain format. I guess this means you cant do it with columns? Is there anyway i can format the whole column or do i have to do each string of data entered one by one?
Thanks in advance!Hello Jay,
I'm not sure you hit the right forum, as this doesn't seem to be a problem with APEX.
Anyway:
You can't use that function on a table like that, and as you already suggested, the to_date-function expects a string value.
It seems you also have a misunderstanding of the basic datatypes in the database. DATE is such a datatype and is stored an internal format you don't need to care about. Each time your request the value, the database will give you a string representation according to either your locale or you give a certain formatting mask.
The same applies to insert or update operations: you hand in either a variable of type DATE or use a function like to_date to create an "object" of type date.
You may be interested in reading the documentation of the [url http://download.oracle.com/docs/cd/E11882_01/server.112/e16508/toc.htm]Oracle Database Concepts. The section concerning datatype DATE can be found here:
http://download.oracle.com/docs/cd/E11882_01/server.112/e16508/tablecls.htm#CBBGJHJC
An overview of formatting options can be found here:
http://download.oracle.com/docs/cd/E11882_01/server.112/e17118/sql_elements004.htm#SQLRF00212
So to answer your question: You would format it as part of your insert operation, taking a string and convert it using to_date.
-Udo -
Calling Bpel Process From a Jsp(Need a string output instead of XML object)
Hi
I am calling a BPEL process(Synchrononus) from a JSP page, Where Bpel process calls a java web service.The output from Bpel process is returned as an XML object. I need the output in a string format.Please let me know the steps to get the string output.
I also executed invokeCreditRatingService.jsp(from samples shipped with SOA Suite) that calls CreditRatingService bpel, but i was getting the following output where the rating value is printed as an XML object.
Output:-
BPELProcess CreditRatingService executed!
Credit Rating is oracle.xml.parser.v2.XMLElement@9511c8
Please let me know, what changes i need to make to get the string output.I followed all the steps given in "orabpel-Tutorial7-InvokingBPELProcesses.PDF" to execute credit rating jsp.
We are using SOA Suite 10.1.3.1.0 version.Do I need to make any changes to the code, to make it work with this version.
Thanks
Vandana.The call payload.get("payload") returns, as you have observed, an XMLElement. You can simply convert the XMLElement into an XML string by using a DOMSerializer implementation. The following code is very useful for this purpose:
http://javafaq.nu/java-example-code-432.html
Best,
Manfred -
Warning - 1241024 - Possible string truncation in column #
I am running the following command in a simple MaxL script, the output of which is sent to a text file:
display variable App.DB.SubVar;
The text file appears to have generated fine, with the substitution variable value displayed. However, the following warnings are returned each time from the stderr output. Should I be concerned? Is there any way to rectify this?
WARNING - 1241024 - Possible string truncation in column 3.
WARNING - 1241028 - Output column defined with warnings.
WARNING - 1241024 - Possible string truncation in column 4.
WARNING - 1241028 - Output column defined with warnings.Hi John,
Many thanks for your response. The problem is a little confusing, as I cannot see how anything is being truncated here - indeed there are characters to spare! Could it be because the potential size of the substitution variable name is 320 bytes and the potential size of the substitution variable value is 256 bytes (11.1.2.1)? Could this be the cause of the warnings here?
Adding "set column_width 10;" does not appear to remove the warnings either unfortunately. Do you please have any other thoughts on how I might remove the warnings? It might allay the fears of the client later on!
James -
How to get the system date format string?
Hello, everybody!
I want to create a MaskFormatter with a mask for dates. So, I could suply as the constructor parameter: "##/##/####'. However, what if the year comes first in the current system date format settings, or the month is in the second place or in the first?... So, I can't just suppose that the current locale format for dates is like the one above. So, my question is: is there a way to get the SYSTEM DATE FORMAT STRING in Java? Searching in google I saw that this was already asked in this forum:
http://forum.java.sun.com/thread.jspa?threadID=301034&messageID=1193794
but there was no effective answer. Does someone already know how to get this?
Thank you.
MarcosHi, not sure, but
import java.text.*;
SimpleDateFormat sdf = new SimpleDateFormat();
System.out.println(sdf.toPattern());
will output something like dd/MM/yy HH:mm
hthThank you very much. It worked. -
SQL LOADER and ORA-01861: literal does not match format string
Hi,
I've to load data through control_file(.ctl) into oracle table through sqlldr. Oracle 11g, win xp.
as soon as I use - sqlldr dss/dss control=orders.ctl I get error or nothing.
Text file that is generated after loading fails has the following error.
Record 1: Rejected - Error on table ORDERS, column O_ORDERDATE.
ORA-01861: literal does not match format string
I have checked the format of data to be loaded into Orders table is like this : *1996-01-02.*
I checked the format of data in my database by querying sysdate from dual i.e. 10-JAN-10
I thought that changing its format might solve my problem so i tried this:
SQL> alter session set nls_date_format='YYYY-MM-DD';
Session altered.
SQL> select sysdate from dual;
SYSDATE
2010-01-10but still i'm getting the same error. I've to load millions of data. how I can solve this issue.
Please suggest.
Thanks alot.
Best Regads,
KamHi,
It's strange ....nobody knew it?. I think this type of load problem will be very common isn't it.... where date column data is in a different format than in the db i.e.
How to change *1996-01-02* in the Control_file to make it able to load in the table where sysdate is like this: *11-JAN-10*
Sample data to be loaded is :
1|36901|O|173665.47|1996-01-02|5-LOW|Clerk#000000951|0|nstructions sleep furiously among |
Desc Orders
O_ORDERDATE NOT NULL DATEI have tested this by creating a test table and a test control file by omitting this O_ORDERDATE and then everything was fine, data was inserted but don't know how to load this DATE also.
Also not able to understand about POSITION in the control file...?
Regards,
Kam -
SQL Error: ORA-01861: literal does not match format string
Hello,
I'm trying to do data mining on a web log which recorded one day web access information from a busy web server. I imported the data into Oracle Data miner, and created a table (WEBLOG). The idea is to create a new field, i.e. session, for the users so that each session could be thought as a representative of a user-intent (aka topic). Now based on this, data mining models would be used to cluster(group) the users based on their similarity. The first step is to prepare the data which involves using SQL queries. So first, all I did was to create a function for date and time. This is the following code I used,
create or replace function ssndate(p_date in varchar2 default '03-01-18',
p_time in varchar2)
return number
$if dbms_db_version.ver_le_10 $then
deterministic
$elsif dbms_db_version.ver_le_11 $then
result_cache
$end
as
begin
return trunc((to_date(p_date||' '||p_time, 'dd-mm-yy hh24:mi:ss')
- to_date('01-01-90','dd-mm-yy')) * (86400/2400));
end ssndate;
The function ssndate compiled successfully.
The next step I took was to create a view through the following query,
create or replace view WEBLOG_VIEWS
as
select (select ssndate(LOG_DATE, LOG_TIME) from dual) as "SESSION_DT",
C_IP,
CS_USER_AGENT,
(CS_URI_STEM||'?'||CS_URI_QUERY) as WEB_LINK
from WEBLOG;
This was successful as well. The problem is in the next step where I try to do data grouping.
create table FINAL_WEBLOG as
select SESSION_DT, C_IP, CS_USER_AGENT,
listagg(WEB_LINK, ' ')
within group(order by C_IP, CS_USER_AGENT) "WEB_LINKS"
from WEBLOG_VIEWS
group by C_IP, CS_USER_AGENT, SESSION_DT
order by SESSION_DT
For this, I got the error,
Error starting at line 1 in command:
create table FINAL_LOG as
select SESSION_DT, C_IP, CS_USER_AGENT,
listagg(WEB_LINK, ' ')
within group(order by C_IP, CS_USER_AGENT) "WEB_LINKS"
from WEBLOG_VIEWS
group by C_IP, CS_USER_AGENT, SESSION_DT
order by SESSION_DT
Error at Command Line:1 Column:7
Error report:
SQL Error: ORA-01861: literal does not match format string
ORA-06512: at "DMUSER.SSNDATE", line 11
ORA-06512: at line 1
01861. 00000 - "literal does not match format string"
*Cause: Literals in the input must be the same length as literals in
the format string (with the exception of leading whitespace).
If the "FX" modifier has been toggled on, the literal must
match exactly, with no extra whitespace.
*Action: Correct the format string to match the literal.
I don't know where I'm going wrong with this.. the to_date function should be fine. In the data that I possess, the date and time are in no format. Example: 30118 and 0:00:09 respectively. If anyone has any clue about this I would be sincerely grateful for any help that I can get!! It's quite urgent..
The Oracle version is 11.2.0.1.0
Edited by: 975265 on Dec 5, 2012 5:31 PM975265 wrote:
Ok.. Looks like I touched a nerve there. I apologize. I'm still a student, and this is the first time that I've tried something at this level. I'm still in the learning process, so I was hoping that someone could point me in the right direction in order to "fix" the data.Not so much touching a nerve as simply trying to implement a very very poor, but all too common, practice. Since you are a student (which we didn't know until this post) most people will cut you some slack. However, this little exchange should now be burned into your brain as you move forward. One of the very first rules of programming is to ALWAYS use the correct data types for your data. And along with that, never ever depend on implicit type conversions - always use the proper explicit conversion functions.
And as a slight follow-on, when considering the appropriate data type, don't assume that just because we refer to a given element as a 'something number' that it is indeed a number. Telephone "numbers" are NOT numbers. U.S. Social Security "numbers" are NOT numbers. U.S. Postal Zip codes are NOT numbers. All are just character strings which, by convention, we limit to the same characters we use to represent numbers.
And since this entire discussion came up around the representation of dates, you might want to take a look at http://edstevensdba.wordpress.com/2011/04/07/nls_date_format/
Now, go forth and be a smarter programmer than your peers.
Edited by: EdStevens on Dec 6, 2012 6:12 AM -
Implicit date format conversion of report column
Hello,
The following expression defines date format for report column implicitly and doesn't reflect FSP_LANGUAGE_PREFERENCE with language independent format mask of the column attribute anymore:
decode(end_date, to_date('31.12.2047', 'dd.mm.yyyy'), null, end_date) closed
end_date is of TIMESTAMP(0) WITH LOCAL TIME ZONE type, format mask of the column attribute: DS TS
Is it expected behavior?
ThanksEdward Shevtsov wrote:
Hello,
The following expression defines date format for report column implicitly and doesn't reflect FSP_LANGUAGE_PREFERENCE with language independent format mask of the column attribute anymore:
decode(end_date, to_date('31.12.2047', 'dd.mm.yyyy'), null, end_date) closed
end_date is of TIMESTAMP(0) WITH LOCAL TIME ZONE type, format mask of the column attribute: DS TS
Is it expected behavior?
ThanksThe reason might be that you compare different datatypes in the SQL statement. The output of decode depends on those parameters.
You can cast the column to a specific datatype or you make sure that your wanted datatype is used during the decode.
example
decode(end_date, to_timestamp_tz('31.12.2047', 'dd.mm.yyyy'), null, end_date) closed
or
cast(decode(end_date, to_date('31.12.2047', 'dd.mm.yyyy'), null, end_date) as timestamp(0) with local time zone) closed -
I'm looking for a quick way to take in integer such as 101500 and formatting it into a string that would display 101,500. I know that this can be done by converting to a string and doing all kinds of manipulation but I was wondering if there was a quicker/easier way of doing it.
Thanks for any help
p_snipeThis is what I came up with...
import java.io.*;
import java.text.*;
public class TestPattern
public static void main(String[] args)
System.out.print("Input Number: ");
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
String strValue = null;
try{
strValue = br.readLine();
catch(IOException ioe){
System.out.println("IO error trying to read value.");
System.exit(1);
int intValue;
intValue = Integer.parseInt(strValue);
DecimalFormat myFormatter = new DecimalFormat(###,###);
String output = myFormatter.format(intValue);
System.out.println(intValue + " " + ###,### + " " + output);
}However...the character " # " isn't allowed. However I think it specifically states the " # " as a pattern symbol. -
Breaking the string into different columns
Hi Guys,
I need to break the following string into different columns
'XXXXX.0001.09011.0001.00002.03.0004.0005.0006.00007.'
I am trying to write it using instr and substr , but having some issues .
Is there any other way to do this. If not can someone help me , below is the query that i am working on
SELECT SUBSTR ('XXXXXX.0001.09011.0001.00002.03.0004.0005.0006.00007', 1, INSTR ('XXXXXX.0001.09011.0001.00002.03.0004.0005.0006.00007', '.', 1) - 1) col1,
SUBSTR ('XXXXXX.0001.09011.0001.00002.03.0004.0005.0006.00007',
INSTR ('XXXXXX.0001.09011.0001.00002.03.0004.0005.0006.00007', '.', 1) + 1,
INSTR ('XXXXXX.0001.09011.0001.00002.03.0004.0005.0006.00007', '.', 1, 2)
- INSTR ('XXXXXX.0001.09011.0001.00002.03.0004.0005.0006.00007', '.', 1)
- 1
) col2,
SUBSTR ('XXXXXX.0001.09011.0001.00002.03.0004.0005.0006.00007',
INSTR ('XXXXXX.0001.09011.0001.00002.03.0004.0005.0006.00007', '.', -1, 2) + 1,
INSTR ('XXXXXX.0001.09011.0001.00002.03.0004.0005.0006.00007', '.', -1, 1)
- INSTR ('XXXXXX.0001.09011.0001.00002.03.0004.0005.0006.00007', '.', -1, 2)
- 1
) col3
from dual
It is very urgent.
Thanks in advance.npejavar wrote:
It is very urgent.
It doesn't look urgent, you could simply read the manuals for instr and substr or describe any issues or errors you are having, or post sample data so people could help you more easily, or format your code so it is more readable, but you don't bother to do any of those things so if it isn't important to you to extend any effort, why would it be important to us?
If it was really urgent it would be a violation of the conditions of use of these forums.
http://www.catb.org/esr/faqs/smart-questions.html#urgent
http://www.oracle.com/html/terms.html
>
4. Use of Community Services
Community Services are provided as a convenience to users and Oracle is not obligated to provide any technical support for, or participate in, Community Services. While Community Services may include information regarding Oracle products and services, including information from Oracle employees, they are not an official customer support channel for Oracle.
You may use Community Services subject to the following: (a) Community Services may be used solely for your personal, informational, noncommercial purposes; (b) Content provided on or through Community Services may not be redistributed; and (c) personal data about other users may not be stored or collected except where expressly authorized by Oracle -
Formatting the output (currency with decimals)
hi all,
i want to format the output of the currency field. Right now it displays the exact value like say 23 or 43.5 etc. But my requirement is i need it to display in a standard format as 23.00 , 43.50 , 565.00 etc. i,e if there is no decimals then it should be filled with zero's.
I have gone through some of the threads which speaks of formatting the output if it is a value node. But here i have directly bounded the table to a model node.
Domian level datatype of the field is Currency in R/3. After model import in dictionary it is showing as decimal.
How can i achieve this?I Appreciate if someone can help me on this.
Regards,
G Nidhi,
Go thru this link it might helps you.
column heading -refer to the webdynpro tutorial 34
Change the currency data type char and specify the length.
Thanks,
Lohi.
Maybe you are looking for
-
Maintenance Order confirmed to WBS element
Hi, We have an issue where in a maintenance orer was confirmed to a WBS element which is has a User Status Profile Active which does not allow "Actual Activity Allocation'', "Confirm Order" etc. but still user was able to confirm Maintenance work ord
-
Hide or show a sub-form whith check a check box
Hi, I don't know how to do this. I can't put it in "on click" because click can check or uncheck the box. Pls help me thx Nath
-
Soil texture triangle in oracle reports
Hello everybody, I need to show the soil texture triangle, example: http://courses.soil.ncsu.edu/resources/physics/texture/soiltexture.swf, in a report. The graphic depends on three parameters: sand, clay and silt Anyone knows how to do it? Anyone kn
-
I bought Photoshop Element 12 from Costco some time ago. Did not install at that time. Now I want to install but don't know which is the serial number. There is a PN number, another 10 digit number, a 18 digit number and a Lot Code. A serial numbe
-
Can I sort my i phone apps by usage?
I have 5 pages of apps and am fed up moving them around. It makes sense that I could organise them by usage or in some other order such as alphabetically... is this possible? If not, is it going to be part of iOS 7?