java – Tengo que desplegar imágenes en un grid de 4×3, tengo mis imágenes y trato de implementarlas dentro de un JFrame, pero no funciona dejo mi código

En esta clase es donde debe generarse el panel de los objetos cartas, dentro de esta estoy tratando de crear un grid de 3×4 y generando objetos de la clase cartas, las cuales deberan ser desplegadas dentro del mismo grid

import java.awt.*;
    import javax.swing.*;
    import java.awt.Color;
    import java.awt.Container;
    import java.awt.Font;
    import java.awt.event.ActionListener;
    import java.awt.event.ActionEvent;
    import java.awt.*;
    import java.util.Random;
    import javax.swing.ImageIcon;
    import javax.swing.JButton;
    import javax.swing.JFrame;
    import javax.swing.JLabel;
    import javax.swing.JOptionPane;
    import javax.swing.JTextField;
    import javax.swing.JPanel;

    /**
     * Tablero
     */
    public class Tablero extends JFrame {
    //Atributos
    private Carta() cartas;
    private Carta carta1;
    private Carta carta2;
    private Jugador() jugadores;
    private int paresEncontrados;
    private java.awt.Image ban;
    private java.awt.Image elizabeth;
    private java.awt.Image escanor;
    private java.awt.Image meliodas;
    private java.awt.Image merlin;
    private java.awt.Image diana;
        //Constructor
        public Tablero(){
            super();
            this.jugadores=jugadores;
            //Instruccion para cerrar
            this.setDefaultCloseOperation(EXIT_ON_CLOSE);
            //Establecer el tamaño del Layout
            this.setLayout(new GridLayout(3, 4));
            //Constructor para las imagenes
            //---------------------------------------------------------
            ban=new ImageIcon("Ban.png").getImage();
            //---------------------------------------------------------
            //agregar nuestras cartas
            for (int i = 0; i < 11; i++) {  
                cartas(i)=new Carta("Papi Ban", ban);
            }
            this.pack();
            this.setVisible(true);
        }

        public void setCarta1(Carta carta1){
            this.carta1=carta1;
        }

        public void setCarta2(Carta carta2){
            this.carta2=carta2;
        }

        public static void main(String() args) {
            Tablero t1 = new Tablero();
        }
    }

Clase Carta para crear los objetos dentro de esta clase es donde genero los objetos carta que posteriormente seran recibidos y utilizados para crear nuestro panel con imagenes

import java.awt.*;
import javax.swing.*;
import javax.swing.JPanel;
import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;

    /**
     * Carta
     */
    public class Carta extends JPanel implements MouseListener {
        //Atributos
        private String nombre;
        private java.awt.Image imagen;
        private boolean estado;
        private boolean encontrada;
        //----------------------------
        //Atributos para tomar decisiones
        private boolean parEncontrada;
        private boolean equals;
        //constructor default
        public Carta(){
            this.nombre="";
            this.imagen=imagen;
        }
        //Constructor con parametros
        public Carta(String nombre, java.awt.Image imagen){
            super();
            this.nombre=nombre;
            this.imagen=imagen; 
        }
        public Color generaColor() {
            // Generador de Color
            int rojo = (int) (236);
            int azul = (int) (126);
            int verde = (int) (156);
            // Creando el objeto color
            Color cover = new Color(rojo, verde, azul);
            return cover;
        }
        public void pintaCarta(Graphics g) { //Must check this one out
            super.paintComponent(g);
             //Para darle tamaño y acciones a los cuadros
             this.setPreferredSize(new Dimension(200, 200));
             this.addMouseListener(this);
             // Asignar el fondo
             this.setBackground(generaColor());
        }
        //Metodos para el funcionamiento del juego
        //---------------------------------------------------------------------------------
        //Revisara si la carta esta abierta o cerrada, en caso de estar cerrada esta se abrira al click false=cerrada true=abierta
        public boolean abrir() {
            if (estado==false) {
                estado=true;
                return estado=true;
            }else{
                return estado=false;
            }
        }
        //Revisara si la carta ya tiene su par, en caso de no haber encontrado su par y que esta se haya abierto se cerrara
        public boolean cerrar(){
            if (estado==true && parEncontrada==false) {
                return true;
            }else{
                return false;
            }
        }
        //Va a determinar si la carta que esta abierta encontro su par o no 
        public void parEncontrado() {
            if (equals==true) {
                parEncontrada=true;
            }else{
                parEncontrada=false;
            }
        }


       /* public boolean iguales(Carta otra){
            if (==otra) {
                return equals=true;
            }else{
                return equals=false;
            }
        }
            /*public String toString(){ //Hace falta este metodo 
                String resultado="";
                for (int i = 0; i < array.length; i++) {
                    resultado+=("n");
                }
        }*/
        //---------------------------------------------------------------------------------
        //Metodos para manejar los eventos del mouse
        @Override
        public void mouseClicked(MouseEvent e) {
            this.setBackground(generaColor());

        }
        @Override
        public void mousePressed(MouseEvent e) {
            // TODO Auto-generated method stub

        }
        @Override
        public void mouseReleased(MouseEvent e) {
            // TODO Auto-generated method stub

        }
        @Override
        public void mouseEntered(MouseEvent e) {
            // TODO Auto-generated method stub

        }
        @Override
        public void mouseExited(MouseEvent e) {
            // TODO Auto-generated method stub

        }


}

Al tratar de compilar me sale el siguiente error:

Exception in thread "main" java.lang.NullPointerException
        at Tablero.<init>(Tablero.java:48)
        at Tablero.main(Tablero.java:64)

Este es un grid 4x3 que hice con colores
El punto es que se genere algo como esto pero con imagenes en lugar de con colores

magento2.3 – Magento2 Grid: Select all disabled with two dropdown filters

A client running a magento 2.3.2. store noted that he can not use the Select All when two Filters are enabled. This pertains to the Magento Grid with orders on the Sales page. The filters the client is using are Status & Storeview.

I tested this behavior and can confirm that when he uses 2 Dropdown filters, the Select All functionality gets disabled. The disabling works through adding a ‘disabled’ attribute to both the input & button element. Other combinations of filters do not seem to have this behavior. When I manually remove the attributes (devtools) the functionality seems to work properly.

My questions.

  1. Is there a good reason why the ‘Select All’ gets disabled on selecting 2 dropdown filters? The disabling seems intentional, so I figure it is not a bug?

  2. If there is no reason, I might want to adjust this behavior. Could you point me in the right direction to where this behavior is set?

I appreciate any helpful input.

game design – 3D World; how do I deal with the thickness of walls on a grid to create a tile based building system

I want to develop a tile based 3D building system as a foundation for an game. But there is a question which is cracking my mind a bit.

I am grateful for every thought, hint, link or book suggestion.

How do I deal with the thickness of walls on a grid, respectivelly how should I realize walls?

I used the search engine, watched at other games on steam & youtube, but the result & my conclusion is not really satisfying.

What is the most common way, which causes the least problems in your oppinion?

The game-engine i want to use is Godot.

This are the 3 options which I have, at least I think this are the 3 I have:

(1) Wall as a plane
Wall as a plane

I think this option causes not much problems, but it is also the least attractive option because it doesn’t look that great to a player.

The wall is flat, the positioning of items in front of the wall, on both sides shouldn’t make problems because. The wall has no thickness, so there is no offset related to the grid.

(2) Wall in size of the grid
Wall in size of the grid

I think this option causes the least problems, but probably you get really thick looking walls if your grid is to big & with a smaller grid you maybe get other problems (performance issues or something else).

The wall doesn’t affect the positioning of items in front of the wall, on both sides. The wall has thickness, but the thickness doesn’t results in an offset related to the grid.

Currently I think this is the option I should stick with, but to get walls which are not that thick, I believe I should create a grid with a size of .5 or .25 when you relate 1 to an meter (walls in germany are about 25 till 50 cm).

Maybe I worry too much about the size of the walls?

(3) Wall overlapping the grid
Wall overlapping the grid

I think this option makes the most headache, at least for me. With this option you have a offset resulting from the thickness of the wall. Because it’s overlapping the floor tiles half the walls thickness, so you have to deal with the placement of items in front of the wall & currently I have no idea to deal with.

html – ¿En css grid porque las cuadriculas desbordan el contenedor cuando tengo imagenes dentro de divs?

Estoy intentando hacer una galeria de imagenes con css grid pero las cuadriculas desbordan el contenedor, cuando solo pongo divs dentro del container todo va bien, el problema es cuando anido imagenes dentro de los divs.

<div class="container">
    <div class="item"><img src="https://es.stackoverflow.com/img/im1.jpg" alt=""></div>
    <div class="item"><img src="img/im2.jpg" alt=""></div>
    <div class="item"><img src="img/im3.jpg" alt=""></div>
    <div class="item"><img src="img/im4.jpg" alt=""></div>
    <div class="item"><img src="img/im14.jpg" alt=""></div>
    <div class="item"><img src="img/img.jpg" alt=""></div>
    <div class="item"><img src="img/img0.jpg" alt=""></div>
    <div class="item"><img src="img/img5.jpg" alt=""></div>
    <div class="item"><img src="img/img6.jpg" alt=""></div>
    <div class="item"><img src="img/img7.jpg" alt=""></div>
    <div class="item"><img src="img/img8.jpg" alt=""></div>
    <div class="item"><img src="img/img9.jpg" alt=""></div>
</div>

Proof on "No rectangles" on a grid

I was solving a problem of the UVA judge called “No rectangles”. They claim the following in the statement of the problem

It can easily be shown that for any given value of $k$, $k^2 − k + 1$ is a
lower bound on the value of $n$, and it can be shown further that $n$ need
never be larger than this.

Proving this statement is not necessary to solve the problem. However, I’ve been thinking on how to prove it and I do not know how I could do it. Any hints/clues?

8 – Layouts using the grid system

How can I lay out blocks or paragraphs using Bootstrap’s grid system? I found this seven-year-old answer and am hoping things have evolved since then, and if so would like to know how.

My best stab at cobbling together something at this point is to use Paragraphs for the content and use the Block Class module to assign the desired Bootstrap class to each paragraph type. Is there a more obvious and cleaner solution to the problem in Drupal 8?

grid – Image gallery multiselection tips

I’m making a gallery of images in a grid and I have a few concerns. The user is able to see metadata when hover over a picture and also select multiple images.

Hovering over an image

enter image description here

Selecting an image

enter image description here

My concerns

For the most part this works. However there are a few things bugging me a bit:

  1. The checkmark appears where the delete icon was. Is this placement ok, or is it going to annoy a user?
  2. What would be the ideal way to hint a user that the image they hover over is selectable?
  3. What would the ideal placement of the checkmark be? I put it where it is for 3 main reasons; (1) it “blocks” the delete button that earlier was there, (2) on the left side it would be hiding the metadata when hovering, (3) it seems reasonable to keep it on the top to be more noticeable.
  4. The border colour looks greenish for certain images. Is there a safe colour in this case that is not perceived differently depending on the image? Currently I gave it the colour that is used in forms on other places of the website for consistency.
  5. The user can still hover over selected images to get the metadata. Is this a good idea?

Open to any other tips and comments.

magento2 – Custom filter in order grid

I’m trying to add a new field to order grid with custom filter. Right now I managed to make it work, but I want to add my custom filtering rule.

I added the column to db_schema.xml and in my module’s sales_order_grid.xml file I added:

<columns name="sales_order_columns">
    <column name="custom_field">
        <settings>
            <filter>select</filter>
            <options class="MyModuleComponentListingColumnsCustomFieldOptions" />
            <dataType>select</dataType>
            <label translate="true">Custom Field</label>
            <visible>true</visible>
        </settings>
    </column>
</columns>

And in my CustomFieldOptions class I have:

<?php
declare(strict_types=1);

namespace MyModuleComponentListingColumns;

use MagentoFrameworkDataOptionSourceInterface;

class CustomFieldOptions implements OptionSourceInterface
{
    /**
     * @var string
     */
    private const VALUE = 'value';

    /**
     * @var string
     */
    private const LABEL = 'label';

    /**
     * Return array of options as value-label pairs
     *
     * @return array Format: array(array('value' => '<value>', 'label' => '<label>'), ...)
     */
    public function toOptionArray() :array
    {
        return (
            (
                self::VALUE => 1,
                self::LABEL => 'Realized'
            ),
            (
                self::VALUE => 0,
                self::LABEL => 'Outdated'
            ),
            (
                self::VALUE => -1,
                self::LABEL => 'Canceled'
            )
        );
    }
}

My custom_field is DateTime, but I want to filter it using those 3 CustomFieldOptions parameters:
Custom field in order grid with filter

I want to specify my own filtering rule (for example option Canceled should filter only records with null value of my custom_field, Outdated should return records with custom_field value that’s older than current day).

Can you help me with what should I do now? Thanks in advance!

magento2 – cannot filter a linked column in the grid

I'm using Magento 2.2.x, I've added a new column that is a connected column between two tables. I can view this column data and it all works fine and like magic, but when I try to filter on that column it didn't work. t work for me, can someone tell me where the problem is here i will be grateful 🙂

My code and tables are below:

Here is my Collection.php

 protected function _initSelect()
    {
        parent::_initSelect();

        $this
            ->join(
                ('dealer' => $this->getTable('amasty_perm_dealer')),
                'dealer.entity_id = main_table.dealer_id',
                ('city' => 'main_table.city')
            );

        $this->addFilterToMap('city', 'main_table.city');

        return $this;
    }

Here is the block:



    
        
            
                
                    
                        
                            City
                            text
                            MymoduleDealerBlockAdminhtmlDealerGridDealerCity
                        
                    
                
            
        
    

and here are the two tables

  • main_table:
    Enter the image description here

  • Dealer table:
    Enter the image description here