what i did atm, it only appear as individual image(s)
import java.awt.BorderLayout;
import java.awt.Container;
import java.awt.FlowLayout;
import java.awt.GridLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.BorderFactory;
import javax.swing.ButtonGroup;
import javax.swing.ImageIcon;
import javax.swing.JCheckBox;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JRadioButton;
public class AutoCad extends JFrame {
JLabel test = new JLabel();
JLabel overlay = new JLabel();
public AutoCad() {
setTitle("AutoCad for Mentally Challenged");
setSize(575, 350);
setResizable(false);
setLocationRelativeTo(null);
setDefaultCloseOperation(EXIT_ON_CLOSE);
JRadioButton greenCmd = new JRadioButton("Green");
JRadioButton blueCmd = new JRadioButton("Blue");
JRadioButton blackCmd = new JRadioButton("Black");
JCheckBox windowCmd = new JCheckBox("Window");
JCheckBox doorCmd = new JCheckBox("Door");
JCheckBox chimneyCmd = new JCheckBox("Chimney");
JCheckBox mailboxCmd = new JCheckBox("Mailbox");
JPanel housePanel = new JPanel();
JPanel colorPanel = new JPanel();
JPanel partPanel = new JPanel();
Container pane = getContentPane();
pane.setLayout(new FlowLayout());
ButtonGroup colorGroup = new ButtonGroup();
pane.add(colorPanel, BorderLayout.CENTER);
colorPanel.setLayout(new GridLayout(3,0));
colorPanel.setBorder(BorderFactory.createTitledBorder(" Color "));
colorGroup.add(greenCmd);
colorPanel.add(greenCmd);
colorGroup.add(blueCmd);
colorPanel.add(blueCmd);
colorGroup.add(blackCmd);
colorPanel.add(blackCmd);
pane.add(partPanel,BorderLayout.WEST);
partPanel.setLayout(new GridLayout(4,0));
partPanel.setBorder(BorderFactory.createTitledBorder(" Parts "));
partPanel.add(windowCmd);
partPanel.add(doorCmd);
partPanel.add(chimneyCmd);
partPanel.add(mailboxCmd);
pane.add(housePanel, BorderLayout.EAST);
test.setIcon(new ImageIcon(getClass().getResource("image/greenhouse.jpg")));
housePanel.add(test);
greenCmd.setSelected(true);
greenCmd.addActionListener(new ActionListener()
{
public void actionPerformed (ActionEvent e)
{
test.setIcon(new ImageIcon(getClass().getResource("image/greenhouse.jpg")));
}
});
blueCmd.addActionListener(new ActionListener()
{
public void actionPerformed (ActionEvent e)
{
test.setIcon(new ImageIcon(getClass().getResource("image/bluehouse.jpg")));
}
});
blackCmd.addActionListener(new ActionListener()
{
public void actionPerformed (ActionEvent e)
{
test.setIcon(new ImageIcon(getClass().getResource("image/blackhouse.jpg")));
}
});
windowCmd.addActionListener(new ActionListener()
{
public void actionPerformed (ActionEvent e)
{
// overlay.setIcon(new ImageIcon(getClass().getResource("image/window.png")));
}
});
doorCmd.addActionListener(new ActionListener()
{
public void actionPerformed (ActionEvent e)
{
// overlay.setIcon(new ImageIcon(getClass().getResource("image/door.png")));
}
});
chimneyCmd.addActionListener(new ActionListener()
{
public void actionPerformed (ActionEvent e)
{
// overlay.setIcon(new ImageIcon(getClass().getResource("image/chimney.png")));
}
});
mailboxCmd.addActionListener(new ActionListener()
{
public void actionPerformed (ActionEvent e)
{
// overlay.setIcon(new ImageIcon(getClass().getResource("image/mail.png")));
}
});
setVisible(true);
}
public static void main(String[] args) {
new AutoCad();
}
}

New Topic/Question
Reply




MultiQuote





|