/* A basic implementation of the JFrame class. */ package application.draw; import java.awt.Dimension; import java.awt.Font; import java.awt.Insets; import java.awt.MediaTracker; import java.net.URL; import java.util.Vector; import controlledparts.*; import javax.swing.ImageIcon; public class FigSelectFrame extends javax.swing.JFrame implements FrameWithControlledButton, StateContainer { public boolean isDirectOperation() { return draw.isDirectOperation(); } public int getState() { return this.currentState; } public int currentState; public void setState(int i) { ControlledButton b=(ControlledButton)(buttons.elementAt(i)); draw.figSelectorButton.setText(b.getText()); draw.figSelectorButton.setIcon(b.getIcon()); draw.figSelectorButton.repaint(); this.currentState=i; } public boolean isControlledByLocalUser() { // This method is derived from interface FrameWithControlledButton // to do: code goes here return draw.isControlledByLocalUser(); } public void sendEvent(String x) { this.draw.sendEvent("dfig."+x); } public void unfocusButton(int i) { SelectedButton button=(SelectedButton)(buttons.elementAt(i)); // button.controlledButton_mouseExited(null); button.unFocus(); } public void focusButton(int i) { SelectedButton button=(SelectedButton)(buttons.elementAt(i)); button.focus(); } public void clickButton(int i) { ControlledButton b=(ControlledButton)(buttons.elementAt(i)); b.click(); this.mouseClickedAtButton(i); } public void mouseExitedAtButton(int i) { // This method is derived from interface SelectButtonsFrame // to do: code goes here // draw.sendEvent("dfig.btn.exit("+i+")\n"); } public void mouseEnteredAtButton(int i) { // This method is derived from interface SelectButtonsFrame // to do: code goes here // draw.sendEvent("dfig.btn.enter("+i+")\n"); } public void mouseClickedAtButton(int i) { // This method is derived from interface SelectButtonsFrame // to do: code goes here if(this.closeButton.getID()==i){ this.hide(); return; } ControlledButton b=(ControlledButton)(buttons.elementAt(i)); if(draw!=null){ this.setState(i); draw.editdispatch.newFig(draw.figSelectorButton.getText()); } this.hide(); } public Vector buttons; public DrawFrame draw; public void setDraw(DrawFrame f) { this.draw=f; } public void setIcons(String iconPlace){ try{ this.lineButton.setIcon(new ImageIcon(new URL(iconPlace+"lineImage.gif"))); this.freeButton.setIcon(new ImageIcon(new URL(iconPlace+"freeImage.gif"))); this.boxButton.setIcon(new ImageIcon(new URL(iconPlace+"boxImage.gif"))); this.ovalButton.setIcon(new ImageIcon(new URL(iconPlace+"ovalImage.gif"))); this.linesButton.setIcon(new ImageIcon(new URL(iconPlace+"linesImage.gif"))); this.polygonButton.setIcon(new ImageIcon(new URL(iconPlace+"polygonImage.gif"))); this.curveButton.setIcon(new ImageIcon(new URL(iconPlace+"curveImage.gif"))); this.fillBoxButton.setIcon(new ImageIcon(new URL(iconPlace+"fiiBoxImage.gif"))); this.fillOvalButton.setIcon(new ImageIcon(new URL(iconPlace+"fiiOvalImage.gif"))); this.textButton.setIcon(new ImageIcon(new URL(iconPlace+"textImage.gif"))); this.loadButton.setIcon(new ImageIcon(new URL(iconPlace+"loadImage.gif"))); this.imageButton.setIcon(new ImageIcon(new URL(iconPlace+"imageimage.gif"))); } catch(Exception e){} } public FigSelectFrame() { // This code is automatically generated by Visual Cafe when you add // components to the visual environment. It instantiates and initializes // the components. To modify the code, only use code syntax that matches // what Visual Cafe can generate, or Visual Cafe may be unable to back // parse your Java file into its visual environment. //{{INIT_CONTROLS getContentPane().setLayout(null); getContentPane().setBackground(new java.awt.Color(204,204,204)); setSize(193,387); setVisible(false); //$$ imageIcon.move(312,396); //$$ lineBorder1.move(0,396); //$$ lineBorder2.move(24,396); lineButton.setText("line"); lineButton.setActionCommand("line"); getContentPane().add(lineButton); lineButton.setBackground(new java.awt.Color(204,204,204)); lineButton.setForeground(java.awt.Color.black); lineButton.setFont(new Font("Dialog", Font.BOLD, 12)); lineButton.setBounds(12,12,156,24); freeButton.setText("free"); freeButton.setActionCommand("free"); getContentPane().add(freeButton); freeButton.setBackground(new java.awt.Color(204,204,204)); freeButton.setForeground(java.awt.Color.black); freeButton.setFont(new Font("Dialog", Font.BOLD, 12)); freeButton.setBounds(12,36,156,24); linesButton.setText("lines"); linesButton.setActionCommand("lines"); getContentPane().add(linesButton); linesButton.setBackground(new java.awt.Color(204,204,204)); linesButton.setForeground(java.awt.Color.black); linesButton.setFont(new Font("Dialog", Font.BOLD, 12)); linesButton.setBounds(12,60,156,24); boxButton.setText("box"); boxButton.setActionCommand("box"); getContentPane().add(boxButton); boxButton.setBackground(new java.awt.Color(204,204,204)); boxButton.setForeground(java.awt.Color.black); boxButton.setFont(new Font("Dialog", Font.BOLD, 12)); boxButton.setBounds(12,108,156,24); ovalButton.setText("oval"); ovalButton.setActionCommand("oval"); getContentPane().add(ovalButton); ovalButton.setBackground(new java.awt.Color(204,204,204)); ovalButton.setForeground(java.awt.Color.black); ovalButton.setFont(new Font("Dialog", Font.BOLD, 12)); ovalButton.setBounds(12,132,156,24); fillBoxButton.setText("fillBox"); fillBoxButton.setActionCommand("fillBox"); getContentPane().add(fillBoxButton); fillBoxButton.setBackground(new java.awt.Color(204,204,204)); fillBoxButton.setForeground(java.awt.Color.black); fillBoxButton.setFont(new Font("Dialog", Font.BOLD, 12)); fillBoxButton.setBounds(12,156,156,24); fillOvalButton.setText("fillOval"); fillOvalButton.setActionCommand("fillOval"); getContentPane().add(fillOvalButton); fillOvalButton.setBackground(new java.awt.Color(204,204,204)); fillOvalButton.setForeground(java.awt.Color.black); fillOvalButton.setFont(new Font("Dialog", Font.BOLD, 12)); fillOvalButton.setBounds(12,180,156,24); polygonButton.setText("polygon"); polygonButton.setActionCommand("polygon"); getContentPane().add(polygonButton); polygonButton.setBackground(new java.awt.Color(204,204,204)); polygonButton.setForeground(java.awt.Color.black); polygonButton.setFont(new Font("Dialog", Font.BOLD, 12)); polygonButton.setBounds(12,204,156,24); textButton.setText("text"); textButton.setActionCommand("text"); getContentPane().add(textButton); textButton.setBackground(new java.awt.Color(204,204,204)); textButton.setForeground(java.awt.Color.black); textButton.setFont(new Font("Dialog", Font.BOLD, 12)); textButton.setBounds(12,228,156,24); loadButton.setText("loadText"); loadButton.setActionCommand("loadText"); getContentPane().add(loadButton); loadButton.setBackground(new java.awt.Color(204,204,204)); loadButton.setForeground(java.awt.Color.black); loadButton.setFont(new Font("Dialog", Font.BOLD, 12)); loadButton.setBounds(12,252,156,24); imageButton.setText("image"); imageButton.setActionCommand("image"); getContentPane().add(imageButton); imageButton.setBackground(new java.awt.Color(204,204,204)); imageButton.setForeground(java.awt.Color.black); imageButton.setFont(new Font("Dialog", Font.BOLD, 12)); imageButton.setBounds(12,276,156,24); curveButton.setText("curve"); curveButton.setActionCommand("curve"); getContentPane().add(curveButton); curveButton.setBackground(new java.awt.Color(204,204,204)); curveButton.setForeground(java.awt.Color.black); curveButton.setFont(new Font("Dialog", Font.BOLD, 12)); curveButton.setBounds(12,84,156,24); closeButton.setText("close"); closeButton.setActionCommand("close"); getContentPane().add(closeButton); closeButton.setBackground(new java.awt.Color(204,204,204)); closeButton.setForeground(java.awt.Color.black); closeButton.setFont(new Font("Dialog", Font.BOLD, 12)); closeButton.setBounds(12,336,156,24); urlBoxButton.setText("urlBox"); urlBoxButton.setActionCommand("urlBox"); getContentPane().add(urlBoxButton); urlBoxButton.setBackground(new java.awt.Color(204,204,204)); urlBoxButton.setForeground(java.awt.Color.black); urlBoxButton.setFont(new Font("Dialog", Font.BOLD, 12)); urlBoxButton.setBounds(12,300,156,24); //}} //{{INIT_MENUS //}} //{{REGISTER_LISTENERS SymAction lSymAction = new SymAction(); lineButton.addActionListener(lSymAction); freeButton.addActionListener(lSymAction); linesButton.addActionListener(lSymAction); boxButton.addActionListener(lSymAction); ovalButton.addActionListener(lSymAction); fillBoxButton.addActionListener(lSymAction); fillOvalButton.addActionListener(lSymAction); polygonButton.addActionListener(lSymAction); textButton.addActionListener(lSymAction); loadButton.addActionListener(lSymAction); imageButton.addActionListener(lSymAction); curveButton.addActionListener(lSymAction); closeButton.addActionListener(lSymAction); urlBoxButton.addActionListener(lSymAction); //}} // buttons=new Vector(); buttons.addElement(lineButton); buttons.addElement(freeButton); buttons.addElement(linesButton); buttons.addElement(boxButton); buttons.addElement(ovalButton); buttons.addElement(fillBoxButton); buttons.addElement(fillOvalButton); buttons.addElement(polygonButton); buttons.addElement(textButton); buttons.addElement(loadButton); buttons.addElement(imageButton); buttons.addElement(curveButton); buttons.addElement(this.urlBoxButton); buttons.addElement(this.closeButton); int numberOfButtons=buttons.size(); for(int i=0;i