// GUI PARA LA EDICION DE CIRCUITOS
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import javax.swing.border.*;
import java.applet.Applet;
import java.net.URL;
public class Interfaz extends JFrame {
JPanel FondoGeneral;
JMenuBar jMenuBar1 = new JMenuBar();
JMenu MenuArchivo = new JMenu();
JMenuItem Abrir = new JMenuItem();
JMenuItem Guardar = new JMenuItem();
JMenuItem Salir = new JMenuItem();
JMenu MenuAyuda = new JMenu();
JMenuItem HacercaDe = new JMenuItem();
AreaGrafica Area = new AreaGrafica(640, 319, this); // Son las dimensiones Icon Resistencia = new ImageIcon("Resistencia_00.jpg");
Icon Bobina = new ImageIcon("Bobina_00.jpg");
Icon Capacitor = new ImageIcon("Capacitor_00.jpg");
Icon Fuente = new ImageIcon("Fuente_00.jpg");
Icon Linea = new ImageIcon("Linea.jpg");
JButton BResistencia = new JButton();
JButton BBobina = new JButton();
JButton BCapacitor = new JButton();
JButton BFuente = new JButton();
JButton BLinea = new JButton();
JLabel jLabel1 = new JLabel();
JTextField Coords = new JTextField();
TitledBorder titledBorder1;
//Construct the frame
public Interfaz() {
enableEvents(AWTEvent.WINDOW_EVENT_MASK);
try {
jbInit();
}
catch(Exception e) {
e.printStackTrace();
}
}
//Component initialization
private void jbInit() throws Exception {
//setIconImage(Toolkit.getDefaultToolkit().createImage(Interfaz.class.getResource("[Your Icon]")));
FondoGeneral = (JPanel) this.getContentPane();
titledBorder1 = new TitledBorder("");
FondoGeneral.setLayout(null);
this.setSize(new Dimension(676, 461));
MenuArchivo.setText("Archivo");
Abrir.setText("Abrir");
Abrir.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
EventoAbrir(e);
}
});
Guardar.setText("Guardar");
Guardar.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
EventoGuardar(e);
}
});
Salir.setText("Salir");
Salir.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
EventoSalir(e);
}
});
MenuAyuda.setText("Ayuda");
HacercaDe.setText("Hacerca de");
HacercaDe.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
EventoHacercaDe(e);
}
});
BResistencia.setBackground(Color.white);
BResistencia.setBounds(new Rectangle(13, 371, 55, 21));
BResistencia.setBorder(BorderFactory.createEtchedBorder());
BResistencia.setIcon(Resistencia);
BResistencia.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(ActionEvent e) {
RESISTENCIA(e);
}
});
BBobina.setBackground(Color.white);
BBobina.setBounds(new Rectangle(72, 372, 74, 21));
BBobina.setBorder(BorderFactory.createEtchedBorder());
BBobina.setIcon(Bobina);
BBobina.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(ActionEvent e) {
BOBINA(e);
}
});
BCapacitor.setBackground(Color.white);
BCapacitor.setBounds(new Rectangle(150, 365, 51, 30));
BCapacitor.setBorder(BorderFactory.createEtchedBorder());
BCapacitor.setIcon(Capacitor);
BCapacitor.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(ActionEvent e) {
CAPACITOR(e);
}
});
BFuente.setBackground(Color.white);
BFuente.setBounds(new Rectangle(205, 367, 53, 29));
BFuente.setBorder(BorderFactory.createEtchedBorder());
BFuente.setIcon(Fuente);
BFuente.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(ActionEvent e) {
FUENTE(e);
}
});
BLinea.setBackground(Color.white);
BLinea.setBounds(new Rectangle(262, 373, 37, 24));
BLinea.setBorder(BorderFactory.createEtchedBorder());
BLinea.setIcon(Linea);
BLinea.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(ActionEvent e) {
LINEA(e);
}
});
FondoGeneral.setBackground(UIManager.getColor("PasswordField.selectionBackground"));
FondoGeneral.setBorder(BorderFactory.createLoweredBevelBorder());
jLabel1.setText("____________________________________________________________________________________________");
jLabel1.setBounds(new Rectangle(12, 345, 652, 14));
Coords.setBorder(BorderFactory.createLineBorder(Color.black));
Coords.setBounds(new Rectangle(302, 377, 351, 21));
Area.setBounds(new Rectangle(16, 26, 640, 319));
MenuArchivo.add(Abrir);
MenuArchivo.add(Guardar);
MenuArchivo.add(Salir);
MenuAyuda.add(HacercaDe);
jMenuBar1.add(MenuArchivo);
jMenuBar1.add(MenuAyuda);
FondoGeneral.add(jLabel1, null);
FondoGeneral.add(Area, null);
FondoGeneral.add(BResistencia, null);
FondoGeneral.add(BBobina, null);
FondoGeneral.add(BCapacitor, null);
FondoGeneral.add(BFuente, null);
FondoGeneral.add(BLinea, null);
FondoGeneral.add(Coords, null);
this.setJMenuBar(jMenuBar1);
}
//File | Exit action performed
public void EventoAbrir(ActionEvent e) { }
//File | Exit action performed
public void EventoGuardar(ActionEvent e) { }
//File | Exit action performed
public void EventoSalir(ActionEvent e) { System.exit(0); }
//Help | About action performed
public void EventoHacercaDe(ActionEvent e) { }
//Overridden so we can exit when window is closed
protected void processWindowEvent(WindowEvent e) {
super.processWindowEvent(e);
if (e.getID() == WindowEvent.WINDOW_CLOSING) {
EventoSalir(null);
}
}
void RESISTENCIA(ActionEvent e) { Area.Inserta("Resistencia"); }
void BOBINA(ActionEvent e) { Area.Inserta("Bobina"); }
void CAPACITOR(ActionEvent e) { Area.Inserta("Capacitor"); }
void FUENTE(ActionEvent e) { Area.Inserta("Fuente"); }
void LINEA(ActionEvent e) { Applet A = new Applet();
A.play(A.getDocumentBase(), "ding.au");
}
// Area.Inserta("Linea"); }
void MovimientoDelRatonEnArea(MouseEvent e)
{ Coords.setText("" + e.getX() + "," + e.getY()); }
}