⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 maintoolbar.java

📁 一个用java写的地震分析软件(无源码)
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
    }

    JToggleButton makeToggleButton (String label, String iconFile, String tip)
    {
      JToggleButton btn = makeToggleButton(label, iconFile);
      btn.setToolTipText(tip);
      return btn;
    }

    JToggleButton makeToggleButton 
	(String label, String iconFile, String tip, char mnem) {
      JToggleButton btn = makeToggleButton(label, iconFile, tip);
      btn.setMnemonic(mnem);	 // doesn't work, needs more support for focus, actions?
      return btn;
    }

/**
 * Set a reference to the main frame so we can call its methods
 */
    public void setMainFrame (Jiggle frm)
    {
      mainFrame = frm;
    }


/**
 * Set anything on the main tool bar that is dependent on the MasterView. For example: <p>
 *  1) JOriginComboBox<p>
 */
    public void setMasterView(MasterView mv) {
	this.mv = mv;
//	makeSolPanelBox();
     solPanel.setMasterView(mv);

    }
    /**
    * Make/remake the guts of the Solution Panel box. It has already been added to
    * the tool bar.
    */
/*
    public void makeSolPanelBox() {

	if (mv == null || mv.solList.size() == 0) return;

     // remove any dangling references to old components in MVC model
     mv.solList.removeChangeListener(solCombo);
     mv.solList.removeChangeListener(typeChooser);
     mv.solList.removeChangeListener(fixDepthButton);

     // [EVENT]
	solCombo = new SolutionListComboBox (mv.solList);
	solCombo.addActionListener(new SolutionComboHandler() );
	// solCombo must update if selected event changes

	// [TYPE] set selected 'type' correctly
	typeChooser = new EventTypeChooser(mv.getSelectedSolution().getEventTypeString());
	typeChooser.addActionListener(new EventTypeComboHandler());;

     // [FIX]
     fixDepthButton = new FixDepthButton(mv);
     fixDepthButton.addActionListener(fixButtonHandler);

     mv.solList.addChangeListener(solCombo);
     mv.solList.addChangeListener(typeChooser);
     mv.solList.addChangeListener(fixDepthButton);

// NOTE: creating a new box distroys the reference to the solPanelBox in the solPanel
//     solPanelBox = Box.createHorizontalBox(); // new
     solPanelBox.removeAll();

     solPanelBox.add(solCombo);
     solPanelBox.add(Box.createHorizontalStrut(10));
     solPanelBox.add(typeChooser);
     solPanelBox.add(Box.createHorizontalStrut(10));
     solPanelBox.add(fixDepthButton);
     }
 */
/** Enable/disable components that only make sense when there's selected
event.  */
  public void setEventEnabled(boolean tf) {
    deleteButton.setEnabled(tf);
    finalButton.setEnabled(tf);
    saveButton.setEnabled(tf);
    saveAllButton.setEnabled(tf);
    locateButton.setEnabled(tf);
    mlButton.setEnabled(tf);
    mcButton.setEnabled(tf);
//    typeChooser.setEnabled(tf);        // may not exist yet
    newSolButton.setEnabled(tf);
    nextButton.setEnabled(tf);
    unpickButton.setEnabled(tf);
    solPanel.setEnabled(tf);

  }

/** Get the Solution ID from the box and select it */
/*
    class SolutionComboHandler implements ActionListener {

	// this is the action taken when the selectedOrigin is changed
	  public void actionPerformed(ActionEvent e) {

	        SolutionListComboBox jc = (SolutionListComboBox) e.getSource();
             Solution sol = jc.getSelectedSolution();

 	        mv.solList.setSelected( sol, true );
       }

    }
*/
/** Handle changes to eventType made by the EventTypeChooser
 */
/*
    class EventTypeComboHandler implements ActionListener {

	// this is the action taken when the event type is selected
      public void actionPerformed(ActionEvent e) {

        Solution sol = mv.solList.getSelected();

        if (sol == null) return; // no solution

	JComboBox jc = (JComboBox) e.getSource();

	if ( jc.getSelectedItem() == null ) return;  // internal setSelected event

	String type =  (String) jc.getSelectedItem();

	// no change = no action
	if (type.equalsIgnoreCase(sol.getEventTypeString())) return;

	//X// set the type of the selected event
     sol.setEventType(type);

	System.out.println ("Event type set to "+ type);
	//	System.out.println ("status = "+status+ "  type= "+type);

     // if its a QUARRY, ask for a comment but supply a default string of the form:
	// "BORON QUARRY, CA"
        if (type.equalsIgnoreCase("QUARRY")) {

          // fix depth at whatever, probably 0.0
          if (mainFrame.props.getBoolean("fixQuarryDepth")) {     // fix quarries?
             sol.depth.setValue(mainFrame.props.getDouble("quarryFixDepth"));
          }

	     WhereIsClosestFrom whereEngine =
		    new WhereIsClosestFrom(DataSource.getDefaultConnection());

          // construct default comment
          LatLonZ latlonz = sol.getLatLonZ();
	     whereEngine.setReference(latlonz.getLat(), latlonz.getLon(), latlonz.getZ());
	     WhereSummaryItem wsi = whereEngine.getClosestQuarry();
	     String placeString = wsi.fromPlaceString(false);
	     // must strip of " from " which the Where class always tacks on the place name
	     if (placeString.startsWith(" from")) placeString = placeString.substring(6);

	     System.out.println (placeString);

	     mainFrame.addComment(placeString);

     // if its not a LOCAL, ask for a comment but don't supply a default string
	   } else if (!type.equalsIgnoreCase("LOCAL")) {
	    mainFrame.addComment();
        }

       // do this to force a change event to notify listners
       mv.solList.setSelected(sol);

      // update title bar, etc.
//      mainFrame.updateTextViews();  // now done by listener

      }

    }  // end of EventTypeComboHandler

 class FixButtonHandler implements ActionListener {
	public void actionPerformed (ActionEvent evt) {

          fixDepthButton.toggle();

     }
 }
*/
// this is the contol panel's event handler class, does menus, buttons
    class ButtonHandler implements ActionListener
    {

    // actual event handling happens here (we're using the Java 1.1 model)
	public void actionPerformed (ActionEvent evt) {
        // save and make public the string of the menu item selected

          objSelected = evt;
	  EventName =  evt.getActionCommand();

 // Code responses to button, menu and list actions here...
 
 // *** a menu item
	if (EventName == "Exit")
	{
//	   appletParent.stop();    // calls Jiggle's stop() method
     mainFrame.stop();
	}

// *** if button push
	else if (EventName == "File")
	{
	    //	    mainFrame.fileChooser.show();
	}

	else if (EventName == "Locate")
	{
	    mainFrame.relocate();
	    //	    mv.locate (mainFrame.props);
	}

	else if (EventName == "ML")
	{
	    mainFrame.scanML();
	}

	else if (EventName == "MC")
	{
	    mainFrame.scanMC();
	}

	else if (EventName == "New Sol")	    // create an new blank origin
	{
	    mainFrame.createNewSolution();
	}

	else if (EventName == "Catalog") // Change focus to catalog tab
	{
	    mainFrame.tabPane.setSelectedIndex(mainFrame.TAB_CATALOG);	
	}
	/* Not needed anything that changes the loc will resort automatically
	if (EventName == "Sort")    // Sort/resort the WFViews 
	{ 
	    mainFrame.reSortWFViews();	
	} 
	*/
	else if (EventName == "Delete")	// load the currently selected ID
     {
		mainFrame.deleteCurrentSolution();
     }

	else if (EventName == "Repaint")
	{
	    mainFrame.repaint();
	}
	else if (EventName == "Save")
	{
	    mainFrame.saveToDb();
	}

	else if (EventName == "Final")
	{
	    mainFrame.finalToDb();
	}

	else if (EventName == "Next")
	{
	    mainFrame.loadNextSolution();
	}

	else if (EventName == "Save All")
	{
	    mainFrame.saveAllToDb();
	}

// repaint the panel to update labels, etc.
        repaint();

	}	    // end of actionPerformed
    }	// end of HandleEvent class

 } // end of class


⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -