有 Java 编程相关的问题?

你可以在下面搜索框中键入要查询的问题!

形状矩形厚度java

我需要在选定的时间用蓝色1矩形勾勒出轮廓。代码运行正常,但我看不太清楚蓝色的轮廓。使轮廓更粗的最简单方法是什么。在上面画另一个形状或其他东西

private void displayBlock(Graphics g)
{
    for(int i = 0; i < 10; i++)
    {

        if (occupant[i].equals("Empty"))
        {
            //Sets the rectangle red to show the room is occupied
            g.setColor(emptyColor);
            g.fillRect(150+(i*50), 120, aptWidth, aptHeight);

        }
        else
        {
            //Sets the rectangle green to show the room is free
            g.setColor(Color.red);
            g.fillRect(150+(i*50), 120, aptWidth, aptHeight);               
        }
        if (i == selectedApartment)
        {

            g.setColor(Color.blue);
            g.drawRect(150+(i*50), 120, aptWidth, aptHeight);

        }
        else
        {
            g.setColor(Color.black);
            g.drawRect(150+(i*50), 120, aptWidth, aptHeight);
        }

        // Draws the numbers in the Corresponding boxes
        g.setColor(Color.black);
        g.drawString(Integer.toString(i+1), 150+(i*50)+15, 120+25);
    }

    //Drawing the key allowing the user to see what the colours refer to
    g.setFont(new Font("TimesRoman", Font.PLAIN, 14));
    g.drawString("Key", 20,120);
    g.drawString("Occupied",60,150);
    g.drawString("Empty", 60, 170);

    // Drawing the boxes to show what the colours mean in the key             
    g.setColor(Color.red);
    g.fillRect(20, 130, 25, 25);
    g.setColor(Color.black);
    g.drawRect(20, 130, 25, 25);
    g.setColor(Color.green);
    g.fillRect(20,150,25,25);
    g.setColor(Color.black);
    g.drawRect(20,150,25,25);

} // End of displayBlock

共 (0) 个答案