Displaying a Grid in Java

I need a grid that i can move objects around in
I need to have a 10 by 10 grid where 30% of the spaces are occupied by object (15% red and 15% blue). The object will only be able to stay in that square if it's neighbours are predominantly the same colour. if that is not the case than the object must be moved ot an adjacent square.
Thanks, any help would be appreciated!

I was just trying to understand how the moves are trigered becouse I was under the impression that you want to allow the user to move them.
If all you want is to programmatically move them the logic will depend on how you have implemented your grid.
Try to make it acording to MVC.
Basically your model should by a two dimentional array of containers. Each container can hold an object. ou can add method to move objects from container to container.
Then you write your view which examine the state of the above model at a given point of time and drow it in the screen.
Every time the objects are moved you should redraw the screen using view.

Similar Messages

  • What is the  difference between list display and grid display in alv report

    Hai genious
    i am a new of the abap, i dont know the alv report, i have a small doubt, can u please tell me  what is the main difference between list display and grid display in alv report
    thanks&regards
    chinnu

    Hi ,
    1. For all practical purposes, they are the same.
    2. Some differences:
    a) from abap coding point of view,
    alv list is done with Function modules,
    alv gris can also be done with FM,
    but can also be done using OO concepts.
    b) Alv grid (using oo concept) requires
    designing the screen layout .
    Hence, in one screen, we can show more
    then one alv grid
    (we cannot show more than
    one alv list on one screen)
    c) ALV grid uses ActiveX controls
    present on the Presentation Server.
    Hence, it consumes More Memory
    on the presentation server.
    d) ALV LIST is Display Only.
    Whereas
    ALV Grid Can Be made EDITABLE for entry purpose.
    e) In alv grid, these options are possible,
    but not in alv list.
    without horizontal lines
    without vertical lines
    without cell merging during sorts
    display total lines above the entries
    I hope it helps.
    Regards,
    Mamta
    Edited by: Mamta Verma on Nov 27, 2008 6:41 AM

  • How can I get dataTable to display values from the java layer?

    When I use the dataTAble in my JSP page it will only display values from my java layer if the facets tag has it's name set to "header". Why is this happening?
    If I set it to "header" and I look at the page source it actually has created the correct number of rows but it doesn't put the values between the <td> tags? It see's the length of my list but it doesn't pick the values out of the list.
    <h:dataTable var="data" value="#{NameBean.test}" border="1">
    <h:column>
    <f:facet name="header">
    <h:outputText value="Name"/>
    </f:facet>
    </h:column>
    <h:column>
    <f:facet name="header">
    <!-- <h:outputFormat styleClass="outputFormat" id="format1" value="#{NameBean.test}"></h:outputFormat>-->
    <h:outputText styleClass="outputText" value="#{NameBean.test}" style="" rendered="true" escape="false"/>
    </f:facet>
    </h:column>
    </h:dataTable>
    public List gettest()
              List li = new LinkedList();
              Object Developers[] = {"M@n00j", "sdsadas"};
              for( int i = 0; i < Developers.length; i++ )
                   li.add(Developers);
              return li;
    Thanks in advance to anyone that can help.
    -ls6v

    I've been able to get it working with some of those changes along with changes in the JSP. I think it's a setting or two in the JSP that'll allow the program to run correctly.
    I have a list and it's returned like what you suggested. A day or two ago I tried to move the outputtext outside of the facet tag but nothing would print, I know believe that's related to the following setting in the JSP:
    rows="0" in the <h:dataTAble tag
    Unfortunately the dataTAble isn't displaying the values correctly. It prints all of the values (Strings) in the list on each row and it make a new row for the number of items in the list.......... ???
    Here's what it's printing to the screen (the table):
    ===================
    == [asdasd], [sddfdfd] ==
    ===================
    ===================
    == [asdasd], [sddfdfd]==
    ===================
    what it should print:
    ============
    == [asdasd] ==
    ============
    ============
    == [sddfdfd] ==
    ============
    My code:
    public List gettest()
              List li = new ArrayList();
              li.add("asdasd");
              li.add("affffd");
              return li;
              }JSP
    <h:dataTable border="1" columnClasses="list-column-left"
        headerClass="list-header"
        rowClasses="list-row-odd"
        id="table"
        rows="0"
        value="#{NameBean.test}"
        var="data">
    <h:column>
    <f:facet name="header">
    <h:outputText value="test"/>
    </f:facet>
    <h:outputText value="#{NameBean.test}" style="" rendered="true" escape="false"/>
    </h:column>
    </h:dataTable>

  • How to display the contents of java.util.list in a frame???

    i should use awt only not applet...
    i need to display the contents of java.util.list in a frame...
    the contents contains rows queried from a oracle database.....
    the contents should be displayed similar to how a lable is displayed..
    please help me out..
    thanks
    dinesh

    Of course there is something in AWT:
    http://java.sun.com/j2se/1.5.0/docs/api/java/awt/List.
    htmlagain, if you carefully read the question, he needs a
    table to display a JDBC result set. There is no
    pre-made table component in AWT.Well, I read that he filled the data into a java.util.List and now wants to display this list. So a List-component should be sufficient. But I might be wrong...
    -Puce

  • Reg. can we display alv grid using field groups (extracts)

    Hi,
    can we display alv grid using field groups (extracts). is this possible. i have to develop a blocked alv.
    tnks
    Yerukala Setty

    No, you will need the data in an internal table to use ALV.
    Cheers
    Allan

  • Report to display in Grid for VAL10C TC even if I dnt select any variant

    Hi everybody,
            I am facing the problem with VL10C trasaction code. It is displaying report in normal list if we dnt select any variant. But I want to display in grid .
    I have tried through settings for managing the layout but I was invain.
    If select any variant then it is displaying in grid.
    But with out grid how to display the report in grid.
    its an urgent issue.
    eagerly waiting for reply.
    Thanks and regards
    Jp

    HI,
    In the Third Button of Save Layout.Check the USer Specific settings of the Report Layout and save the Varaint.This will help.
    Bala.M

  • Problem in displaying Alv grid output  using oops........

    hi,
    i have two problems in displaying ALV grid output Using Oops.
    1) How to modify the fieldcatalog after we getting a field catalog using general FM.
    2) initialy it is displaying 13 fields but there are 63 fields .
       eventhough we chage the layout to 63 fields it is displaying only 13 fields , these 13 fields may be different based on our selection but count  of displayed fileds are same . how can display 63 fields at a time .

    Hi,
    You can chnage using below code:
    loop at gt_fieldcat.
    if <gt_fieldcat-field_name> = 'FIELDNAME'.
    endif.
    modify gt_fieldcat.
    clear gt_fieldcat.
    endloop.
    Make sure that all the field should not have no_out = 'X' and tech = 'X'.
    Thanks,
    Sriram Ponna.

  • Displaying Picture in a Java APPLICATION please help!!

    I have been trying to write a method that Displays a .jpg file when called. However I have not gotten far, every book I have tell you how to display pictures in an applet but not an application. I did find some code that is supposed to be for an application, but It does not compile right. Any help would be apprecidated!
    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.*;
    public class PictureIt{
    public void makeImage() {
    //***Image Output Stream
    String imgFile
    = "d:\\temp\\TestImage.jpeg";
    out = new FileOutputStream(imgFile);
    BufferedImage image = null;
    image = (BufferedImage)createImage
    (panelJpeg.size.width, panelJpeg.size.height);
    Graphics g = image.getGraphics();
    panelJpeg.paintAll(g);
    }

    Displaying Picture in a Java APPLICATION please help!!
    Hope this helps.There is going to be two classes compile seperatly first class is what does the drawing
    here it is
    import javax.swing.*;
    import java.awt.*;
    public class draww extends JPanel {
    Image ball;
    int width1 = 100;
    int height1 = 100;
    public draww() {
    super();
    Toolkit kit = Toolkit.getDefaultToolkit();
    ball = kit.getImage("pic1.gif");
    public void paintComponent(Graphics comp) {
    Graphics2D comp2D = (Graphics2D) comp;
    comp2D.drawImage(ball, 20, 20, width1, height1, this);
    sound class is the container JFrame here it is
    import javax.swing.*;
    import java.awt.*;
    public class drawing extends JFrame {
    public drawing() {
    super("draw");
    setSize(400,400);
    setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    Container pane = getContentPane();
    draww d = new draww();
    pane.add(d);
    setContentPane(pane);
    setVisible(true);
    public static void main(String[] args) {
    drawing drawing1 = new drawing();
    PS Hope this helps and see you around

  • Can I switch to another Coherence Grid in Java Extend?

    The scenario is I have two data grids, the name of the cache are same, but data in the cache is different. I programmed a Java Client (Extend) to the data grid, the Java client is using a configuration file configured to connect with one of the data grids, the connection is configured in remote-cache-scheme section. Every time When I want to connect my Java Client to another data grid, I have to stop the JVM of the client and modify the configuration file.
    My question is can I switch to another data grid from my Java client without shutting down the Java Client's JVM and modify the configuration file? I noticed that in the caching-scheme-mapping section of client configuration, we can use the name to decide which grid to call, but in my case, the caches in both data grids has same name.

    I use this sample code to connect to two or more proxy extend with the same cache name.
    import com.tangosol.net.CacheFactory;
    import com.tangosol.net.CacheFactoryBuilder;
    import com.tangosol.net.ConfigurableCacheFactory;
    import com.tangosol.net.NamedCache;
    public class TestMultipleProxyAccess {
    public static void main(String[] args) {
    ClassLoader cl = TestMultipleProxyAccess.class.getClassLoader();
    String cacheConfigA = "client-cache-config-a.xml";
    String cacheConfigB = "client-cache-config-b.xml";
    CacheFactoryBuilder builder = CacheFactory.getCacheFactoryBuilder();
    ConfigurableCacheFactory ccfA = builder.getConfigurableCacheFactory(cacheConfigA, cl);
    NamedCache ncA = ccfA.ensureCache("myCache", cl);
    ConfigurableCacheFactory ccfB = builder.getConfigurableCacheFactory(cacheConfigB, cl);
    NamedCache ncB = ccfB.ensureCache("myCache", cl);
    }

  • Module Pool for displaying the Grid values in Matrix format

    Hi Experts,
    I have one requirement which as follows,
    In Module pool program i need to display the Grid Values in Matrix format i.e,
    Row = Color
    Column = Size
    Like what we can see in Sales order or Purchase Order if you click Grid Entries Button.
    Can you Please Help me out.
    Thanks n Advance.
    Logu

    Hi
    the sources ate the function groups WMMB and WMMA.
    In a new release you should find the function module MGW_UTILITIES_MATRIX_SHELL_RA
    the report RWRFMATCHARVAL is a good example
    Regards
    Björn

  • Displaying HTML in a java application

    Is there any other way to display HTML in a java application besides JEditorPane and JLabel (which are fairly restrictive). Its tableing I'm really after.

    Eureka!
    http://home.earthlink.net/~hheister/

  • Displaying database text to java components

    hello everyone!
    i d like to ask how i can display database elements in java components.
    For instance, i have a textarea and i d like to take the text from the database and display it in the textarea..
    In addition, i d like to submit a form and the text user entered in a textarea, to be inserted in a database field.
    Any tutorials with such examples would help me!
    Thank you

    That screencast is already some kind of a tutorial.
    Further tutorials and resources:
    Swing:
    [http://java.sun.com/docs/books/tutorial/ui/index.html|http://java.sun.com/docs/books/tutorial/ui/index.html]
    Java:
    [http://java.sun.com/docs/books/tutorial/|http://java.sun.com/docs/books/tutorial/]
    Beans Binding (JSR 295):
    [https://beansbinding.dev.java.net/|https://beansbinding.dev.java.net/]
    Java Persistence API (JPA):
    [http://java.sun.com/javaee/5/docs/tutorial/doc/bnbpy.html|http://java.sun.com/javaee/5/docs/tutorial/doc/bnbpy.html]
    (Maybe you also want to buy some book about this topic...)
    -Puce

  • Hide some cells while displaying ALV GRID !

    Hi guyz!
        Back with lill query,
        While displaying ALV GRID using REUSE_ALV_GRID... FMs ,i need to hide
        some cells by default, when the lists is generated.But those cells should
        be  availble to be displayed by the user from ALV layout settings.
        Please advise
    Thanks
    jahan

    Hi, Check for fm documentation.
    Only relevant if layout parameter
    LAYOUT-GET_SELINFOS of IMPORTING structure IS_LAYOUT is set.
    Complex type for modifying information displayed on the selection dialog box:
    mode:              'R' = Only entries passed in internal table
                              IS_SEL_HIDE-T_ENTRIES are output on
                              the dialog box. Selection information
                              obtained by the list tool by reading the
                              selection screen again (only if the report
                              is called with selection screen) are
                              replaced by the entries passed.
                       'S' = The selection information obtained by the
                              list tool by reading the selection screen
                              of the calling report again, are modified
                              by the entries of table
                              IS_SEL_HIDE-T_ENTRIES.
    t_entries:         Table with selection information
    t_entries-mode:   'A' = Display selection information of the current
                             table row on the information dialog box.
                      'D' = Do not display selection information of the
                             the Select option or of parameter SELNAME
                             on the dialog box.
    t_entries-selname: (required only if t_entries-mode = 'D')
                       name of Select option or parameter
    The following table fields are only required if t_entries-mode = 'A'. They contain the selection information to be added.
    t_entries-field:  DDIC field name of the field for which selection
                       information is to be displayed
    t_entries-table:  DDIC table name of t_entries-field.
    t_entries-stext:  Field description on the information dialog box.
                      If t_entries-field and t_entries-table were
                      filled, this text is taken from the DDIC.
    t_entries-valuf:  Selection condition from-value (external format)
    t_entries-valut:  Selection condition to-value (external format)
    t_entries-sign0:  (I)nclusive (E)xclusive
    t_entries-optio:  All values of the option field of the Select
                      option are allowed.
    The remaining fields are used internally and are irrelevant to the caller.
    aRs

  • How to display two grids in same screen using SALV Method

    Hi Freinds,
    Please let me know how to display two grids in same screen using SALV Method.
    Thank you
    Regards,
    SDV

    Using the same concept as described in How to dispaly Three Internal Table  Data (One below another) in ALV OOPS .
    All you need to add is passing your new containers as r_container parementer of factory method.
    "1st one
          cl_salv_table=>factory(
             EXPORTING
               R_CONTAINER    = g_top_container
    "2nd one
          cl_salv_table=>factory(
             EXPORTING
               R_CONTAINER    = g_bottom_container
    Regards
    Marcin

  • How to retrieve Task Lists from All Subsites to the Parent Site and display in Grid view using CAML Query

    How to retrieve Task Lists from All Subsites to the Parent Site and display in  Grid view using CAML Query + object model

    do u just want task list or items under task list for all subsites
    for items use spsitedataquery ref
    http://msdn.microsoft.com/en-us/library/microsoft.sharepoint.spsitedataquery.aspx use recursive to get it from alll subsite under site collection
    for tasklist only u can a simply use a for loop to find in all subsite
    Manish Sati

Maybe you are looking for

  • ODBC DSNless connection

    I created some ASP pages for a database and while onmy local machine everything was good. When uploaded to my host the connection failed and they suggested a DSNless connection, i reasearched it on the net and there were several tutorials but none of

  • How to update dynamically

    Hi I have a table name and the corressponding column names in the text fields...I want to update the fields for the table with the values present in another 2 text fields...I have written the following code.. begin update '||v(':p2_table_name')||' se

  • Where is java.util.Formatter?

    Java 1.5 supposedly introduced java.util.Formatter, which gives us a printf(). Running 'java -version' from the Terminal gives the following: +java version "1.5.0_16"+ +Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0_16-b06-284)+ +Java

  • Only Select date from date picker

    Hi All, How can I disable typing date in field text (Choose Date Component)? On other words the user can just select from date picker . Thanks Message was edited by: user638709

  • Sales Order in PCUI: Search for products based on BP?

    Hello, my customer wants to migrate to PC-UI and has the requirement that when creating a new sales order the search for products only returns those products that are defined by a partner-product relation PPR, as is possible in standard SAPGui. Unfor