Set color for selected item?

i was wondering if it is possible to setBackground and setForeground for JMenu, JMenuItems or any items that are selected? I know it is possible for JList because it has the function setSelectionBackground and setSelectionForeground but are there any functions that do that for these classes?

This was originally posted by xhunterx:
The fastest way I know to change that property for all instances of a JMenu or JMenuItem in an application is to simply change the UIDefaults for that property via UIManager.<I>put()</I>. Try this (changes the selection background for both menu and menuitems to Color.green):
<pre>import java.awt.*;
import javax.swing.*;
<br>
public class MenuDemo extends JFrame
public MenuDemo() throws Exception
UIManager.put("Menu.selectionBackground", new javax.swing.plaf.ColorUIResource(Color.green));
UIManager.put("MenuItem.selectionBackground", new javax.swing.plaf.ColorUIResource(Color.green));
<br>
JMenuBar menuBar = new JMenuBar();
JMenu menuOne = new JMenu("One");
JMenu menuTwo = new JMenu("Two");
JMenuItem itemOne = new JMenuItem("One Sub One");
menuOne.add(itemOne);
menuBar.add(menuOne);
menuBar.add(menuTwo);
getContentPane().add(menuBar,"North");
setSize(200,200);
setVisible(true);
<br>
public static void main(String args[]) throws Exception { new MenuDemo(); }
}</pre>
- Mark

Similar Messages

  • Setting custom color for selected node in JTree?

    Hi,
    i want to set my own color for selected node in JTree. i don't want to set for all the nodes...how to set Color for Selected node using TreeCellRender class?
    Thanks
    Mani

    I assume you are not setting a custom tree cell renderer...
    javax.swing.JTree theTree = ...;
    java.awt.Color newBGColor = ...;
    ((javax.swing.tree.DefaultTreeCellRenderer)theTree.getCellRenderer())
        .setBackgroundSelectionColor(newColor);

  • How to set background color for selected days in DateChooser

    How to set background color for selected days. I created
    checkbox for each day [Son,Mon,Tue,Wed,Thu,Fri,Sat] and a
    DateChooser, I want to change the background color for the selected
    day when i click on a button after selecting the desired checkboxs
    [ monthly wise/yearly wise]
    Thanks in advance

    There is no button involved in the following code, but it may
    be of use to you:
    <?xml version="1.0"?>
    <mx:Application xmlns:mx="
    http://www.adobe.com/2006/mxml"
    creationComplete="init()">
    <mx:Script>
    <![CDATA[
    private var origColor:uint;
    private function init():void {
    origColor = dc.getStyle("selectionColor");
    public function setBackGrdColors(newColor:uint):void {
    dc.setStyle("selectionColor", origColor);
    if(dc.selectedDate){
    var dayOfWeek:Number = dc.selectedDate.day;
    else{
    return;
    switch(dayOfWeek) {
    case 0:
    if(sun.selected)
    dc.setStyle("selectionColor", newColor);
    break;
    case 1:
    if(mon.selected)
    dc.setStyle("selectionColor", newColor);
    break;
    case 2:
    if(tue.selected)
    dc.setStyle("selectionColor", newColor);
    break;
    case 3:
    if(wed.selected)
    dc.setStyle("selectionColor", newColor);
    break;
    case 4:
    if(thu.selected)
    dc.setStyle("selectionColor", newColor);
    break;
    case 5:
    if(fri.selected)
    dc.setStyle("selectionColor", newColor);
    break;
    case 6:
    if(sat.selected)
    dc.setStyle("selectionColor", newColor);
    break;
    default:
    break;
    ]]>
    </mx:Script>
    <mx:VBox horizontalAlign="center" verticalGap="20">
    <mx:DateChooser id="dc" textAlign="left"
    change="setBackGrdColors(cellColor.selectedColor)"/>
    <mx:HBox width="100%" horizontalAlign="center">
    <mx:CheckBox id="sun" label="Sun"/>
    <mx:CheckBox id="mon" label="Mon"/>
    <mx:CheckBox id="tue" label="Tue"/>
    <mx:CheckBox id="wed" label="Wed"/>
    </mx:HBox>
    <mx:HBox width="100%" horizontalAlign="center">
    <mx:CheckBox id="thu" label="Thu"/>
    <mx:CheckBox id="fri" label="Fri"/>
    <mx:CheckBox id="sat" label="Sat"/>
    </mx:HBox>
    <mx:HBox width="300" horizontalAlign="center">
    <mx:Label text="Background Color" />
    <mx:ColorPicker id="cellColor"
    selectedColor="#FF00FF"/>
    </mx:HBox>
    </mx:VBox>
    </mx:Application>

  • A quick way to set different color for certain items in JList?

    is there a quick way of setting different color for certain items in JList?

    Either use HTML strings as the values in your JList (quickest, but may not be the most convenient, especially if your model isn't just text), or create your own ListCellRenderer (e.g. extend DefaultListCellRenderer).
    There is no such thing as "list.setItemForeground(int index, Color c)". You'll have to use one of the methods above.

  • Javabean for colorpicker to select color for form item

    1- copy the colorpicker.jar in your /forms/java directory
    2 - update the archive and archive_jini tags of your /forms/server/formsweb.cfg file:
    archive_jini=frmall_jinit.jar,colorpicker.jar
    archive=frmall.jar,colorpicker.jar
    3 - in your form, add a Bean Area in a block - bean name = 'bean'
    4 - initialize the bean in a When-New-Form-Instance trigger:
    FBean.Register_Bean('block.bean',1,'oracle.forms.demos.beans.ColorPicker');
    5 - pick the color anywhere you want:
    PROCEDURE PickColor(pvcTarget in VARCHAR2) IS
    vcColor VARCHAR2(11 char);
    BEGIN
    -- now display the picker with that color as an initial value
    vcColor := FBean.Invoke_char('block.bean',1,'showColorPicker','Select color','');
    END;
    I will follow these steps and colorpicker is shown but i want to select the color for form item such as text item , canvas etc.
    I want when i select the color from colorpicker that color is assign to that item. such as changing the background color and foreground color of text item.
    I need help about this.
    How i solve this problem.
    need code.

    Hello,
    Once you get the color, you can apply it to the item with the Set_Item_Property() built-in (see the online doc).
    Francois

  • How can i change the color of selected item in combo box, the selected item color is same as accent color, i want to change this to custom color

    <Page
    x:Class="App1.MainPage"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:local="using:App1"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    mc:Ignorable="d"
    Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">
    <Grid Background="White">
    <ComboBox HorizontalAlignment="Left"
    BorderBrush="Black"
    Foreground="Black"
    Margin="80,272,0,0" VerticalAlignment="Top" Width="205" Style="{StaticResource BorderColor}">
    <ComboBoxItem Content="One" IsSelected="True"/>
    <ComboBoxItem Content="Two"/>
    <ComboBoxItem Content="Three"/>
    <ComboBoxItem Content="Four"/>
    <ComboBoxItem Content="Five"/>
    </ComboBox>
    </Grid>
    </Page>

    Hi,
    you can open the project in blend and then select the combobox for get the default style for combobox and for selected item . Please reference the
    set combobox style.
    Or see
    quickstart: Styling controls topic to deep understand it.
    Hope helpful for you.
    --Simon
    True mastery of any skill takes a lifetime.

  • Item availability for selected items and directly create the delivery

    Hi All,
    For a very big sales order ..lets say having 700 line items ...is there any convenient way to create the delivery for selected items ..e.g. 30-40 line items rather going and selecting the line items then doing the item availability.
    do you have any LSMW format by which we can do the item availability for selected items and directly create the delivery.
    kindly Guide me..
    With Regards
    Azeez.Mohd

    Hi ,
    There is no stand way of doing it . You need to take help of abaper to do this :
    1. Create a t code where if you give sale order number , it displays a report with all the items with a check box near to it as we see in SE16 .
    2. This report could be best in ALV form where users can do "ctr+f" and search only the required materials then select those lines and press a button on the top of report .
    3. Once the button is pressed , program will run vL01n ( create delv in backgrnd) in a BDC form . At time of delev creating , the bdc program in backgrnd uses only those items which were selected by user and not the other items .
    4. Program will create a delv using a BDC in background and return the delv number for user to view tht.
    U can also try using FM : RV_DELIVERY_CREATE to create delv in backgrnd after user selection if BDC is getting tricky.
    Hopefully ,this shuld work and will be a easy process for the customers.
    Let us know the outcome .. .
    B O L ..
    Hope this Helps !!!

  • To set color for barchart having datetime column

    Hi,
       I have a datetime column in the XSD,
    I was trying to set colors for the barchart through,  chart expert --> colorhighlight  ,here in  colorhighlight when i click on new I am getting a dialogue box asking to enter datetime in M:D:YYYY H:MM:SS TT format. why is this dialogue displayed ? How to overcome this.
    Regards,
    Deepa V

    Hi Deepa
    Please inform us with the following information:
    1: What is the version of Crysatl Reports that you are using?
    2: What is the Chart Type that you are uisng?
    3: Where are you placing this chart in the report?
    Regards
    Ashwini Yadav

  • Sourcing: Propose sources for selected items

    Hi
    I am running SRM 7.0 in classic scenario - for now in a demo environment. I try to figure out how the sourcing work if I have contracts.
    I creates a central service contract in SRM. This is not replicated to backend at the moment but do it have to be replicated to backend to be proposed as source for my shopping cart in the sourcing cockpit?
    I have created a contract in backend (and only in backend) and this is visible in "Propose sources for selected items"
    Another issue I have is in the following process.
    1. A user creates a SC with a service item (text item)
    2. This goes to Purchasers worklist
    3. Purchaser creates RFx and select bidders
    4. The bidders respond
    5. The Purchaser select the best offer and creates a contract.
    6. The SC is not possible to order anymore so the Purchaser creates a copy of the original SC (on behalf of the user who create  the SC in the first place).
    7. I expect that the contract I created in bullet 5 would be proposed as source of supply in the new SC but it isn´t :-(
    I therefore wondering if it is because the contracts is not replicated to backend at the moment?
    Note:
    I order a text service item and I have filled the Supplier Part number in both the contract and SC but this do not help.
    Hope anyone can help me

    Hello,
    If you are using classic scenario, only backend contracts will be proposed as SOS.
    This means that if you create a central contract in SRM, it should be replicated to ECC in order to be used as source of supply.
    SRM contracts can be used as SOS only in case of extended classic and local scenarios.
    Regards,
    Ricardo

  • Color for each item ring

    Hello,
    Is it possible to assign a different color for each item in a ring control ? See what I start in attached file.
    Thanks
    Attachments:
    enumeration_avec_couleur.vi ‏8 KB

    Attached is the LV 8.0 version.  I also added a control as described by Evan because I hadn't thought of it originally, but it is probably the best option -- it places text on color and doesn't require a loop to update.
    David C
    Applications Engineering
    Attachments:
    enumeration_avec_couleur2.vi ‏74 KB
    Control 2.ctl ‏6 KB

  • How to set color for a tabstrip in BSP

    Hello all,
    Can anyone please let me know how to set color for a tabstripn in BSP?
    I am using the below syntax but it still gives me the default color.
    <htmlb:content design="design2003" >
      <htmlb:page title="test " >
        <htmlb:form>
    <htmlb:tabStrip id         = "TabStrip"
                          bodyHeight = "200"
                          bodyColor  = "red"
                          width      = "700" >
    </htmlb:tabStrip>
    </htmlb:form>
      </htmlb:page>
    </htmlb:content>
    Thanks,
    Sandeep

    Hi...
    The below code is working fine for me...
    <%@page language="abap" %>
    <%@extension name="htmlb" prefix="htmlb" %>
    <htmlb:content design="design2003" >
      <htmlb:page title="stg " >
        <htmlb:form>
          <htmlb:tabStrip width      = "430"
                          bodyColor  = "rgb(88,5,64)"
                          id         = "t1"
                          bodyHeight = "112" >
            <htmlb:tabStripItem id      = "t1"
                                index   = "1"
                                title   = "Sales"
                                tooltip = "My Tooltip for Tab 1" >
              <htmlb:textView text="Tab N 1" />
              <htmlb:tree id        = "treeReports"
                          showTitle = "true"
                          table2    = "<%= mt_nodes %>"
                          title     = "Menu"
                          width     = "100%" />
            </htmlb:tabStripItem>
            <htmlb:tabStripItem id      = "t2"
                                index   = "2"
                                title   = "Production"
                                tooltip = "My Tooltip for Tab 2" >
              <htmlb:textView text="Tab N 2" />
            </htmlb:tabStripItem>
          </htmlb:tabStrip>
        </htmlb:form>
      </htmlb:page>
    </htmlb:content>

  • Setting Color for Records in forms6i

    Dear All
    How can I set color for particular records on a form. i.e. Set the color of all employees whose salary is greater than 2000 to Red and All the rest to Green
    Solomon

    Hello,
    6i is an old version and I don't remember if there is a Set_Item_Instance_Property() built-in. If yes, you can use it with a Visual Attribute that held the colors.
    Francois

  • How set color for a ValidationTextField's hint?

    I want to set color for a ValidationTextField's hint, to
    implement watermark effect, how do it?

    Hi...
    The below code is working fine for me...
    <%@page language="abap" %>
    <%@extension name="htmlb" prefix="htmlb" %>
    <htmlb:content design="design2003" >
      <htmlb:page title="stg " >
        <htmlb:form>
          <htmlb:tabStrip width      = "430"
                          bodyColor  = "rgb(88,5,64)"
                          id         = "t1"
                          bodyHeight = "112" >
            <htmlb:tabStripItem id      = "t1"
                                index   = "1"
                                title   = "Sales"
                                tooltip = "My Tooltip for Tab 1" >
              <htmlb:textView text="Tab N 1" />
              <htmlb:tree id        = "treeReports"
                          showTitle = "true"
                          table2    = "<%= mt_nodes %>"
                          title     = "Menu"
                          width     = "100%" />
            </htmlb:tabStripItem>
            <htmlb:tabStripItem id      = "t2"
                                index   = "2"
                                title   = "Production"
                                tooltip = "My Tooltip for Tab 2" >
              <htmlb:textView text="Tab N 2" />
            </htmlb:tabStripItem>
          </htmlb:tabStrip>
        </htmlb:form>
      </htmlb:page>
    </htmlb:content>

  • Sub-items not supported for selected item(s) error in LSMW

    Hi gurus,
    Am working on BOM's data load via LSMW. Most of the item are stock items (L) but some of the items i am loading are Text items (T). Because of the customizing done in OS13 (that can't be changed apparently), the LSMW executed in foreground gives the message "Sub-items not supported for selected item(s)" (only as information, green message) and the dataload IS STOPPED.
    Is there a way to :
    -> change OS13 (allow sub-items for text items) : When i try i have an error message.
    -> or to force LSMW program no to go on the sub items screens (this way the program does not stop and the BOM is created)
    Thanks in advance for your answers,
    Olivier

    Found the solution my self all relations between dataload file and sub-items structure had to be suppressed in LSMW.

  • Blue color for selected text

    Hello, is any way to change blue color for selected text which is the same as for invisible characters? When I select text all unvisible characters are realy unvisible... In old ID selected text was black and invisible characters inside was orange. Many thx for help... Ilja

    For sure I tried to use "select text" in Illustrator CC on the same system (windows 7) and selected text is black too...
    Many thx for help
    Ilja
    PS
    I must agree with the post about very slowly ID CC. I tried the same indd files in CS6 and CC and CC is slowly in large documents (500 pages and more), for ex. find/replace, but when document is near its end (aprox 80-100 pages) ID CC is much faster than at the start of document. Now I am working on large doc (540 pages) with many headers (aprox 3-4 on each page) and when I want change space for non-breaking space on pages between 1-100, this takes sometimes more than 2 seconds!!! Only simple space change - no styl change etc.
    I think that I am using fast PC (Intel i7, 16GB RAM, SSD disks - cache is on separated mSATA 30GB SSD), all doc are located inside PC, no external drives for normal day work) and I never seen these lags on CS6. Doesn't matter if I using ID CC 32 od 64 bit - it is aprox the same.

Maybe you are looking for

  • Dynamic Header help in PDF Portfolio

    Need some help please, to create and load a Dynamic Header when creating a PDF Portfolio in LiveCycle ES2.  Have input parameter of a [name] and an [image file] to place in the Header.  Process flowing out of Assembler (PDF Generator).  Currently oth

  • Error frm-41211

    hello friends when i am using the following code report_id Report_Object; ReportServerJob VARCHAR2(100); BEGIN report_id:= find_report_object('MyReport1'); ReportServerJob:=run_report_object(report_id); END; i am getting the following error frm-41211

  • How to get the value of combo.

    hello, i am new in jsf so sorry if the question is asked before. in my project i have a jsp page where there is a combo(selectOneMenu). as far as my knowledge a combo is constructed with itemLabel and itemValue. i can get the value of the combo by us

  • Errors In PSA

    Hi All I am getting errors in PSA when Loading Master data The errors are 1.ZACTPAR : Data record 77 ('000300000089 '):    Version 'Rebserve FM ' is not valid     RSDMD     194 2.Value 'Rebserve FM ' for characteristic ZACTPAR    contains invalid cha

  • Workflow GURU

    When i am doing parking for customer credit memo in F-67 and when i save it is giving me Update was terminated System ID.... DEV Client....... 110 User..... 80001000 Transaction.. FBV1 Update key... 949391E0CF46F19A8508001517A02AB1 Generated.... 08.0