3

最終的に、この小さな詳細を作成した後、建物と部屋番号を概説するために建物と部屋番号を受け取るので、簡単に見つけることができますが、単一の部屋に正確に近い長方形を描くことさえできません.

package programSTLApp;
/*
   Program to request the classroom no. in STLCC and Display the location of 
   that classroom.
 */

import javax.swing.*;
import java.awt.*;
import java.awt.event.*;

public class STLApp extends JFrame
{
    private JLabel imageLabel;
    private JButton button;
    private JPanel imagePanel;
    private JPanel buttonPanel;

public STLApp()
{
    super("My STLCC Class Locator");   

    setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    setLayout(new BorderLayout());
    buildImagePanel();
    buildButtonPanel();

    add(imagePanel, BorderLayout.CENTER);
    add(buttonPanel,BorderLayout.SOUTH);

    pack();
    setVisible(true);
}

private void buildImagePanel()
{
    imagePanel = new JPanel();
    imageLabel = new JLabel("Click the button to see the drawing indicating "
            + "the location of your class");
    imagePanel.add(imageLabel);
}

private void buildButtonPanel()
{
    buttonPanel = new JPanel();

    button = new JButton("Get Image");

    button.addActionListener(new ButtonListener());
    buttonPanel.add(button);
}

private class ButtonListener implements ActionListener
{
    @Override
    public void actionPerformed(ActionEvent e)
    {
        ImageIcon SiteLayoutFV = new ImageIcon("D:\\B120.jpg");
        imageLabel.setIcon(SiteLayoutFV);
        imageLabel.setText(null);
        pack();
    }

}
public void paint(Graphics g)
    {
        super.paint(g);
        g.setColor(Color.RED);
        g.fillRect(55,740,164,815);
    }


    public static void main(String[] args) 
    {
        new STLApp();


    }
}
4

1 に答える 1