當前位置: 首頁>>代碼示例>>Java>>正文


Java RadioButton.setUserData方法代碼示例

本文整理匯總了Java中javafx.scene.control.RadioButton.setUserData方法的典型用法代碼示例。如果您正苦於以下問題:Java RadioButton.setUserData方法的具體用法?Java RadioButton.setUserData怎麽用?Java RadioButton.setUserData使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在javafx.scene.control.RadioButton的用法示例。


在下文中一共展示了RadioButton.setUserData方法的12個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: createButtonGroup

import javafx.scene.control.RadioButton; //導入方法依賴的package包/類
/**
 * Create a radio button for each String in the list, add them to the container, and bind the selected value to the
 * String property
 *
 * @param container     Container to put radio buttons in
 * @param radioBtns     List of Strings, one for each radio button
 * @param modelProperty Property to bind selected radio button's value to
 */
public static ToggleGroupValue createButtonGroup(Pane container, List<String> radioBtns, StringProperty modelProperty) {
    // Create new ToggleGroup and ToggleGroupValue for the radio buttons
    ToggleGroupValue groupValue = new ToggleGroupValue();
    ToggleGroup btnsGroup = new ToggleGroup();

    // Create a radio button for each option
    for (String s : radioBtns) {
        // Create radio button for this option
        RadioButton radioBtn = new RadioButton(s);
        radioBtn.setUserData(s);
        radioBtn.setToggleGroup(btnsGroup);

        // Add to RadioButton to the container pane and the ToggleGroupValue
        container.getChildren().add(radioBtn);
        groupValue.add(radioBtn, radioBtn.getUserData());
    }

    // Bind toggle group value to model
    modelProperty.bindBidirectional(groupValue.valueProperty());

    // Select first option
    groupValue.setValue(radioBtns.get(0));

    return groupValue;
}
 
開發者ID:scify,項目名稱:jedai-ui,代碼行數:34,代碼來源:RadioButtonHelper.java

示例2: setupToggle

import javafx.scene.control.RadioButton; //導入方法依賴的package包/類
private LinkedList<RadioButton> setupToggle(ToggleGroup group) {

		// Use Dijkstra as default
		RadioButton rbD = new RadioButton("Dijkstra");
		rbD.setUserData("Dijkstra");
		rbD.setSelected(true);

		RadioButton rbA = new RadioButton("A*");
		rbA.setUserData("A*");

		RadioButton rbB = new RadioButton("BFS");
		rbB.setUserData("BFS");

		rbB.setToggleGroup(group);
		rbD.setToggleGroup(group);
		rbA.setToggleGroup(group);
		return new LinkedList<RadioButton>(Arrays.asList(rbB, rbD, rbA));
	}
 
開發者ID:Cs4r,項目名稱:UCSDGraphs,代碼行數:19,代碼來源:MapApp.java

示例3: setupToggle

import javafx.scene.control.RadioButton; //導入方法依賴的package包/類
private LinkedList<RadioButton> setupToggle(ToggleGroup group) {

	  // Use Dijkstra as default
	  RadioButton rbD = new RadioButton("Dijkstra");
	  rbD.setUserData("Dijkstra");
	  rbD.setSelected(true);

	  RadioButton rbA = new RadioButton("A*");
	  rbA.setUserData("A*");

	  RadioButton rbB = new RadioButton("BFS");
	  rbB.setUserData("BFS");

	  rbB.setToggleGroup(group);
	  rbD.setToggleGroup(group);
	  rbA.setToggleGroup(group);
	  return new LinkedList<RadioButton>(Arrays.asList(rbB, rbD, rbA));
	}
 
開發者ID:MacSimmy,項目名稱:Maps,代碼行數:19,代碼來源:MapApp.java

示例4: MessageTypeDialog

import javafx.scene.control.RadioButton; //導入方法依賴的package包/類
public MessageTypeDialog() {
    super(null, "Choose message type", false, DialogStyle.NATIVE);
    setMasthead("Choose message type");

    group = new ToggleGroup();

    RadioButton textButton = new RadioButton("Text");
    textButton.setUserData(new JmsTextMessage());
    textButton.setToggleGroup(group);
    textButton.setSelected(true);
    RadioButton bytesButton = new RadioButton("Bytes");
    bytesButton.setUserData(new JmsBytesMessage());
    bytesButton.setToggleGroup(group);

    HBox hbox = new HBox(5);
    hbox.getChildren().add(textButton);
    hbox.getChildren().add(bytesButton);
    setContent(hbox);

    Action action = new JmsMessageAction();
    action.disabledProperty().bind(group.selectedToggleProperty().isNull());

    ButtonBar.setType(action, ButtonBar.ButtonType.OK_DONE);
    getActions().addAll(action, Dialog.Actions.CANCEL);
}
 
開發者ID:Mykolas-Molis,項目名稱:mq-visualizer,代碼行數:26,代碼來源:MessageTypeDialog.java

示例5: createXPathVersionPanel

import javafx.scene.control.RadioButton; //導入方法依賴的package包/類
private javafx.scene.Node createXPathVersionPanel() {

		HBox p = new HBox(5);
		p.setPadding(new Insets(5, 5, 5, 5));
		//		JPanel p = new JPanel();
		Label e = new Label("XPath Version:");
		e.setAlignment(Pos.CENTER_LEFT);
		p.add(e);
		for (Object[] values : XPathRule.VERSION_DESCRIPTOR.choices()) {
			//			JRadioButton b = new JRadioButton();
			RadioButton b = new RadioButton((String) values[0]);

			//			b.setText((String) values[0]);
			b.setUserData(b.getText());
			//			b.setActionCommand(b.getText());
			if (values[0].equals(XPathRule.VERSION_DESCRIPTOR.defaultValue())) {
				b.setSelected(true);
			}
			b.setToggleGroup(xpathVersionButtonGroup);
			//			xpathVersionButtonGroup.add(b);
			p.add(b);
		}

		//		SwingNode swingNode = new SwingNode();
		//		createSwingContent(swingNode, p);
		return p;
	}
 
開發者ID:callakrsos,項目名稱:Gargoyle,代碼行數:28,代碼來源:DesignerFx.java

示例6: getLine

import javafx.scene.control.RadioButton; //導入方法依賴的package包/類
private HBox getLine (RadioButton button, TextField text)
{
  HBox line = new HBox (10);
  line.getChildren ().addAll (button, text);
  button.setPrefWidth (LABEL_WIDTH);
  text.setPrefWidth (300);
  text.setFont (defaultFont);
  text.setEditable (false);
  text.setFocusTraversable (false);
  button.setUserData (text);

  return line;
}
 
開發者ID:xframium,項目名稱:xframium-java,代碼行數:14,代碼來源:TransfersTab.java

示例7: setupToggle

import javafx.scene.control.RadioButton; //導入方法依賴的package包/類
private LinkedList<RadioButton> setupToggle(ToggleGroup group) {

	  // Use Dijkstra as default
	  RadioButton rbD = new RadioButton("Dijkstra");
	  rbD.setUserData("Dijkstra");
	  rbD.setSelected(true);

	  RadioButton rbA = new RadioButton("A*");
	  rbA.setUserData("A*");

	  RadioButton rbB = new RadioButton("BFS");
	  rbB.setUserData("BFS");
	  
	  RadioButton rbGreedyTSP = new RadioButton("GreedyTSP");
	  rbGreedyTSP.setUserData("GreedyTSP");
	  
	  RadioButton rbGreedy2OptTSP = new RadioButton("Greedy2OptTSP");
	  rbGreedy2OptTSP.setUserData("Greedy2OptTSP");
	  

	  rbB.setToggleGroup(group);
	  rbD.setToggleGroup(group);
	  rbA.setToggleGroup(group);
	  rbGreedyTSP.setToggleGroup(group);
	  rbGreedy2OptTSP.setToggleGroup(group);
	  return new LinkedList<RadioButton>(Arrays.asList(rbB, rbD, rbA, 
			  										   rbGreedyTSP, 
			  										   rbGreedy2OptTSP) );
	}
 
開發者ID:ryanwc,項目名稱:GraphSearch,代碼行數:30,代碼來源:MapApp.java

示例8: Home

import javafx.scene.control.RadioButton; //導入方法依賴的package包/類
public Home() {
	group = new ToggleGroup();
	RadioButton rb1 = new RadioButton("Create a new transaction");
	RadioButton rb2 = new RadioButton("Review existing transactions");
	rb1.setToggleGroup(group);
	rb2.setToggleGroup(group);
	rb1.setSelected(true);

	VBox vboxRb = new VBox(10);
	vboxRb.getChildren().addAll(rb1, rb2);

	initGenerateForm();
	initReviewForm();

	rb1.setUserData(generate);
	rb2.setUserData(review);

	vbox = new VBox(25);
	vbox.setPadding(new Insets(50, 50, 50, 50));
	vbox.getChildren().addAll(vboxRb, generate);

	group.selectedToggleProperty().addListener(new ChangeListener<Toggle>() {
		@Override
		public void changed(ObservableValue<? extends Toggle> ov, Toggle toggle, Toggle new_toggle) {
			vbox.getChildren().remove(1);
			vbox.getChildren().add((NewForm) group.getSelectedToggle().getUserData());
		}
	});
}
 
開發者ID:egordon,項目名稱:btcoracle,代碼行數:30,代碼來源:Home.java

示例9: updateItem

import javafx.scene.control.RadioButton; //導入方法依賴的package包/類
@Override
protected void updateItem(T item, boolean empty)
{
    super.updateItem(item, empty);
    if (!empty)
    {

        TableRow currentRow = getTableRow();
        RequestEntry requestEntry = (RequestEntry) getTableView().getItems().get(getIndex());
        if(currentRow != null && requestEntry.isGray()) {
            currentRow.setStyle("-fx-background-color: darkgrey");
        }

        // gui setup
        HBox hb = new HBox(7);
        hb.setAlignment(Pos.CENTER);
        final ToggleGroup group = new ToggleGroup();

        // create a radio button for each 'element' of the enumeration
        for (Enum<RequestTypeGUI> enumElement : enumeration) {
            RadioButton radioButton = new RadioButton(enumElement.toString());
            radioButton.setUserData(enumElement);
            radioButton.setToggleGroup(group);
            hb.getChildren().add(radioButton);
            if (enumElement.equals(item)) {
                radioButton.setSelected(true);
            }
        }

        // issue events on change of the selected radio button
        group.selectedToggleProperty().addListener((observable, oldValue, newValue) -> {
            if(disableEvent == true) {
                return;
            }
            if(EditRequestsController.isEditable(requestEntry.getEventDutyDTO().getRehearsalFor())) {
                requestEntry.setEdited(true);
                RequestTypeGUI requestTypeGUI = (RequestTypeGUI) newValue.getUserData();
                requestEntry.setRequestType(requestTypeGUI);

                // todo change
                if(requestTypeGUI.equals(RequestTypeGUI.Absence)) {
                    EditRequestsController.setReahearsalsAbsence(requestEntry.getEventDutyDTO().getEventDutyId());
                }
            } else {
                disableEvent = true;
                group.selectToggle(oldValue);
                disableEvent = false;
                requestEntry.requestTypeProperty().set(RequestTypeGUI.Absence);
                requestEntry.setRequestType(RequestTypeGUI.Absence);
            }
        });
        setGraphic(hb);
    }
}
 
開發者ID:ITB15-S4-GroupD,項目名稱:Planchester,代碼行數:55,代碼來源:RequestRadioButtonCell.java

示例10: start

import javafx.scene.control.RadioButton; //導入方法依賴的package包/類
@Override
  public void start(Stage pPrimaryStage) 
  {
aText.setText(PART_1);
      pPrimaryStage.setTitle(aLabelProvider.getBoth());
      aButton.setOnAction(this);
      
      aSkin.selectedToggleProperty().addListener(this);

      RadioButton rb1 = new RadioButton("Plain");
      rb1.setToggleGroup(aSkin);
      rb1.setUserData("Plain");
      rb1.setSelected(true);

      RadioButton rb2 = new RadioButton("Floral");
      rb2.setUserData("Floral");
      rb2.setToggleGroup(aSkin);
       
      RadioButton rb3 = new RadioButton("Chintz");
      rb3.setUserData("Chintz");
      rb3.setToggleGroup(aSkin);
      
      VBox centerPanel = new VBox(MARGIN);
      centerPanel.setPadding(new Insets(MARGIN));
      centerPanel.setAlignment(Pos.CENTER);
      centerPanel.getChildren().addAll(aText, aButton);
      
      BorderPane root = new BorderPane();
      root.setCenter(centerPanel);
      
      HBox bottomPanel = new HBox(MARGIN);
      bottomPanel.setPadding(new Insets(MARGIN));
      bottomPanel.setAlignment(Pos.CENTER);
      bottomPanel.getChildren().addAll(rb1, rb2, rb3);
      root.setBottom(bottomPanel);
      
      aScene = new Scene(root, WIDTH, HEIGHT);
      pPrimaryStage.setResizable(false);
      pPrimaryStage.setScene(aScene);
      pPrimaryStage.show();
  }
 
開發者ID:prmr,項目名稱:COMP303Starter,代碼行數:42,代碼來源:Welcome.java

示例11: baseLayout

import javafx.scene.control.RadioButton; //導入方法依賴的package包/類
protected GridPane baseLayout()
{    
    final GridPane grid = new GridPane();
    grid.setHgap(30);
    grid.setVgap(30);
    grid.setAlignment(Pos.TOP_LEFT);
    grid.setPadding(new Insets(10));
    
   final DropShadow dropShadow = new DropShadow();
   dropShadow.setRadius(5.0);
   dropShadow.setOffsetX(0.0);
   dropShadow.setOffsetY(0.0);
   dropShadow.setColor(Color.color(0.0, 0.0, 0.0));  
    
    Text q = new Text("Q"+(index+1)+") "+questions[index]); 
    q.setWrappingWidth(remX*rem-50); //set Wrap Boundary relative to Screen DPI
    grid.setColumnSpan(q, 31);
    grid.setRowSpan(q,1);
    q.setId("question");
    grid.add(q, 1, 5);
  
    final ToggleGroup tg = new ToggleGroup(); //ToggleGroup for options for the question
    
    /*
        HBox hOpt will get options arranged Row-wise
        VBox vOpt will get the hOpt multiple times
        GridPane grid will get the VBox, hence, options are arranged in a grid/matrix            
    */
    
    HBox hOpt= new HBox(100);
    VBox vOpt= new VBox(100);        
    
    /*
        Each option has data so that it can be used to access the corresponding matrix data
    */
    RadioButton opt1 = new RadioButton(answers[index][0]);
    opt1.setUserData("0");
    opt1.setToggleGroup(tg); 
    
    RadioButton opt2 = new RadioButton(answers[index][1]);
    opt2.setUserData("1");
    opt2.setToggleGroup(tg);
    
    hOpt.getChildren().addAll(opt1, opt2);
    vOpt.getChildren().addAll(hOpt);
    hOpt = new HBox(100);
    
    RadioButton opt3 = new RadioButton(answers[index][2]);
    opt3.setUserData("2");
    opt3.setToggleGroup(tg);
    
    RadioButton opt4 = new RadioButton(answers[index][3]);
    opt4.setUserData("3");
    opt4.setToggleGroup(tg);
    
    hOpt.getChildren().addAll(opt3, opt4); 
    vOpt.getChildren().addAll(hOpt);
    grid.setColumnSpan(vOpt, 20);    
    grid.add(vOpt, 8, 6); 
    
    if(userAnswers[index] != -1) //if the user returns to previous question, the already selected options to be selected again
    {
        switch(userAnswers[index])
        {
            case 0: opt1.setSelected(true); break;
            case 1: opt2.setSelected(true); break;
            case 2: opt3.setSelected(true); break;
            case 3: opt4.setSelected(true); break;
        }
    }
    tg.selectedToggleProperty().addListener(new ChangeListener<Toggle>() { //when the user selects an option
                     @Override
                     public void changed(ObservableValue<? extends Toggle> ov, Toggle t, Toggle t1)
                     {                             
                         userAnswers[index] = Integer.valueOf(tg.getSelectedToggle().getUserData().toString());
                     }
                     });
    
    grid.getStylesheets().add(FossAsiaQuiz.class.getResource("FossAsiaQuizCSS.css").toExternalForm());   
    return grid;        
}
 
開發者ID:svr8,項目名稱:FossAsiaQuiz,代碼行數:82,代碼來源:FossAsiaQuiz.java

示例12: addTransformingModeOptions

import javafx.scene.control.RadioButton; //導入方法依賴的package包/類
private HBox addTransformingModeOptions() {
  	HBox hBox = new HBox();
  	
  	hBox.setPadding(new Insets(15, 12, 15, 12));
  	hBox.setSpacing(10);
  	hBox.setStyle("-fx-background-color: #66FFFF;");
  	
  	final ToggleGroup optionGroup = new ToggleGroup();
  	
  	Label lblMouseMode = new Label("Mouse Mode: ");
  	lblMouseMode.setPrefSize(100,  20);
  	
  	RadioButton rbTransform = new RadioButton("Pan & Zoom");
  	rbTransform.setPrefSize(100, 20);
  	rbTransform.setToggleGroup(optionGroup);
  	rbTransform.setUserData("T");
  	rbTransform.setSelected(true);
  	
  	RadioButton rbPick = new RadioButton("Picking");
  	rbPick.setPrefSize(100, 20);
  	rbPick.setUserData("P");
  	rbPick.setToggleGroup(optionGroup);
  	
  	
  	
  	optionGroup.selectedToggleProperty().addListener(new ChangeListener<Toggle>() {

	@Override
	public void changed(ObservableValue<? extends Toggle> observable,
			Toggle oldValue, Toggle newValue) {
		if (optionGroup.getSelectedToggle() != null){
			DefaultModalGraphMouse dmg = (DefaultModalGraphMouse) vv.getGraphMouse();
			
			if (optionGroup.getSelectedToggle().getUserData().equals("T")){
				dmg.setMode(Mode.TRANSFORMING);
			} else 	if (optionGroup.getSelectedToggle().getUserData().equals("P")){
				dmg.setMode(Mode.PICKING);
			}
		}
		
	}
});
  	
  	
  	
  	hBox.getChildren().addAll(lblMouseMode, rbTransform, rbPick);
  	
  	return hBox;

  }
 
開發者ID:gems-uff,項目名稱:dominoes,代碼行數:51,代碼來源:GraphPane.java


注:本文中的javafx.scene.control.RadioButton.setUserData方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。