Creating a panel with multiple canvasses on it, in complementary colors

    public Dancefloor(Dimension patches, int size, Color color)
        //create JPanel
        super();
        backgroundColor = color;
        numberOfPatches = patches;
        patchSize = size;
        //set Size of Dancefloor, make a conversion because the returned type isn't int but double and the setSize
        //function is only able to handle int
        setSize((new Double( numberOfPatches.getWidth() * patchSize) ).intValue(),
        (new Double( numberOfPatches.getHeight() * patchSize) ).intValue() );
        //set bacground color of the panel
        setBackground(backgroundColor);
        //create a number of patches, as submitted to the constructor(at the moment as Canvas)
        //Create a for loop which will be looped as much times as the number of patches
        for(int d = 0; d < new Double(numberOfPatches.getWidth() * numberOfPatches.getHeight()).intValue(); d++)
            //create a new canvas and set a background for it
            patch = new Canvas[new Double(numberOfPatches.getWidth() * numberOfPatches.getHeight()).intValue()];
            patch[d] = new Canvas();
            patch[d].setBackground(backgroundColor);
            //set another background for the patches that are not even, but have an odd number
            if(d % 2 != 0)
                float[] colorHSB = color.RGBtoHSB(color.getRed(), color.getGreen(), color.getBlue(), null);
                colorHSB[0] += 0.5;
                if(colorHSB[0] > 1) {
                    colorHSB[0] -= 1;
                patch[d].setBackground(new Color(Color.HSBtoRGB(colorHSB[0], colorHSB[1], colorHSB[2])));
    }Above is the code of the constructor of my class called Dancefloor, it attempts to create a panel(the 'dancefloor') with multiple canvasses('patches') on it. The even patches should have the color specified in the constructor, the others should have a complementary color as background. this is done using the last if-statement.
When executing however, all patches have the color specified in the constructur and so you all you can see is a panel with a background instead of a panel with a patchwork of 2 different color canvasses on it
I hope this explanation was pretty clear, I hope someone is able to help me out
thomas

i would suggest if you are going to use a JPanel, simply create an array of Rectangles that represent all of your patches. Then override the paintComponent(Graphics g) method of the JPanel to and use the fillRect(int x, int y, int width, int height) method from the graphics class to draw all of your rectangles something like this
JPanel floor = new JPanel() {
     public void paintComponent(Graphics g) {
          super.paintComponent(g);
          for (int j = 0; j < myRectangles.length; j++){
                g.setColor(whateverColor)
                g.fillRect(myRectangles[j].x, myRectangles[j].y,
                                 myRectangle[j].height, myRectangles[j].width);
}btw, you can use the field values width and height from Dimension class to retrieve an int value, insted of using getWidth() and getHeight just call myDimension.height or myDimension.width

Similar Messages

  • How can i create  excel sheet with multiple tabs using utl file?

    how can i create excel sheet with multiple tabs using utl file?
    any one help me?

    Jaggy,
    I gave you the most suitable answer on your own thread yesterday
    Re: How to Generating Excel workbook with multiple worksheets

  • How to create list items with multiple attachment files using rest api javascript

    In one of user form I am using javascript rest api to create a list item with multiple attachment files. So far I am able to create list item and once created uploading an attachment file. But this is two step process first create an item and then upload
    a file.
    It create an additional version of the item which is not desired. Also I am not able find a way to attach multiple files in a go. Following is the code I am using.
    createitem.executeAsync({
                    url: "/_api/web/lists/GetByTitle('UserForm')/items(1)/AttachmentFiles/add(FileName='" + aFile.name + "')",
                    method: "POST",
                    contentType: "application/json;odata=verbose",
                    headers: {
                        "Accept": "application/json;odata=verbose",
                        "X-RequestDigest": $("#__REQUESTDIGEST").val()
                    binaryStringRequestBody: true,
                    body: fileContent,
                    success: fnsuccess,
                    error: fnerror
    So somehow I need to combine item attributes along with attachment files in body: param. I visited https://msdn.microsoft.com/en-us/library/office/dn531433.aspx#bk_ListItem but no success.
    Appreciate any help.

    Thanks Mahesh for the reply and post you share it was useful.
    But this does not solve the core of the issue. You are uploading attachments after creation of item and multiple files are being attached in loop. This is kind of iterative update to an existing item with attachments. This will end up creating multiple versions. 
    What I am trying to achieve is to create an item along with multiple attachments in a go. No item updates further to attach a file.
    Please suggest how this can be done in one go. SharePoint does it when one creates an item with multiple attachment.
    Thanks for your reply.

  • How to create a table with multiple select on???

    Hi all,
            I am  new to webdynpro and my requirement is to create a  table with multiple selection on.I have to add abt 10 rows in the table but only 5 rows should be visible and moreover a verticalscroll should be available to view other rows.Can anybody explain me in detail how to do that.Please reply as if you are explaining  to a newcomer.Reply ASAP as i have to do it today.
                                                                           Thanxs

    Hi,
    1. Create a value node in your context name Table and set its cardinality to 0:n
    2. Create 2 value attributes within the Table node name value1 and value2
    3. Goto Outline view> Right click on TransparentUIContainer>Apply Template> Select Table>mark the node Table and it's attributes.
    you have created a table and binded its value to context
    Table UI properties
    4.Set Selection Mode to Multi
    5.Set Visible Row Count to 5
    6.ScrollableColCount to 5
    In your implemetaion, you can add values to table as follow:
    IPrivate<viewname>.ITableElement ele = wdContext.nodeTable().createTableElement();
    ele.setValue1(<value>);
    ele.setValue2(<value>);
    wdContext.nodeTable().addElement(ele);
    The above code will allow you to add elements to your table node.
    Regards,
    Murtuza

  • Is it possible to create a form with multiple form fields on a single line?

    Is it possible to create a form with multiple form fields on a single line?  I can't find anything in the documentation or a template that does this.
    I am trying to create a "documents received" checklist with a check box on the left margin, a date-received field to the right of the check box and and a description of the document (Formatted Text) on the far right.
    In the past I have entered the Fixed Text with a word processor, published it to a PDF file, then added the check box and date fields with the Acrobat Forms editor.  I would prefer to use FormsCentral if it is possible.

    We now support multiple fields on one line. This post provides a brief overview.
    Give it a try and send us your feedback.
    Sorry it took so long.
    Randy

  • I need your expert opinion on how to create a map with multiple conditions.

    Hello.
    I need your expert opinion on how to create a map with multiple conditions.
    I have a procedure (which i cannot import or re-create in OWB due to the bug), so i am trying to create a map instead :-(
    How can i create a cursors within the map?
    My function creates table and cursor.
    Then it will have to check for duplicates in the tables (the one created and another table) - the criteria for finding duplicates is a number of fields.I then need to place few different conditions (if some attributes are not available) and it has to load cursor based on this conditions. The next step is to fetch the data into the cursor based on what attributes are missing.
    The next thing it will do is insert the data into table (if record doesn't exist), output the error in separate table is record is corrupted, or update the record with changed information.
    In short i need to re-create match / merge but with conditions, iterations etc 'built into' it.
    I can read up on available functions - it's just what would be the best options? and what would be the best approach to do so?
    In my function i use %rowtype - but cannot use it in owb - so what would be the alternative? i don't really want to create a lot of variables and then have a nightmare of maintaing it. are there any tips regarding this?
    having looked through Oracle dedupe - it's not really what i need because it is just DISTINCT.
    I would appreciate any help / advise on this.
    Thank you very much

    thanks a lot for your reply - i will look into this option :-)
    it is a bit more complicated now as i have to re-create the match / merge and then somehow 'tweak' it to achieve the result i need.
    At the moment i am looking to breakdown the package into smaller chunks 'functions' and try creating the map that way.
    Anyway, thank you very much for your suggestion.

  • Creating a report with multiple Y-axes on one graph

    I currently have a script that will create a report with either 1, 2, or 3 graphs and has the ability to have four graphs per plot.  I would like to add functionality to this script by making the Y-axis on the graphs have multiple Y-axes.  How can I programmatically create a graph with multiple Y-axes?

    To create an new axis system use the command GraphObjNew, eg:
    Call GraphObjNew("2D-Axis","2DAxis1")
    Call GraphObjOpen("2DAxis1")        
      D2AxisBackColor = "blue"  
    Call GraphObjClose("2DAxis1") 
    Call PicUpdate
    If you have DIAdem Version 10 you can also create a new y-axis using GraphObjYAxisNew. This command is not available in versions 9.1:
    Call GraphObjOpen("2DAxis1")
    AxisNo = GraphObjYAxisNew("left")
    If AxisNo>0 Then
      Call GraphObjOpen(D2AxisYObj(AxisNo))
      D2AXISYTXT ="My new axis"
      D2AXISYTXTFONT ="Arial"
      D2AXISYTXTCOLOR ="red"
      Call GraphObjClose(D2AxisYObj(AxisNo))
    End If
    Call GraphObjClose("2DAxis1")
    Winfried
    Message Edited by winner on 03-23-2006 03:48 PM

  • Creating SVG Chart with multiple lines

    Hi All,
    I want to create a chart with multiple lines.
    Ex: I have one emp table with empno, sal and deptno columns.
    I want to print deptno in x axis and no of employees on y axis.
    I want to print one line for employees with sal > 15000 and one more line for employee with sal =< 15000
    So one line will show no of employees with sal more than 15000 for each dept. Similar case for the other line and these 2 lines should be in different colors.
    For one line the query will go as
    select link, deptno, count(empno)
    from emp where sal > 15000 group by null, deptno
    Is this possible to draw this chart?
    Thanks,
    Manoj

    I wasn't able to do something like what you describe, but I was able to do this:
    I defined column A of the table as a Header Row, selected the cells in the table, and chose this chart type (2D 2 Axis):
    Then I clicked the chart and in the pane at the right checked 'Axis Name' in the Axis tab and added the axis names.
    Maybe this can give you an idea of how you can illustrate the relationships that you want to show.
    SG

  • Problem in creating Maintenance Order with multiple operations

    Hello all,
    I am facing problem while creating Maintenance Order with multiple operations and sub-operations. I am using BAPI : BAPI_ALM_ORDER_MAINTAIN.
    For single operation it is working fine,but i am unable to create MO with multiple operations and sub-operations.
    Please, provide me the inputs required,
    I have used methods :
    ORDER        CREATE,
    OPERATION CREATE
    and SAVE.
    Regards,
    Siddhartha

    Hi,
    The FM you are using is a perfect one. This FM is bit tricky to use. You need to perfectly pass the Reference number field. which links various input table parameters of this FM.
    Thanks & Regards,
    Navneeth K.

  • How do we create a panel with a title on it

    How do we create a panel with a title on it (something like the titled border in java swing)

    Thanks John,
    But, I already have a panel box with many panel form layouts inside and would like to have a title on one of the panel form layouts. So, a panel box isn't the one I am looking for.
    More like the titled border shown in here [http://java.sun.com/docs/books/tutorial/uiswing/components/border.html#demo]
    thanks again
    Anwar

  • How to create Item Codes with multiple Item Description

    Hi,
    for one of my client, we need to create Item Codes with multiple Item Description.
    e.g.,
    Item Code - M00285
    Item Description 1 - Blue Paint
    Item Description 2 - Red Paint
    Is that possible in SAP Business One? If "Yes" kindly provide a solution. Else recommend an alternative method.
    Regards,
    Ammheya U. Naaik

    Ammheya,
    I just wanted to add that there is an Add-On that handles "Style, Color, Size" situations like yours.
    It allows you to define a "master" item, (Paint, for example) and then setup the various styles, colors and sizes it comes in. 
    This creates sub-items for each with the master in the ItemCode (Paint-Blue, Paint-Red, etc)
    It's called MatrixOne from Navigator.  You could find it on the partner portal with other Add-Ons.
    Hope thathelps,
    Brad Windecker

  • How does create a server with multiple Clients ?

    Any people can lead me .
    How does create a server with multiple Clients ?
    Thanks

    For a multithreaded server you will need a thread to listen and at least one thread per client. If the conversation is half duplex, one thread per client works very well, if it's full duplex you will find one thread to send and one to receive much easier to program.
    I posted a Simple Socket Server that uses 1+2*clients threads.

  • Error creating a contract with multiple account assignments

    Hallo,
    I have created a PO agreement with a single account assignment on tr - ME31K.
    If I open this agreement and open the account assignments for an item I'm able to press the "Change display" button. In the screen which is showed I'm able to set the distribution to set the distribution to 1 - Distribution on quantity basis. If I do so I get the following error message: " Enter Acc. ***. Block". The only thing I could do is set this indicator!. But when I set this indicator this indicator is resettled and the message appears again.
    The thing I want to do is that it is possible to create a contract whit multiple account assignments.
    Could any one say what is missing or what is wrong?
    My SAP version is 47x110 SR1.
    Kind regards,
    Richard MeijnError creating a contract with multiple account assignments

    Rahul,
    The reason why I created a contract with a single Account Assignment is that it was not possible to save the document.
    So I created a document for my example and want to change it to a multiple Account assignment. So I did the steps as described.
    After adding a extra account line and pressing Enter I get the error message as described: "Enter Acc. ***. Block".
    There must be a setting wring in the IMG but I don't know which one?
    I have looked ad transaction "OME9" but couldn't see the cause.
    Kind Regards,
    Richard Meijn

  • Can I create a Formula with Multiple Products [ Not Co Products ] ?

    hi There,
    Have a simple question & Doubt.
    Is it okay to create a Formula with Multiple Products in OPM ? If Yes, how does the Formula behave with respect to Standard Costing Subledger.
    If not, what are the reasons for not creating formula with Multiple Products & what are the alternatives to that ?
    Thanks,
    Dhiraj

    hi
    U can very well define Multple products in a formula and ur std costing will work fine. But for any By products there is No costing method support. This is Oracles standard.
    Now it is clear,,,still any doubt...plz ask
    Regards
    R Singh
    Tech Mahindra Satyam

  • Trying to create a surface  with multiple images with mouse events

    novice programmer (for a applet program)
    hi trying to create a surface i.e jpanel, canvas, that allows multiple images to be created.
    Each object is to contain a image(icon) and a name associated with that particular image. Then each image+label has a mouse event that allows the item to be dragged around the screen.
    I have tried creating own class that contains a image and string but I having problems.
    I know i can create a labels with icons but having major problems adding mouse events to allow each newly created label object to moved by the users mouse?
    if any one has any tips of how to acheive this it would be much appreciated. Thanks in advance.
    fraser.

    This should set you on the right track:- import java.awt.*;
        import java.awt.event.*;
        import javax.swing.*;
        public class DragTwoSquares extends JApplet implements MouseListener, MouseMotionListener {  
           int x1, y1;   // Coords of top-left corner of the red square.
           int x2, y2;   // Coords of top-left corner of the blue square.
           /* Some variables used during dragging */
           boolean dragging;      // Set to true when a drag is in progress.
           boolean dragRedSquare; // True if red square is being dragged, false                              //    if blue square is being dragged.                            
           int offsetX, offsetY;  // Offset of mouse-click coordinates from
                                  //   top-left corner of the square that was                           //   clicked.
           JPanel drawSurface;    // This is the panel on which the actual
                                  // drawing is done.  It is used as the
                                  // content pane of the applet.  It actually                      // belongs to an anonymous class which is
                                  // defined in place in the init() method.
            public void init() {
                 // Initialize the applet by putting the squares in a
                 // starting position and creating the drawing surface
                 // and installing it as the content pane of the applet.
              x1 = 10;  // Set up initial positions of the squares.
              y1 = 10;
              x2 = 50;
              y2 = 10;
              drawSurface = new JPanel() {
                        // This anonymous inner class defines the drawing
                        // surface for the applet.
                    public void paintComponent(Graphics g) {
                           // Draw the two squares and a black frame
                           // around the panel.
                       super.paintComponent(g);  // Fill with background color.
                       g.setColor(Color.red);
                       g.fillRect(x1, y1, 30, 30);
                       g.setColor(Color.blue);
                       g.fillRect(x2, y2, 30, 30);
                       g.setColor(Color.black);
                       g.drawRect(0,0,getSize().width-1,getSize().height-1);
              drawSurface.setBackground(Color.white);
              drawSurface.addMouseListener(this);
              drawSurface.addMouseMotionListener(this);
              setContentPane(drawSurface);
           } // end init();
           public void mousePressed(MouseEvent evt) {
                  // Respond when the user presses the mouse on the panel.
                  // Check which square the user clicked, if any, and start
                  // dragging that square.
              if (dragging)  // Exit if a drag is already in progress.
                 return;           
              int x = evt.getX();  // Location where user clicked.
              int y = evt.getY();        
              if (x >= x2 && x < x2+30 && y >= y2 && y < y2+30) {
                     // It's the blue square (which should be checked first,
                     // since it's in front of the red square.)
                 dragging = true;
                 dragRedSquare = false;
                 offsetX = x - x2;  // Distance from corner of square to (x,y).
                 offsetY = y - y2;
              else if (x >= x1 && x < x1+30 && y >= y1 && y < y1+30) {
                     // It's the red square.
                 dragging = true;
                 dragRedSquare = true;
                 offsetX = x - x1;  // Distance from corner of square to (x,y).
                 offsetY = y - y1;
           public void mouseReleased(MouseEvent evt) {
                  // Dragging stops when user releases the mouse button.
               dragging = false;
           public void mouseDragged(MouseEvent evt) {
                   // Respond when the user drags the mouse.  If a square is
                   // not being dragged, then exit. Otherwise, change the position
                   // of the square that is being dragged to match the position
                   // of the mouse.  Note that the corner of the square is placed
                   // in the same position with respect to the mouse that it had
                   // when the user started dragging it.
               if (dragging == false)
                 return;
               int x = evt.getX();
               int y = evt.getY();
               if (dragRedSquare) {  // Move the red square.
                  x1 = x - offsetX;
                  y1 = y - offsetY;
               else {   // Move the blue square.
                  x2 = x - offsetX;
                  y2 = y - offsetY;
               drawSurface.repaint();
           public void mouseMoved(MouseEvent evt) { }
           public void mouseClicked(MouseEvent evt) { }
           public void mouseEntered(MouseEvent evt) { }
           public void mouseExited(MouseEvent evt) { }  
        } // end class

Maybe you are looking for

  • Unable to trap error on NAS drive mount failure

    Following script works fine when NAS is on network but unmounted but fails to trap error when NAS not on network (it's on a wireless connection that drops out in heavy snow). I want to build a loop so that it tries to bring up the drive every few min

  • Icons of firefox menu bar are not shown properly

    I've recently updated my firefox to Version 35.0, When I opened it the icons for the menubar are missing. I tried using the suggestions found in this site: 1.Options > Content : Fonts & Colors > Advanced 2.gfx.downloadable_fonts.enabled 3. reset fire

  • Apple TV 2 Status Light

    Can anyone tell me if the status light is supposed to come on every couple of minutes, it stays on for about 5 secs then goes out. I can't find anything in the manual about it, I just wondered if this was normal, any ideas would be welcome.

  • More than 2 structures in a BEx query

    Hi guys,   Is it possible to define more than 2 local/global STRUCTURE for a particular query ?

  • After Installation Thunderbird cannot create any e-mailaccount in Windows 8.1

    Dear friends, I have installed Thunderbird on my recently installed Win 8.1 system. TB installes, opens, but then I cannot create anything else but a Newsgroupaccount. The wizard for creating a new, or importing existing e-mailaccounts does not appea