Like Microsoft Paint-is it possible to display the color panel

My project requires whiteboard facility also....If i used JcolorChooser all the colors are displayed...If u see in Microsoft paint only 20 colors are displayed...How can we do using java?Please help me

import java.awt.*;
import java.awt.event.*;
import java.awt.geom.*;
import java.awt.image.BufferedImage;
import javax.swing.*;
public class ColorChart extends JPanel
    int[] colorInts;
    BufferedImage image;
    Color foregroundColor;
    Color backgroundColor;
    double x0;
    final int SIDE = 13;
    final int PAD = 3;
    public ColorChart()
        colorInts = new int[]
            0x000000, 0x808080, 0x800000, 0x808000, 0x008000, 0x008080, 0x000080,
            0x800080, 0x808040, 0x004040, 0x0080ff, 0x004080, 0x8000ff, 0x804000,
            0xffffff, 0xc0c0c0, 0xff0000, 0xffff00, 0x00ff00, 0x00ffff, 0x0000ff,
            0xff00ff, 0xffff80, 0x00ff80, 0x80ffff, 0x8080ff, 0xff0080, 0xff8040
        createImage();
        foregroundColor = Color.black;
        backgroundColor = Color.white;
    protected void paintComponent(Graphics g)
        super.paintComponent(g);
        Graphics2D g2 = (Graphics2D)g;
        g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING,
                            RenderingHints.VALUE_ANTIALIAS_ON);
        double w = getWidth();
        double h = getHeight();
        int cols = colorInts.length/2;
        // demo image area
        // darker highlight adjacent to black shadow
        g2.setPaint(UIManager.getColor("Panel.background").darker());
        g2.draw(new Line2D.Double(0, PAD-1.0, image.getWidth()+1.0, PAD-1.0));
        g2.draw(new Line2D.Double(0, PAD, 0, PAD+image.getHeight()));
        g2.drawImage(image, 1, PAD, this);
        double x = 1.0 + image.getWidth() + 1.0;
        double y = PAD + image.getHeight() + 1.0;
        // white highlight
        g2.setPaint(Color.white);
        g2.draw(new Line2D.Double(x, PAD-1.0, x, y));
        g2.draw(new Line2D.Double(0, y, x, y));
        // foreground/background tiles over image
        g2.setPaint(backgroundColor);
        Rectangle2D.Double bg = new Rectangle2D.Double(12.0, PAD+12.0, 12.0, 12.0);
        g2.fill(bg);
        g2.setPaint(UIManager.getColor("Panel.background"));
        g2.draw(bg);
        g2.setPaint(foregroundColor);
        Rectangle2D.Double fg = new Rectangle2D.Double(5.0, PAD+5.0, 12.0, 12.0);
        g2.fill(fg);
        g2.setPaint(UIManager.getColor("Panel.background"));
        g2.draw(fg);
        // darker shadow outlines
        g2.setPaint(UIManager.getColor("Panel.background").darker());
        g2.draw(new Line2D.Double(bg.x+bg.width+1.0, bg.y,
                                  bg.x+bg.width+1.0, bg.y+bg.height));
        g2.draw(new Line2D.Double(bg.x, bg.y+bg.height+1.0,
                                  bg.x+bg.width + 1.0, bg.y+bg.height+1.0));
        g2.draw(new Line2D.Double(fg.x+fg.width+1.0, fg.y,
                                  fg.x+fg.width+1.0, fg.y+fg.height));
        g2.draw(new Line2D.Double(fg.x, fg.y+fg.height+1.0,
                                  fg.x+fg.width + 1.0, fg.y+fg.height+1.0));
        // color swatches
        x0 = x;
        for(int row = 0; row < 2; row++)
            y = PAD + row*(SIDE+PAD);
            for(int col = 0; col < cols; col++)
                int index = row*cols + col;
                g2.setPaint(new Color(colorInts[index]));
                x = x0 + PAD + col*(SIDE+PAD);
                g2.fill(new Rectangle2D.Double(x, y, SIDE, SIDE));
                g2.setPaint(Color.black);
                g2.draw(new Line2D.Double(x, y, x+SIDE-1.0, y));
                g2.draw(new Line2D.Double(x, y, x, y+SIDE-1.0));
        // darker highlight trim that borders black shadow
        g2.setPaint(UIManager.getColor("Panel.background").darker());
        // inter-cell vertical trim
        y = 2*(PAD + SIDE);
        for(int col = 0; col < cols; col++)
            x = x0 + col*(SIDE+PAD) + 1.0;
            g2.setPaint(UIManager.getColor("Panel.background").darker());
            g2.draw(new Line2D.Double(x+1.0, PAD-1.0, x+1.0, y));
        x = x0 + cols*(SIDE+PAD) + 1.0;
        // top trim
        g2.draw(new Line2D.Double(x0+PAD, PAD-1.0, x-1.0, PAD-1.0));
        // horizontal center trim
        y = PAD + SIDE + 1.0;
        g2.draw(new Line2D.Double(x0+PAD, y+1.0, x-1.0, y+1.0));
        // white highlight trim
        g2.setPaint(Color.white);
        y = 2*(PAD + SIDE);
        // inter-cell vertical trim
        for(int col = 0; col < cols; col++)
            x = x0 + col*(SIDE+PAD) + 1.0;
            g2.draw(new Line2D.Double(x, PAD-1.0, x, y));
        // horizontal center trim
        x = x0 + cols*(SIDE+PAD) + 1.0;
        y = PAD + SIDE + 1.0;
        g2.draw(new Line2D.Double(x0+PAD, y, x-1.0, y));
        // bottom trim
        y = 2*(PAD + SIDE);
        g2.draw(new Line2D.Double(x0+PAD, y+1.0, x, y+1.0));
        // right side trim
        g2.draw(new Line2D.Double(x, PAD, x, y));
    public Dimension getPreferredSize()
        return new Dimension(260, 36);
    public void setBackgroundColor(int index)
        backgroundColor = new Color(colorInts[index]);
        repaint();
    public void setForegroundColor(int index)
        foregroundColor = new Color(colorInts[index]);
        repaint();
    private void createImage()
        int w = 27, h = 29;
        image = new BufferedImage(w, h, BufferedImage.TYPE_INT_RGB);
        int white = Color.white.getRGB();
        int bg = UIManager.getColor("Panel.background").getRGB();
        int[] data = new int[w*h];
        for(int j = 0; j < data.length; j++)
            data[j] = j%2 == 0 ? white : bg;
        image.setRGB(0, 0, w, h, data, 0, w);
        Graphics2D g2 = image.createGraphics();
        g2.setPaint(Color.black);
        g2.draw(new Line2D.Double(0,0,w,0));
        g2.draw(new Line2D.Double(0,0,0,h));
        g2.dispose();
    public static void main(String[] args)
        ColorChart colorChart = new ColorChart();
        colorChart.addMouseListener(new ColorSelector(colorChart));
        JFrame f = new JFrame("mimics v5.1");
        f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        f.setContentPane(colorChart);
        f.pack();
        f.setLocation(200,200);
        f.setVisible(true);
class ColorSelector extends MouseAdapter
    ColorChart chart;
    public ColorSelector(ColorChart cc)
        chart = cc;
    public void mousePressed(MouseEvent e)
        Point p = e.getPoint();
        Dimension d = chart.getPreferredSize();
        if(p.x > d.width || p.y > d.height)
            return;
        int x = (int)(p.x - chart.x0);
        int col = x / (chart.SIDE + chart.PAD);
        int row = p.y / (chart.SIDE + chart.PAD);
        int cols = chart.colorInts.length/2;
        if(row < 0 || row > 2 || col < 0 || col > cols-1 || x < 0 ||
                      row*col > chart.colorInts.length-1)
            return;
        int index = row*cols + col;
        //System.out.printf("p.x %d p.y %d x %d row %d col %d index %d\n",
        //                   p.x, p.y, x, row, col, index);
        if(SwingUtilities.isLeftMouseButton(e))
            chart.setForegroundColor(index);
        else if(SwingUtilities.isRightMouseButton(e))
            chart.setBackgroundColor(index);
}

Similar Messages

  • Is it possible to display the color map of a 3D Surface plot on the Front Panel?

    This would be a very useful feature to include, especially if you are just displaying the top-down (XY) projection of your plot (otherwise there's no way to visualize the amplitude that a given color represents). I know that the Intensity Graph allows you to display the Z-axis color map, but I want to use the 3D Graph control for some of the other features it offers...

    I had the same question. After quite a bit of playing around with properties, methods, color ramps, viewing examples and reading a bit about it, I discovered a way to do this. Basically use the ColorMapValues and ColorMapColors properties from the 3D graph and modify them slightly and feed these into the ZScale.Marker.Vals[] on an intensity chart or the Scale.MarkerVals[] on the color ramp. See the attached example.
    I think the diagram is self-documenting and pretty darn simple. I have a couple of notes on the front panel that help explain the vi.
    Good luck.
    Attachments:
    3D_Intensity_ColorMap_Example.llb ‏51 KB

  • Is there any possible to display the text in big font in screen painter

    HI all!
    i want to display the text in the large size in the text field in the screen painter in the odule pool programing.Is there any possible.What i have to do in the screen painter to display the text in the large size.Also is there any possible to put the color for the text.Give me reply

    HI
    CALL METHOD o_dyndoc_id->initialize_document
          EXPORTING
            background_color = cl_dd_area=>col_tree_level1.
        DATA : dl_text(255) TYPE c.  "Text
        CALL METHOD o_dyndoc_id->add_text
          EXPORTING
            text         = 'Flight Details'
            sap_style    = cl_dd_area=>heading
            sap_fontsize = cl_dd_area=>large
            sap_color    = cl_dd_area=>list_heading_int.
    * Display document
        CALL METHOD o_dyndoc_id->display_document
          EXPORTING
            reuse_control      = 'X'
            parent             = cont
          EXCEPTIONS
            html_display_error = 1.
        IF sy-subrc NE 0.
        ENDIF.
    by using these methods you can achieve i hope..
    have a good day.
    regards
    sarves

  • Is it possible to display the entire list in Background ?

    Hi all,
    I have alv report(Oops) , it is grid display and having more than 300 columns , when i execute that report in background i am getting only 132 columns and 65 lines per page, Is it possible to display the entire list , If it is possible then how we can do that? if it is not what is the reason? .
    Thanks in Advance.

    Hi,
    If use Grid in BG u will get o/p In ALV List Itself, second thing is u will get Croped o/p bcos of Print Format 65255 , in this case u have to create/change a new Print Format only for BG jobs like 651000.
    for more info ask ur basis person to create a new print formats in such cases.
    Regards,
    shiva.

  • Is it possible to display the static numerals as Hindi?

    Trying to generate a report using XML Publisher, the report composed of two columns.
    Need to display the numerals in English language coulmn in Arabic numerals and the numerals in Arabic language column in Hindi numerals. Currently they both appear as Arabic numerals in both columns
    Question:
    Is it possible to display the static numerals as Hindi as they had been
    entred in the template or not?
    I understood that on generation these should be variables not static.
    I would welcome any input on this issue.
    Many thanks

    Hmm,
    In templates i guess, you can use multiple font text ..
    same is the case here..
    Arabic and hindi, are you using different font for these ?
    if so, are these fonts available in server too ?
    The test displayed can be static or dynamic, but if the server doesn't know which font to be applied, then its going to apply default font for the text.
    At runtime, the server has to known, for this text which font has to be applied. if this has to happen, font has to be understood by server.

  • Is that possible to display the user selection data in the printable page?

    Hi All,
    I'm going to add a printablepage button on my page.
    Here comes a questions.
    Is that possible to display the user selection data in the printable page?
    For example,
    I have a table in the page,with 10 records.User select 5 of them.Can I display these 5 records in the printable page?
    Please help.

    Hi Yannick,
    Thanks a lot for the information. It worked.
    The portlet data can be accessible using bindings, but parameter name can be different.
    Meanwhile I have got one more scenario, where the Portlet and Task Flow placed in different pages of WCP Application. On change of data in the Portlet the application should navigate to another page where the Task Flow placed and displays selected data.
    Basically I can not use any button for navigation. The navigation should happen once I do some action in Portlet.
    Is this possible? If yes can you please let me know the steps?
    Thanks in advance!
    Somnath
    Edited by: Somnath Basak on Dec 20, 2011 9:41 AM

  • Is it Possible to display the output of the ALV list as POP-UP

    Hi Experts,
                     Is it Possible to display the output of the ALV list as POP-UP, if yes then provide some ideas on it.
    thanking in advance,
    Samad.

    Hi samad, it is possible to display alv list as pop-up by using the FM " REUSE_ALV_POPUP_TO_SELECT"
    try this sample code
    CALL FUNCTION 'REUSE_ALV_POPUP_TO_SELECT'
          EXPORTING
       I_TITLE                       =  P1_TITLE
           I_SELECTION                   = 'X'
           I_ZEBRA                       = 'X'
      I_CHECKBOX_FIELDNAME          =
      I_LINEMARK_FIELDNAME          =
      I_SCROLL_TO_SEL_LINE          = 'X'
            I_TABNAME                     = 'T_VBAP'
           I_STRUCTURE_NAME              =  'T_VBAP'
           IT_FIELDCAT                   =  T_FCAT2
           I_CALLBACK_PROGRAM            = 'ZTEST_ALV_POPUP'
       IMPORTING
           ES_SELFIELD                   = I_SELFIELD
           E_EXIT                        = W_EXIT
          TABLES
            T_OUTTAB                      = T_VBAP.
    i think it will solve your problem
    Regards,
    Vijay

  • Is it possible to display the document link for each record  in Report ?

    Hi,
         Is it possible to display the document or Image link for each master record in the Report  with the help of RSA1->Document->Master Data.
    Usefull answers are really helpfull.
    Advance Thanks for the userful answers.
    Regards,
    MRC.

    Hi  JAYASHREE PARASMAL ,
          Thanks for your valuable answers.
          Now i got the document in my Report,while executing the report through query designer as per your suggestion done on Setting Tab option.
          But i can't able to get the same thing,while i executing the Repory through WAD.
          What setting i need follow in the WAD for getting the same thing.
          Kindly give your suggestion to get the document in my Report,while i am executing through my WAD.
          Once again thanks for your helpful answer and awaiting for your suggestion.
    Regards,
    MRC.

  • I have a problem in the liquefaction of confidentiality and answers when asked to reset the answers but remembered email added halted from by Microsoft Corporation, Is it possible to cancel the account and send the answers added on my email and thank you

    Dear,s
    I have a problem in the liquefaction of confidentiality and answers when asked to reset the answers but remembered email added halted from by Microsoft Corporation, Is it possible to cancel the account and send the answers added on my email:
    <Email Edited by Host>
    Thanks

    You are not addressing Apple here. And your post is a bit confusing. See Klaus's answer in this thread:
    https://discussions.apple.com/thread/5228474?tstart=0

  • I would like to ask if is possible to predict a future version of iOS can have the possibility to choose the color with which to write and be able to choose the character also...

    I would like to ask if is possible to predict a future version of iOS can have the possibility to choose the color with which to write and be able to choose the character also...

    Nobody here would have a crystal ball and know what Apple plans on doing in the furture.
    If you feel this feature is so important, you can let Apple know:
    www.apple.com/feedback

  • I would like to know if is possible to use the old iSight with my powerbook (mid 2009)?

    I would like to know if is possible to use the old iSight with the macbook pro (mid 2009)?

    Hi,
    If the Mac has Firewire then you can use the External iSight
    (Other readers
    If you have Firewire 800  then you will need an adapter to use the Firewire 400 camera - Search for the word Adpater and see posts by EZ Jim for more details)
    Don't daisy-chain the camera with Hard Drives
    The camera only uses a data rate of 200Mbps and the differences in Hard Drive data speeds can be an issue.
    The External iSIght should work no matter what Firmware is on there currently.
    There is some evidence that having the 1.0.3 version (Open the System Profiler > Hardware > Firewire) on the device makes it more compatible/useable in later OS versions
    The Updater is included in Tiger and Leopard. 
    Hard Drive/System/Library/CoreServices/iSight Updater/iSight Updater.app
    An OS Update could "trigger" this to be run if you have Tiger
    It can also be run as a Standalone.
    It is Not present in Snow Leopard and although the documentation says this Firmware is an Audio update some people report that the camera needs the 1.0.3 Firmware to run.
    (that could simply be the "Flashing" the Memory involved resets it enough to work)
    10:22 PM      Wednesday; June 8, 2011
    Please, if posting Logs, do not post any Log info after the line "Binary Images for iChat"
     G4/1GhzDual MDD (Leopard 10.5.8)
     MacBookPro 2Gb( 10.6.7)
     Mac OS X (10.6.7),
    "Limit the Logs to the Bits above Binary Images."  No, Seriously

  • New Quad-G5 with Apple 30" display WON'T DISPLAY THE COLOR BLACK???!!!!

    Just got this system up and running with all my software and for some reason if I show video with an all black screen there are blue lines tarnishing the image. If I let the computer go to sleep and then wake it up any black is afflicted with the same problem. Now if just the display goes to sleep (not the computer) and it gets woken up then the problem just occurs in video again. HELP! This computer should be able to display the color black.

    Sounds like a video card issue.

  • Is there possibility to use the front panel without installing Labview?

    Hallo,
    i have two small questions:
    1- Is it possible to use the front panel of a labview software without needing to install Labview itself? i mean something similar to the "power point viewer" which can view the Power Point files without installing the microsoft office.
    2- In an intensity Graph, how can one change the color?
    thanks.
    Solved!
    Go to Solution.

    Hi,
    Regarding your questions
    1)You need to have Labview and Application builder installed on your machine. If you have that you can make an stand alone application (EXE) and then you can deploy it on systems that does not have LabView and can view it, However you will not be able to see the block diagram.
    Here is a link that explains how to do so
    http://zone.ni.com/reference/en-XX/help/371361A-01/lvhowto/exe_ex/
    2) You can either do it by using propery node or marker method. The following link explains it
    http://digital.ni.com/public.nsf/allkb/1ADFF221E27F5B5886256E6F007C7B58?OpenDocument
    Hope it helps.
    Regards,
    Fawad
    Fawad Nisar
    Applications Engineer
    National Instruments UK & Ireland

  • Is it possible to change the color settings of ides 4.7 to make it appear .

    hi all...
    I want to take some snapshots from ides 4.7. Please tell is it possible to change the color tone of ides 4.7 to make it appear like ECC 6. How to change the color settings?
    Thanks!

    Install Tweak SAP gui .

  • How can I display the front panel of the dinamically loaded VI on the cliente computer, the VI dinamically loaded contains files, I want to see the files that the server machine has, in the client machine

    I can successfully view and control a VI remotly. However, the remote VI dinamically loads another VI, this VI loaded dinamically is a VI that allows open others VIs, I want to see the files that contains the server machine, in the client machine, but the front panel of the dinamic VI appears only on the server and not on the client, How can I display the fron panel with the files of the server machine of the dinamically loaded VI on the client computer?
    Attachments:
    micliente.llb ‏183 KB
    miservidor.llb ‏186 KB
    rdsubvis.llb ‏214 KB

    I down loaded your files but could use some instructions on what needs run.
    It seems that you are so close yet so far. You need to get the data on the server machine over to the client. I generally do this by doing a call by reference (on the client machine) of a VI that is served by the server. THe VI that executes on the server should pass the data you want to diplay via one of its output terminals. You can simply wire from this terminal (back on the client again) to an indicator of your choosing.
    Now theorectically, I do not think that there is anything that prevents use from getting the control refnum of the actual indicator (on the server) of the indicator that has the data, and read its "Value" using a property node. I have never tried this idea but it seems t
    hat all of the parts are there. You will need to know the name of the VI that holds the data as well as the indicator's name. You will also have to serve all VI's. This is not a good idea.
    Ben
    Ben Rayner
    I am currently active on.. MainStream Preppers
    Rayner's Ridge is under construction

Maybe you are looking for

  • How can I create a status bar at the bottom of a window ?

    I would like to create a status bar at the bottom of my main window similiar to "Internet explorer" has. I thought of using a tool bar but I can't see how to keep it positioned at the bottom of the window when the window is resizable. Any other ideas

  • Manual Bank Statement Posting problem

    Hi, I am posting MBS(ff67) for the openitem clearance in openitem managed check deposit bankaccount  and a counter entry in mainbank account.after i posted a session is created.now when i process this session it dint execute properly.There is an erro

  • Exchange 2010 on windows server 2008 r2 (VMware Virtual Machine)

    Hello All, I am trying to get an exchange 2010 test environment running. This is a virtual deployment on windows server 2008 r2 sp1 and the actual exchange install passes the initial requisite  checks, during the install it however fails on creating

  • Calling a method in a class extended from thread

    I'm trying to use two threads of type ThreadTest to call the addNum method in the class below. I found that i couldnt call the addnum method with the instances I created but had to make the addnum method static and then call it with the class name Th

  • Is there a way to set/change default event start/end time?

    Is there a way to set or change the default start and end time for events?