Color attribute in MM ?
hi everyone,
in MM nodule, how to maintain the color info. for material masters?
thanks!
Hi Edgar
Not sure if I understood your question properly. Two ways i can think of right away where you can maintain info related to color is:
1. In the material description
2. In the product hierarchy of the material
Reward points if this helps
Rgds
Similar Messages
-
CSS - Setting the color attribute of the commandMenuItem
Hello
Under the menuBar in Jdeveloper resides an item called commandMenuItem. The
color of this item always defaults to a Golden Brown Color. I can change the color
attribute under the properties navigator and it takes the new color. However I'd like to have an item in the CSS to define the color of all the commandMenuItems.
Is there a way of doing this.
Any Help will be appreciated
Regards
Kes MoodleyHi,
I am specifically interested in setting the text color of the .AFMenuBarItem. I have tried setting this color attribute in the CSS and it does not seem to take.
The reference you pointed me to refers to the background and foreground color of the menu Bar. This is different to the text color on the menu Bar.
Thanks,
Kes -
Oracle FO processor ignoring color attribute
Hello,
I have the following: <fo:inline font-weight="bold" color="red">blah</fo:inline> iin my report xml. When I use BI Publisher desktop to convert my template to pdf or html, the selected text is shown in bold but the color is not in red but black. I have tried using hex colors like #FFFFFF but this is equally ignored.
Does the oracle processor ignore the color attribute and if so is there a workaround?Do you have the code in a form field? When you say that you use BI Publisher desktop to convert my template to pdf or html, do you mean that when you preview the output you don't see the text in RED? I was able to view the text in bold and red color.
Thanks,
Bipuser -
All I am creating a visual component "bulletChart" just about
finished, it that accepts attributes one of which is a color
attribute. I would like for the developers that use the component
to be able to pass the value in, in the format of #808080 for
example for gray. When I run the application it does show up gray.
My issue is that when developing in flex builder it show up black.
the attribute data type is uint. If I set it to 0x808080 it shows
up as gray in flex builder. what is the best way to handle passing
in value like #808080 to a component and setting the color. I use a
setter to set a bindable object to the objects color attribute.
Thanks in advance for the help
Scott"texas_stingray" <[email protected]> wrote
in message
news:g8ms1o$bgc$[email protected]..
> All I am creating a visual component "bulletChart" just
about finished, it
> that
> accepts attributes one of which is a color attribute. I
would like for the
> developers that use the component to be able to pass the
value in, in the
> format of #808080 for example for gray. When I run the
application it does
> show
> up gray. My issue is that when developing in flex
builder it show up
> black. the
> attribute data type is uint. If I set it to 0x808080 it
shows up as gray
> in
> flex builder. what is the best way to handle passing in
value like #808080
> to a
> component and setting the color. I use a setter to set a
bindable object
> to the
> objects color attribute.
This might be helpful
http://blogs.digitalprimates.net/codeSlinger/index.cfm/2007/4/9/Ah-design-view -
Hi,
I want to assign different colors for planned orders in planning board using pp/ds planning board decision table, so that if I make a field in extra tab of Product master data to represent a color say red, the order in planning board will be displayed in red for that product. Have anyone configured the planning board objects (operation) with different colors according to the product attribute field? Appreciate your help.
Thanks,
AndyHi,
I will give you one example. Follow following steps
1. Define value of freely defineable attribute as RED in product master
2. Go to planning board profile copy standarad planning board profile SAP001
3. select graphical object id ORD_DEF_1 copy it and give new name ex-Red
4. Select graphical element for new graphical object ID red RED and change the colour of element to red.
5. Double click charts, select the chart for which you want to display orders in different colours
6. Then double click on decision table for graphical objects click on new entries keep decision group and step as 0 or 1
select table name 4 click on field selection and select feild freely defineable attribute
select relational operatior as eq compar value =red
then graphical object id=Red.
Regards,
Santosh -
Could PlainDocument set Foreground Color Attribute?
PlainDocument class has a method called
insertString(int pos,String str,AttributeSet a)
It looks like we could add attributes to PlainDocument ,but
when I assign it a Attribute Set ,the foreground color doesn't
change, could anyone tell me how to change attributes
in PlainDocument?
Thanks a lot!
CatonYes, I tried these two already,but it still doesn,t work.
I found whether I use JEditorPane or JTextPane ,it does not change anything.
In the subclass of the JEditorPane ,called SubEditorPane, I write the code
setContentType("text/plain"); -->to get the DefaultEditor instance for SubEditorPane
PlainDocument doc = (PlainDocument)getEditorKit().createDefaultDocument();
-->to get PlainDocument instance
then I use doc.insertString(0,"This is a Test Words",style);
where the style is a NamedStyle instance :
StyleContext sct = new StyleContext();
Style style = sct.addStyle("test",null);
style.addAttribute(StyleConstants.Foreground,Color.blue);
But it doesn't change anything :foreground color is still black!!
I don't know where I do the wrong thing ,style instance or else ?
Thanks!
Caton -
How to use a variable to specify the color when setting an attribute
Hi
We are using BI Publisher (XDO) embedded in e-Business Suite. So we are effectively on version 5.6.3.
I would like to conditionally set the background-color attribute of cells in a table by using a variable reference; something like this (the ways in which I have tried):
<?attribute@incontext:background-color;$exEmpBGColor?>
<?attribute@incontext:background-color;'{$exEmpBGColor}'?>
The 'standard' way of doing this would be:
<?attribute@incontext:background-color;'#CCCCFF'?>
Can anybody please help? (i.e. is this even possible?)Thanks that works.
I was using a variable, so I adapted your example to use the variable, not an element.
<xsl:attribute xdofo:ctx="block" name="background-color"><xsl:value-of select='$exEmpBackgroundColour' /></xsl:attribute>
Regards -
How can I make a color box indicator transparent?
All, I would like to make a color box, which is part of a cluster in an array, transparent programmatically. Instead of appearing transparent, it shows up with a LARGE "T" inside the color box, with a white background. Because it is part of a cluster within an array, it will not work to use a property node... and because I would like to programmatically change the color, having it permanenty transparent (as proposed on another discussion topic) will also not work. Can someone please help me turn a color box transparent programmatically?
Thanks.
AnthonyThe problem is that arrays of clusters cannot be passed into property nodes as falkpl has previously said. The attached jpeg shows how you would programmatically break the arrays into cluster, into elements, and then manipulate that color box to a transparent one. The T within the white color box indicates transparent though. If you were to attached that to a color attribute then you would see that object disappear (well I guess not since it's transparent )
Grant H.
National Instruments
LabVIEW Product Marketing Manager
Attachments:
color box.JPG 21 KB -
Is it possible to change the color of a layer of a Customs CSS from an External Style sheet?
Hi,
I have sucessfully link External .css file to my HTML page and able to change the font size of the headlines and the paragraph.
What I am not able to do is to ADD the color my Custom CSS from the External sheet. I have difined the color attribute as a 'Advance'
and gave it the same name "#bigwraper" that is has in my HTML file.
Attached is the color outline of my 'Blank Layout' with colors?
Thank you.
Dreamer101.1Hi Murray,
I am building a web site on which the entire content would be changed at least daily. The website would have similar design to www.Helium.com
The page will have CCS layout boxes in which different content would be pasted.
To re-phrase my question: I want to know how to change the color of a layer from an external style sheet?
Because my home page 'Sidebar' and colors would be the same for all page, only the content of different pages would be different. If I want to change a color of my web side pages, I need to learn how to do it in one spot through an External Style Sheet.
I am amble to link my external style sheet and to change H1 tag and to give it different colors. But I was not sucess with change the color of a layer on which my content sits around.
I took out the color from my HTML page and gave the same name to the layer in my External Style Sheet with the same color.
Hope my question and the reason I was able to clarify.
cheers,
Dreamer101.1 -
When I copy a vector shape from one layer to another, the shape picks up the color attributes of an existing shape in the second layer (or sometimes only the outline of the shape appears). What to I do to avoid this from happening (I just just want to paste the shape in its original form and color)?
OK - I guess this is a little more difficult than I imagined...
Merge Layers rasterizes all the vector shapes - I want all the shapes to stay as vectors in the second (pasted) layer.
Merge Shapes changes the color of the copied vector shape - I don't want to change the color
Shape Layer via Copy [Ctrl] +[J] copies the layer containing the vector shape, but doesn't paste it into the second layer
Any other ideas? Or, is it possible that PhotoShop doesn't support varied colored vector shapes on the same layer? I am coming from an InDesign background, and there was no issue having many different (colored) vector objects on the same layer. -
Is there a way to create QR codes through Enhanced Datamerge in color rather than black?
Trying to find a way to create QR codes through the data merge feature in a color other than black. The only way I know to attempt it is to try to give the placeholder a color attribute, but no matter what I try the QR codes generated come in as black. Wondering if there is a way to color them, like you can when you just generate an individual QR code.
aggieweather,
See the following post. I think should help out. Thanks!
Chris C
Applications Engineering
National Instruments
Chris Cilino
National Instruments
LabVIEW Product Marketing Manager
Certified LabVIEW Architect -
How to change the color of specific row in ALV tree
Hi,
I m using method set_table_for_first_display of a class CL_GUI_ALV_TREE.
The req is to change the color of specific row. Now can anybody tell me how to change the color of ALV tree. As in ALV tree and in this method 'set_table_for_first_display', there is no parameter IS_Layout.
Pls suggest...hi
hope this code will help you.
Reward if help.
REPORT zsharad_test1.
TABLES: ekko.
TYPE-POOLS: slis. "ALV Declarations
*Data Declaration
TYPES: BEGIN OF t_ekko,
ebeln TYPE ekpo-ebeln,
ebelp TYPE ekpo-ebelp,
statu TYPE ekpo-statu,
aedat TYPE ekpo-aedat,
matnr TYPE ekpo-matnr,
menge TYPE ekpo-menge,
meins TYPE ekpo-meins,
netpr TYPE ekpo-netpr,
peinh TYPE ekpo-peinh,
line_color(4) TYPE c, "Used to store row color attributes
END OF t_ekko.
DATA: it_ekko TYPE STANDARD TABLE OF t_ekko INITIAL SIZE 0,
wa_ekko TYPE t_ekko.
*ALV data declarations
DATA: fieldcatalog TYPE slis_t_fieldcat_alv WITH HEADER LINE,
gd_tab_group TYPE slis_t_sp_group_alv,
gd_layout TYPE slis_layout_alv,
gd_repid LIKE sy-repid.
*Start-of-selection.
START-OF-SELECTION.
PERFORM data_retrieval.
PERFORM build_fieldcatalog.
PERFORM build_layout.
PERFORM display_alv_report.
*& Form BUILD_FIELDCATALOG
Build Fieldcatalog for ALV Report
FORM build_fieldcatalog.
There are a number of ways to create a fieldcat.
For the purpose of this example i will build the fieldcatalog manualy
by populating the internal table fields individually and then
appending the rows. This method can be the most time consuming but can
also allow you more control of the final product.
Beware though, you need to ensure that all fields required are
populated. When using some of functionality available via ALV, such as
total. You may need to provide more information than if you were
simply displaying the result
I.e. Field type may be required in-order for
the 'TOTAL' function to work.
fieldcatalog-fieldname = 'EBELN'.
fieldcatalog-seltext_m = 'Purchase Order'.
fieldcatalog-col_pos = 0.
fieldcatalog-outputlen = 10.
fieldcatalog-emphasize = 'X'.
fieldcatalog-key = 'X'.
fieldcatalog-do_sum = 'X'.
fieldcatalog-no_zero = 'X'.
APPEND fieldcatalog TO fieldcatalog.
CLEAR fieldcatalog.
fieldcatalog-fieldname = 'EBELP'.
fieldcatalog-seltext_m = 'PO Item'.
fieldcatalog-col_pos = 1.
APPEND fieldcatalog TO fieldcatalog.
CLEAR fieldcatalog.
fieldcatalog-fieldname = 'STATU'.
fieldcatalog-seltext_m = 'Status'.
fieldcatalog-col_pos = 2.
APPEND fieldcatalog TO fieldcatalog.
CLEAR fieldcatalog.
fieldcatalog-fieldname = 'AEDAT'.
fieldcatalog-seltext_m = 'Item change date'.
fieldcatalog-col_pos = 3.
APPEND fieldcatalog TO fieldcatalog.
CLEAR fieldcatalog.
fieldcatalog-fieldname = 'MATNR'.
fieldcatalog-seltext_m = 'Material Number'.
fieldcatalog-col_pos = 4.
APPEND fieldcatalog TO fieldcatalog.
CLEAR fieldcatalog.
fieldcatalog-fieldname = 'MENGE'.
fieldcatalog-seltext_m = 'PO quantity'.
fieldcatalog-col_pos = 5.
APPEND fieldcatalog TO fieldcatalog.
CLEAR fieldcatalog.
fieldcatalog-fieldname = 'MEINS'.
fieldcatalog-seltext_m = 'Order Unit'.
fieldcatalog-col_pos = 6.
APPEND fieldcatalog TO fieldcatalog.
CLEAR fieldcatalog.
fieldcatalog-fieldname = 'NETPR'.
fieldcatalog-seltext_m = 'Net Price'.
fieldcatalog-col_pos = 7.
fieldcatalog-outputlen = 15.
fieldcatalog-datatype = 'CURR'.
APPEND fieldcatalog TO fieldcatalog.
CLEAR fieldcatalog.
fieldcatalog-fieldname = 'PEINH'.
fieldcatalog-seltext_m = 'Price Unit'.
fieldcatalog-col_pos = 8.
APPEND fieldcatalog TO fieldcatalog.
CLEAR fieldcatalog.
ENDFORM. " BUILD_FIELDCATALOG
*& Form BUILD_LAYOUT
Build layout for ALV grid report
FORM build_layout.
gd_layout-no_input = 'X'.
gd_layout-colwidth_optimize = 'X'.
gd_layout-totals_text = 'Totals'(201).
Set layout field for row attributes(i.e. color)
gd_layout-info_fieldname = 'LINE_COLOR'.
gd_layout-totals_only = 'X'.
gd_layout-f2code = 'DISP'. "Sets fcode for when double
"click(press f2)
gd_layout-zebra = 'X'.
gd_layout-group_change_edit = 'X'.
gd_layout-header_text = 'helllllo'.
ENDFORM. " BUILD_LAYOUT
*& Form DISPLAY_ALV_REPORT
Display report using ALV grid
FORM display_alv_report.
gd_repid = sy-repid.
CALL FUNCTION 'REUSE_ALV_LIST_DISPLAY'
EXPORTING
i_callback_program = gd_repid
i_callback_top_of_page = 'TOP-OF-PAGE' "see FORM
i_callback_user_command = 'USER_COMMAND'
i_grid_title = outtext
is_layout = gd_layout
it_fieldcat = fieldcatalog[]
it_special_groups = gd_tabgroup
IT_EVENTS = GT_XEVENTS
i_save = 'X'
is_variant = z_template
TABLES
t_outtab = it_ekko
EXCEPTIONS
program_error = 1
OTHERS = 2.
IF sy-subrc <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
ENDFORM. " DISPLAY_ALV_REPORT
*& Form DATA_RETRIEVAL
Retrieve data form EKPO table and populate itab it_ekko
FORM data_retrieval.
DATA: ld_color(1) TYPE c.
SELECT ebeln ebelp statu aedat matnr menge meins netpr peinh
UP TO 10 ROWS
FROM ekpo
INTO TABLE it_ekko.
*Populate field with color attributes
LOOP AT it_ekko INTO wa_ekko.
Populate color variable with colour properties
Char 1 = C (This is a color property)
Char 2 = 3 (Color codes: 1 - 7)
Char 3 = Intensified on/off ( 1 or 0 )
Char 4 = Inverse display on/off ( 1 or 0 )
i.e. wa_ekko-line_color = 'C410'
ld_color = ld_color + 1.
Only 7 colours so need to reset color value
IF ld_color = 8.
ld_color = 1.
ENDIF.
CONCATENATE 'C' ld_color '10' INTO wa_ekko-line_color.
wa_ekko-line_color = 'C410'.
MODIFY it_ekko FROM wa_ekko.
ENDLOOP.
ENDFORM. " DATA_RETRIEVAL -
HOW TO CHANGE COLOR OF PARTICULAR CELL IN ALV
I HAVE DISPLAYED A REPORT IN ALV
I WANT TO CHANGE THE COLOR OF VBELN FIELD ON WHICH HOTSPOT IS ON?
HOW TO DO THIS?Hi Lovleen,
Check out the code
*& Report ZDEMO_ALVGRID *
*& Example of a simple ALV Grid Report *
*& The basic ALV grid, Enhanced to display each row in a different *
*& colour *
REPORT zdemo_alvgrid .
TABLES: ekko.
type-pools: slis. "ALV Declarations
*Data Declaration
TYPES: BEGIN OF t_ekko,
ebeln TYPE ekpo-ebeln,
ebelp TYPE ekpo-ebelp,
statu TYPE ekpo-statu,
aedat TYPE ekpo-aedat,
matnr TYPE ekpo-matnr,
menge TYPE ekpo-menge,
meins TYPE ekpo-meins,
netpr TYPE ekpo-netpr,
peinh TYPE ekpo-peinh,
line_color(4) type c, "Used to store row color attributes
END OF t_ekko.
DATA: it_ekko TYPE STANDARD TABLE OF t_ekko INITIAL SIZE 0,
wa_ekko TYPE t_ekko.
*ALV data declarations
data: fieldcatalog type slis_t_fieldcat_alv with header line,
gd_tab_group type slis_t_sp_group_alv,
gd_layout type slis_layout_alv,
gd_repid like sy-repid.
*Start-of-selection.
START-OF-SELECTION.
perform data_retrieval.
perform build_fieldcatalog.
perform build_layout.
perform display_alv_report.
*& Form BUILD_FIELDCATALOG
Build Fieldcatalog for ALV Report
form build_fieldcatalog.
There are a number of ways to create a fieldcat.
For the purpose of this example i will build the fieldcatalog manualy
by populating the internal table fields individually and then
appending the rows. This method can be the most time consuming but can
also allow you more control of the final product.
Beware though, you need to ensure that all fields required are
populated. When using some of functionality available via ALV, such as
total. You may need to provide more information than if you were
simply displaying the result
I.e. Field type may be required in-order for
the 'TOTAL' function to work.
fieldcatalog-fieldname = 'EBELN'.
fieldcatalog-seltext_m = 'Purchase Order'.
fieldcatalog-col_pos = 0.
fieldcatalog-outputlen = 10.
fieldcatalog-emphasize = 'X'.
fieldcatalog-key = 'X'.
fieldcatalog-do_sum = 'X'.
fieldcatalog-no_zero = 'X'.
append fieldcatalog to fieldcatalog.
clear fieldcatalog.
fieldcatalog-fieldname = 'EBELP'.
fieldcatalog-seltext_m = 'PO Item'.
fieldcatalog-col_pos = 1.
append fieldcatalog to fieldcatalog.
clear fieldcatalog.
fieldcatalog-fieldname = 'STATU'.
fieldcatalog-seltext_m = 'Status'.
fieldcatalog-col_pos = 2.
append fieldcatalog to fieldcatalog.
clear fieldcatalog.
fieldcatalog-fieldname = 'AEDAT'.
fieldcatalog-seltext_m = 'Item change date'.
fieldcatalog-col_pos = 3.
append fieldcatalog to fieldcatalog.
clear fieldcatalog.
fieldcatalog-fieldname = 'MATNR'.
fieldcatalog-seltext_m = 'Material Number'.
fieldcatalog-col_pos = 4.
append fieldcatalog to fieldcatalog.
clear fieldcatalog.
fieldcatalog-fieldname = 'MENGE'.
fieldcatalog-seltext_m = 'PO quantity'.
fieldcatalog-col_pos = 5.
append fieldcatalog to fieldcatalog.
clear fieldcatalog.
fieldcatalog-fieldname = 'MEINS'.
fieldcatalog-seltext_m = 'Order Unit'.
fieldcatalog-col_pos = 6.
append fieldcatalog to fieldcatalog.
clear fieldcatalog.
fieldcatalog-fieldname = 'NETPR'.
fieldcatalog-seltext_m = 'Net Price'.
fieldcatalog-col_pos = 7.
fieldcatalog-outputlen = 15.
fieldcatalog-datatype = 'CURR'.
append fieldcatalog to fieldcatalog.
clear fieldcatalog.
fieldcatalog-fieldname = 'PEINH'.
fieldcatalog-seltext_m = 'Price Unit'.
fieldcatalog-col_pos = 8.
append fieldcatalog to fieldcatalog.
clear fieldcatalog.
endform. " BUILD_FIELDCATALOG
*& Form BUILD_LAYOUT
Build layout for ALV grid report
form build_layout.
gd_layout-no_input = 'X'.
gd_layout-colwidth_optimize = 'X'.
gd_layout-totals_text = 'Totals'(201).
Set layout field for row attributes(i.e. color)
gd_layout-info_fieldname = 'LINE_COLOR'.
gd_layout-totals_only = 'X'.
gd_layout-f2code = 'DISP'. "Sets fcode for when double
"click(press f2)
gd_layout-zebra = 'X'.
gd_layout-group_change_edit = 'X'.
gd_layout-header_text = 'helllllo'.
endform. " BUILD_LAYOUT
*& Form DISPLAY_ALV_REPORT
Display report using ALV grid
form display_alv_report.
gd_repid = sy-repid.
call function 'REUSE_ALV_GRID_DISPLAY'
exporting
i_callback_program = gd_repid
i_callback_top_of_page = 'TOP-OF-PAGE' "see FORM
i_callback_user_command = 'USER_COMMAND'
i_grid_title = outtext
is_layout = gd_layout
it_fieldcat = fieldcatalog[]
it_special_groups = gd_tabgroup
IT_EVENTS = GT_XEVENTS
i_save = 'X'
is_variant = z_template
tables
t_outtab = it_ekko
exceptions
program_error = 1
others = 2.
if sy-subrc <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
endif.
endform. " DISPLAY_ALV_REPORT
*& Form DATA_RETRIEVAL
Retrieve data form EKPO table and populate itab it_ekko
form data_retrieval.
data: ld_color(1) type c.
select ebeln ebelp statu aedat matnr menge meins netpr peinh
up to 10 rows
from ekpo
into table it_ekko.
*Populate field with color attributes
loop at it_ekko into wa_ekko.
Populate color variable with colour properties
Char 1 = C (This is a color property)
Char 2 = 3 (Color codes: 1 - 7)
Char 3 = Intensified on/off ( 1 or 0 )
Char 4 = Inverse display on/off ( 1 or 0 )
i.e. wa_ekko-line_color = 'C410'
ld_color = ld_color + 1.
Only 7 colours so need to reset color value
if ld_color = 8.
ld_color = 1.
endif.
concatenate 'C' ld_color '10' into wa_ekko-line_color.
wa_ekko-line_color = 'C410'.
modify it_ekko from wa_ekko.
endloop.
endform. " DATA_RETRIEVAL
Regards,
Chandru -
Row coloring in WD table (not ALV) based on condition
HI All,
I have created WD table with 8 columns
8 Th columns is “color “ type wdui_table_cell_desgin
All 7 are bounded to table except color.
Depending on my condition I am passing the domain values colors
Loop at itab into WA.
Ex: if wa-abc = ‘ABC’.
Wa-color = 27
Modify statement …….
End loop.
I followed the below link .
http://www.sdn.sap.com/irj/scn/go/portal/prtroot/docs/library/uuid/707fb792-c181-2d10-61bd-ce15d58b5cf1?quicklink=index&overridelayout=true
My problem is WD Table row is not coloring, any suggestion or related links
Will be awarded. If iam in wrong way please correct me.
Thanks
GopalHi Gopal,
There are two posibilities that, your Table row/cell coloring is not working
1:
Make sure that you have bound the columns "CellDesign" property to COLOR attribute as below
Note: If you need to color whole ROW, then you need to bind the cellDesign of all columns to COLOR, otherwise, only respective cells gets colored.
2. Make sure that the property "Design" of table should not be set to "ALTERNATING", because it overrides the color. Hence, set the design of table to "standard"
Hope this resolves your issue.
Regards,
Rama -
How to print diffrent color and diffrent size of text in JTextArea ?
Hello All,
i want to make JFrame which have JTextArea and i append text in
JTextArea in diffrent size and diffrent color and also with diffrent
fonts.
any body give me any example or help me ?
i m thanksfull.
Arif.You can't have multiple text attributes in a JTextArea.
JTextArea manages a "text/plain" content type document that can't hold information about attributes ( color, font, size, etc.) for different portions of text.
You need a component that can manage styled documents. The most basic component that can do this is JEditorPane. It can manage the following content types :
"text/rtf" ==> via StyledDocument
"text/html" ==> via HTMLDocument
I've written for you an example of how a "Hello World" string could be colorized in a JEditorPane with "Hello" in red and "World" in blue.
import javax.swing.JEditorPane;
import javax.swing.text.StyleConstants;
import javax.swing.text.StyledEditorKit;
import javax.swing.text.StyledDocument;
import javax.swing.text.MutableAttributeSet;
import javax.swing.text.SimpleAttributeSet;
import java.awt.Color;
public class ColorizeTextTest{
public static void main(String args[]){
//build gui
JFrame frame = new JFrame();
JEditorPane editorPane = new JEditorPane();
frame.getContentPane().add(editorPane);
frame.pack();
frame.setVisible(true);
//create StyledEditorKit
StyledEditorKit editorKit = new StyledEditorKit();
//set this editorKit as the editor manager [JTextComponent] <-> [EditorKit] <-> [Document]
editorPane.setEditorKit(editorKit);
StyledDocument doc = (StyledDocument) editorPane.getDocument();
//insert string "Hello World"
//this text is going to be added to the StyledDocument with positions 0 to 10
editorPane.setText("Hello World");
//create and attribute set
MutableAttributeSet atr = new SimpleAttributeSet();
//set foreground color attribute to RED
StyleConstants.setForeground(atr,Color.RED);
//apply attribute to the word "Hello"
int offset = 0; //we want to start applying this attribute at position 0
int length = 5; //"Hello" string has a length of 5
boolean replace = false; //should we override any other attribute not specified in "atr" : anwser "NO"
doc.setCharacterAttributes(offset,length,atr,replace);
//set foreground color attribute to BLUE
StyleConstants.setForeground(atr,Color.BLUE);
//apply attribute to the word "World"
offset = 5; //we include the whitespace
length = 6;
doc.setCharacterAttributes(offset,length,atr,replace);
}
Maybe you are looking for
-
New Data is not available in reporting after revrse posting
Hello All I have a cube and data loaded into it.Now i came to know that one request is having wrong data and need to be deleted,without deleting I did reverse posting.Now that particular data(means new data) is not available in reporting.The reportin
-
Ipod not recognized in itunes, stuck in recovery mode (tried everything)
I've had my ipod touch for about a year now, and the other day itunes told me I needed to download the new software and such. FYI, I use Vista (unfortunately. Probably not helping with the problem). I am aware that this is a common problem. I have *t
-
Help sought customizing a SP 2010 custom list template
I am forced to use InfoPath 2010 to edit and then publish the form for a custom list, due to problems that SP 2010 has displaying a set of lookup columns on the form. Now that I have made the initial change, there are some other customizations that t
-
How to combine the radio buttons in different panels
Hello everyone.I have to have some form of panels, each of which I want to put a radio button. How to make sure that when you select one of the radio buttons, the second was not selected ? Now both are selected. For convenience, made a small example.
-
ORA-00600 while starting the SOA suite soa_server1
Hi we are getting following error on soa weblogic server log soa_server1 as well as in the database alert log when ever we do startup of the soa_server1. This is consistent during every startup. But not repeating in the log after that. Any one seen t