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


Java Label.setOnMouseClicked方法代碼示例

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


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

示例1: initializeLabel

import javafx.scene.control.Label; //導入方法依賴的package包/類
private void initializeLabel() {
    LoggerFacade.getDefault().trace(this.getClass(), "Initialize Label"); // NOI18N
    
    lSign = new Label();
    lSign.setPadding(DEFAULT_PADDING);
    lSign.setMinWidth(26.0d);
    lSign.setStyle("-fx-background-color:POWDERBLUE"); // NOI18N
    lSign.setOnMouseClicked(event -> {
        if (event.getClickCount() == 2) {
            final Term term = new Term();
            term.setTitle("" + System.currentTimeMillis()); // NOI18N
            this.onActionAddTerm(term);
        }
    });
    
    super.getChildren().add(0, lSign);
}
 
開發者ID:Naoghuman,項目名稱:ABC-List,代碼行數:18,代碼來源:SignFlowPane.java

示例2: AboutPane

import javafx.scene.control.Label; //導入方法依賴的package包/類
public AboutPane()
{
    super();
    super.setPrefHeight(AppTabPane.CONTENT_HEIGHT);
    super.setPrefWidth(AppTabPane.CONTENT_WIDTH);
    super.getStyleClass().add("vbox");
    super.setPadding(new Insets(10,10,10,10));
    super.setSpacing(25);
    
    sourceLabel = new Label("You can view the source code at:\nhttps://github.com/BlueGoliath/Goliath-Overclocking-Utility-FX");
    sourceLabel.setOnMouseClicked(new SourceHandler());
    
    super.getChildren().add(new Label("Goliath Overclocking Utility FX V1 Alpha"));
    
    super.getChildren().add(new Label("An easy to use, Open Source overclocking utility for Nvidia graphics cards in Linux using Java 8 & JavaFX."));
    
    super.getChildren().add(sourceLabel);
}
 
開發者ID:BlueGoliath,項目名稱:Goliath-Overclocking-Utility-FX,代碼行數:19,代碼來源:AboutPane.java

示例3: createHeaderPane

import javafx.scene.control.Label; //導入方法依賴的package包/類
public Node createHeaderPane(WeekView calView) {
    final GridPane container = new GridPane();
    container.setAlignment(Pos.BOTTOM_LEFT);
    container.getStyleClass().add("headerpane");

    final Label lblWeekday = new Label(calView.getDate().get().format(DateTimeFormatter.ofPattern("EEE")));
    lblWeekday.getStyleClass().add("label-weekday");

    final Label lblDate = new Label(calView.getDate().get().toString());
    lblDate.getStyleClass().add("label-date");
    final ContextMenu dayChooserMenu = new ContextMenu();
    final CustomMenuItem item = new CustomMenuItem(new DayChooser(calView.getDate()));
    dayChooserMenu.getStyleClass().add("day-chooser");
    item.setHideOnClick(false);
    dayChooserMenu.getItems().add(item);
    lblDate.setOnMouseClicked(event ->
            dayChooserMenu.show(lblDate,
                    lblDate.localToScreen(0, 0).getX(),
                    lblDate.localToScreen(0, 0).getY())
    );

    final Button left = new Button("<");
    left.getStyleClass().add("header-button");
    left.setOnAction(event -> calView.getDate().set(calView.getDate().get().minusDays(1)));
    final Button right = new Button(">");
    right.getStyleClass().add("header-button");
    right.setOnAction(event -> calView.getDate().set(calView.getDate().get().plusDays(1)));

    final ColumnConstraints columnWeekday = new ColumnConstraints(70);
    final ColumnConstraints columnCenter = new ColumnConstraints(20,50,Double.POSITIVE_INFINITY, Priority.ALWAYS, HPos.LEFT,true);
    final ColumnConstraints columnSwitcher = new ColumnConstraints(60);
    container.getColumnConstraints().addAll(columnWeekday, columnCenter, columnSwitcher);
    container.add(lblWeekday,0,0);
    container.add(lblDate, 1,0);
    container.add(new HBox(left, right), 2,0);
    return container;
}
 
開發者ID:Jibbow,項目名稱:FastisFX,代碼行數:38,代碼來源:WeekViewRenderer.java

示例4: createEntryTimeLabel

import javafx.scene.control.Label; //導入方法依賴的package包/類
/**
 * Creates the label used to display the time of the entry. The default implementation of this
 * method creates a label and sets the text returned by {@link #getTimeText(Entry)}.
 *
 * @param entry the entry for which the time will be displayed
 * @return a label for displaying the time information on the entry
 */
protected Label createEntryTimeLabel(Entry<?> entry) {
    Label timeLabel = new Label(getTimeText(entry));
    timeLabel.getStyleClass().add(AGENDA_VIEW_TIME_LABEL);
    if (agendaView.isEnableHyperlinks()) {
        timeLabel.setOnMouseClicked(evt -> fireEvent(new RequestEvent(this, this, entry)));
        timeLabel.getStyleClass().add("date-hyperlink");
    }
    return timeLabel;
}
 
開發者ID:dlemmermann,項目名稱:CalendarFX,代碼行數:17,代碼來源:AgendaView.java

示例5: createEntryTitleLabel

import javafx.scene.control.Label; //導入方法依賴的package包/類
/**
 * Creates the label used to display the title of the entry. The default implementation of this
 * method creates a label and sets the text found in {@link Entry#getTitle()}.
 *
 * @param entry the entry for which the title will be displayed
 * @return a label for displaying the title of the entry
 */
protected Label createEntryTitleLabel(Entry<?> entry) {
    Label titleLabel = new Label(entry.getTitle());
    titleLabel.getStyleClass().add(AGENDA_VIEW_TITLE_LABEL);
    if (agendaView.isEnableHyperlinks()) {
        titleLabel.setOnMouseClicked(evt -> fireEvent(new RequestEvent(this, this, entry)));
        titleLabel.getStyleClass().add("date-hyperlink");
    }
    return titleLabel;
}
 
開發者ID:dlemmermann,項目名稱:CalendarFX,代碼行數:17,代碼來源:AgendaView.java

示例6: MonthDayEntriesPane

import javafx.scene.control.Label; //導入方法依賴的package包/類
MonthDayEntriesPane(LocalDate date, int week, int day) {
    getStyleClass().add("entries-pane");

    this.date = date;
    this.week = week;
    this.day = day;

    entries.addListener((Observable evt) -> update());

    setMinSize(0, 0);
    setPrefSize(0, 0);

    Rectangle clip = new Rectangle();
    clip.widthProperty().bind(widthProperty());
    clip.heightProperty().bind(heightProperty());
    setClip(clip);

    moreLabel = new Label();
    moreLabel.getStyleClass().add(MONTH_DAY_MORE_LABEL);
    moreLabel.setManaged(false);
    moreLabel.setVisible(false);

    if (getSkinnable().isEnableHyperlinks()) {
        moreLabel.getStyleClass().add("date-hyperlink");
        moreLabel.setOnMouseClicked(evt -> fireEvent(new RequestEvent(this, this, date)));
    }

    getChildren().add(moreLabel);
}
 
開發者ID:dlemmermann,項目名稱:CalendarFX,代碼行數:30,代碼來源:MonthViewSkin.java

示例7: GoogleEntryAttendeeItem

import javafx.scene.control.Label; //導入方法依賴的package包/類
public GoogleEntryAttendeeItem(EventAttendee attendee) {
    this.attendee = Objects.requireNonNull(attendee);

    optionalIcon = new Label();
    optionalIcon.setOnMouseClicked(evt -> setOptional(!isOptional()));
    optionalIcon.getStyleClass().add("button-icon");
    optionalIcon.setTooltip(new Tooltip());

    statusIcon = new Label();

    name = new Label();
    name.setMaxWidth(Double.MAX_VALUE);

    setOptional(Boolean.TRUE.equals(attendee.getOptional()));
    optionalProperty().addListener(obs -> updateIcon());
    updateIcon();

    removeButton = new Label();
    removeButton.setGraphic(new FontAwesome().create(FontAwesome.Glyph.TRASH_ALT));
    removeButton.getStyleClass().add("button-icon");
    removeButton.setOnMouseClicked(evt -> removeAttendee(attendee));

    HBox.setHgrow(optionalIcon, Priority.NEVER);
    HBox.setHgrow(name, Priority.ALWAYS);
    HBox.setHgrow(removeButton, Priority.NEVER);

    getStyleClass().add("attendee-item");
    getChildren().addAll(optionalIcon, statusIcon, name, removeButton);

    ContextMenu menu = new ContextMenu();
    MenuItem optionalItem = new MenuItem("Mark as optional");
    optionalItem.setOnAction(evt -> setOptional(true));
    MenuItem requiredItem = new MenuItem("Mark as required");
    requiredItem.setOnAction(evt -> setOptional(false));
    MenuItem removeItem = new MenuItem("Remove attendee");
    removeItem.setOnAction(evt -> removeAttendee(attendee));
    menu.getItems().addAll(optionalItem, requiredItem, new SeparatorMenuItem(), removeItem);

    addEventHandler(CONTEXT_MENU_REQUESTED, evt -> menu.show(this, evt.getScreenX(), evt.getScreenY()));
}
 
開發者ID:dlemmermann,項目名稱:CalendarFX,代碼行數:41,代碼來源:GoogleEntryAttendeesView.java

示例8: GoogleEntryDetailsView

import javafx.scene.control.Label; //導入方法依賴的package包/類
public GoogleEntryDetailsView(GoogleEntry entry) {
    super(requireNonNull(entry));

    this.entry = entry;

    Label notificationLabel = new Label("Notification:");

    Label addButton = new Label("Add a notification");
    addButton.getStyleClass().add("link");
    addButton.setOnMouseClicked(evt -> createReminder());
    addButton.disableProperty().bind(entry.getCalendar().readOnlyProperty());

    VBox center = new VBox();

    BorderPane notificationPane = new BorderPane();
    notificationPane.setCenter(center);
    notificationPane.setBottom(addButton);

    GridPane box = (GridPane) getChildren().get(0);
    box.add(notificationLabel, 0, 5);
    box.add(notificationPane, 1, 5);

    GridPane.setValignment(notificationLabel, VPos.TOP);
    getStyleClass().add("details-view");

    if (entry.isUseDefaultReminder()) {
        GoogleCalendar calendar = (GoogleCalendar) entry.getCalendar();
        reminders.addAll(calendar.getDefaultReminders());
    }

    reminders.addAll(entry.getReminders());
    reminders.addListener((Observable obs) -> buildItems(center));
    buildItems(center);
}
 
開發者ID:dlemmermann,項目名稱:CalendarFX,代碼行數:35,代碼來源:GoogleEntryDetailsView.java

示例9: GoogleEntryReminderItem

import javafx.scene.control.Label; //導入方法依賴的package包/類
private GoogleEntryReminderItem(GoogleEntryReminder reminder) {
    this.reminder = requireNonNull(reminder);

    methodCombo = new ComboBox<>();
    methodCombo.getItems().setAll(RemindMethod.values());
    methodCombo.disableProperty().bind(entry.getCalendar().readOnlyProperty());
    methodCombo.valueProperty().bindBidirectional(reminder.methodProperty());
    methodCombo.setConverter(new StringConverter<RemindMethod>() {
        @Override
        public String toString(RemindMethod object) {
            return object.getName();
        }

        @Override
        public RemindMethod fromString(String string) {
            for (RemindMethod method : RemindMethod.values()) {
                if (method.getName().equals(string)) {
                    return method;
                }
            }
            return null;
        }
    });

    Integer minutes = reminder.getMinutes();
    TimeUnit unit = TimeUnit.MINUTES;
    if (minutes != null) {
        if (minutes % 1440 == 0) {
            unit = TimeUnit.DAYS;
            minutes = minutes / 1400;
        } else if (minutes % 60 == 0) {
            unit = TimeUnit.HOURS;
            minutes = minutes / 60;
        }
    }

    valueTxt = new TextField();
    valueTxt.disableProperty().bind(entry.getCalendar().readOnlyProperty());
    valueTxt.setPrefColumnCount(5);
    valueTxt.setText(minutes == null ? "" : minutes.toString());
    valueTxt.textProperty().addListener(obs -> updateMinutes());

    unitCombo = new ComboBox<>();
    unitCombo.getItems().setAll(TimeUnit.MINUTES, TimeUnit.HOURS, TimeUnit.DAYS);
    unitCombo.disableProperty().bind(entry.getCalendar().readOnlyProperty());
    unitCombo.setValue(unit);
    unitCombo.valueProperty().addListener(obs -> updateMinutes());

    removeIcon = new Label();
    removeIcon.getStyleClass().add("button-icon");
    removeIcon.setGraphic(new FontAwesome().create(FontAwesome.Glyph.TRASH_ALT));
    removeIcon.setOnMouseClicked(evt -> removeReminder(reminder));
    removeIcon.disableProperty().bind(entry.getCalendar().readOnlyProperty());

    HBox.setHgrow(removeIcon, Priority.NEVER);
    setAlignment(Pos.CENTER_LEFT);
    getChildren().addAll(methodCombo, valueTxt, unitCombo, removeIcon);
    getStyleClass().add("notification-item");
}
 
開發者ID:dlemmermann,項目名稱:CalendarFX,代碼行數:60,代碼來源:GoogleEntryDetailsView.java

示例10: homeView

import javafx.scene.control.Label; //導入方法依賴的package包/類
public static Scene homeView(){

        BorderPane view = new BorderPane();

        Label title = new Label("Classroom Flipkart");
        title.setFont(new Font("Open Sans", 60));
        title.setTextFill(Color.web("#ededed"));

        HBox header = new HBox(25);
        header.setMinHeight(30);
        header.setAlignment(Pos.TOP_CENTER);

        Label login = new Label("Login");
        login.setPadding(new Insets(5));
        login.setFont(new Font("Open Sans", 20));
        login.setTextFill(Color.web("#ededed"));
        login.setCursor(Cursor.HAND);
        login.setStyle(" -fx-border-color: red; -fx-border-width: 0 0 3 0; -fx-border-insets: 0 0 1 0; ");

        Label register = new Label("Register");
        register.setPadding(new Insets(5));
        register.setFont(new Font("Open Sans", 20));
        register.setTextFill(Color.web("#ededed"));
        register.setCursor(Cursor.HAND);

        header.getChildren().addAll(login, register);

        userLogin loginObject = new userLogin();
        userSignUp signUpObject = new userSignUp();

        BorderPane credential = new BorderPane(loginObject.userLogin(), header, null, null, null);
        credential.setMaxWidth(350);
        credential.setStyle("-fx-background-color: rgba(0, 100, 100, 0.5); -fx-border-color: grey; -fx-border-width: 1 1 1 1;");

        login.setOnMouseClicked(e->{
            credential.setCenter(loginObject.userLogin());
            login.setStyle(" -fx-border-color: red; -fx-border-width: 0 0 3 0; -fx-border-insets: 0 0 1 0; ");
            register.setStyle("");
        });

        register.setOnMouseClicked(e->{
            credential.setCenter(signUpObject.userSignUp());
            login.setStyle("");
            register.setStyle(" -fx-border-color: red; -fx-border-width: 0 0 3 0; -fx-border-insets: 0 0 1 0; ");
        });

        VBox centerVB = new VBox(30);
        centerVB.setAlignment(Pos.CENTER);
        centerVB.getChildren().addAll(title, credential);

        view.setCenter(centerVB);

        Scene scene = new Scene(view,800,500);
        scene.getStylesheets().add(loginHome.class.getResource("../../resources/css/main.css").toExternalForm());

        image = loginHome.class.getResource("../../resources/images/splash.jpg").toExternalForm();
        view.setStyle("-fx-background-image: url('" + image + "'); " +
                "-fx-background-position: center center; " +
                "-fx-background-size: cover, auto; " +
                "-fx-background-repeat: stretch;");

        return  scene;
    }
 
開發者ID:madHEYsia,項目名稱:ClassroomFlipkart,代碼行數:64,代碼來源:loginHome.java

示例11: DayChooser

import javafx.scene.control.Label; //導入方法依賴的package包/類
/**
 * A control for choosing between dates. A month calendar is displayed and the user
 * can click on a date. Easy to use.
 *
 *    --------------------
 *    | <     Month    > |
 *    --------------------
 *    |    1  3  4  5  6 |
 *    | 7  8  9 10 11 12 |
 *    |        ...       |
 *    --------------------
 *
 * @param selectedDate A date property which gets adjusted when the user selects a new date.
 */
public DayChooser(ObjectProperty<LocalDate> selectedDate) {
    this.getStylesheets().add(DayChooser.class.getClassLoader().getResource("css/DayChooser.css").toString());
    this.selectedDateProperty = selectedDate;
    this.displayedMonth = new SimpleObjectProperty<>(selectedDateProperty.get().getMonth());
    this.displayedYear = selectedDateProperty.get().getYear();

    // Add a header to the DayChooser for switching between months
    final BorderPane header = new BorderPane();
    final Button btnMonthLeft = new Button("<");
    final Button btnMonthRight = new Button(">");
    header.setLeft(btnMonthLeft);
    header.setRight(btnMonthRight);
    final Label lblMonth = new Label(selectedDate.get().getMonth().name());
    lblMonth.getStyleClass().add("daychooser-label-month");
    // set to current month when label is clicked
    lblMonth.setOnMouseClicked(event -> {
        displayedYear = selectedDateProperty.get().getYear();
        displayedMonth.set(selectedDateProperty.get().getMonth());
    });
    header.setCenter(lblMonth);
    this.getChildren().add(header);

    // create a GridPane that holds every single day
    final GridPane monthPane = new GridPane();
    monthPane.getStyleClass().add("daychooser-monthgrid");
    VBox.setVgrow(monthPane, Priority.ALWAYS);
    populateMonthPane(monthPane, displayedMonth.get(), displayedYear);
    this.getChildren().add(monthPane);

    // highlight the current date when selectedDate is changed and display the correct month
    selectedDateProperty.addListener(observable -> {
        displayedMonth.set(selectedDateProperty.get().getMonth());
        displayedYear = selectedDateProperty.get().getYear();
        populateMonthPane(monthPane, displayedMonth.get(), displayedYear);
        lblMonth.setText(displayedMonth.get().name());
    });

    // update displayed month when switching
    displayedMonth.addListener(observable -> {
        lblMonth.setText(displayedMonth.get().name());
        populateMonthPane(monthPane, displayedMonth.get(), displayedYear);
    });

    // switch between month with left and right buttons
    btnMonthLeft.setOnAction(event -> {
        if(displayedMonth.get() == Month.JANUARY) {
            displayedYear--;
        }
        displayedMonth.set(displayedMonth.get().minus(1));
    });
    btnMonthRight.setOnAction(event -> {
        if(displayedMonth.get() == Month.DECEMBER) {
            displayedYear++;
        }
        displayedMonth.set(displayedMonth.get().plus(1));
    });
}
 
開發者ID:Jibbow,項目名稱:FastisFX,代碼行數:72,代碼來源:DayChooser.java


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