使用 ONE JavaFX 8 DatePicker 选择一个时间段或日期

2023-11-22

在我当前正在工作的应用程序中,需要从同一个 JavaFX 8 DatePicker 中选择单个日期或时间段。

这样做的首选方法如下:

  1. 选择单个日期 - 与 DatePicker 的默认行为相同。

  2. 选择时间段 - 按住鼠标按钮并拖动到所需的结束/开始日期来选择开始/结束日期。释放鼠标按钮后,您就定义了您的周期。您不能选择显示的日期以外的日期,这一事实是可以接受的。

  3. 编辑应适用于单个日期(例如 2014 年 12 月 24 日)和期间(例如:2014 年 12 月 24 日 - 2014 年 12 月 27 日)

上面所选时间段(减去文本编辑器的内容)的可能呈现如下所示:

Rendering of selected period

其中橙色表示当前日期,蓝色表示选定的时间段。该图片来自我制作的原型,但其中使用 2 个日期选择器而不是一个来选择期间。

我查看了源代码

com.sun.javafx.scene.control.skin.DatePickerContent

其中有一个

protected List<DateCell> dayCells = new ArrayList<DateCell>();

为了找到一种方法来检测鼠标何时选择释放鼠标时的日期结束(或者可能检测拖动)。

但是我不太确定该怎么做。有什么建议么?

我附上了迄今为止制作的简单原型代码(使用 2 而不是所需的 1 日期选择器)。

Prototype so far

import java.time.LocalDate;

import javafx.beans.property.SimpleObjectProperty;

public interface PeriodController {

    /**
     * @return Today.
     */
    LocalDate currentDate();

    /**
     * @return Selected from date.
     */
    SimpleObjectProperty<LocalDate> fromDateProperty();

    /**
     * @return Selected to date.
     */
    SimpleObjectProperty<LocalDate> toDateProperty();
}


import java.time.LocalDate;
import java.time.format.DateTimeFormatter;

import javafx.util.StringConverter;

public class DateConverter extends StringConverter<LocalDate> {

    private DateTimeFormatter dateFormatter = DateTimeFormatter.ofPattern("dd.MM.yyyy"); // TODO i18n

    @Override
    public String toString(LocalDate date) {
        if (date != null) {
            return dateFormatter.format(date);
        } else {
            return "";
        }
    }

    @Override
    public LocalDate fromString(String string) {
        if (string != null && !string.isEmpty()) {
            return LocalDate.parse(string, dateFormatter);
        } else {
            return null;
        }
    }


}







import static java.lang.System.out;

import java.time.LocalDate;
import java.util.Locale;

import javafx.application.Application;
import javafx.beans.property.SimpleObjectProperty;
import javafx.beans.value.ChangeListener;
import javafx.geometry.HPos;
import javafx.scene.Scene;
import javafx.scene.control.Label;
import javafx.scene.layout.GridPane;
import javafx.scene.layout.VBox;
import javafx.stage.Stage;

public class PeriodMain extends Application {

    private Stage stage;

    public static void main(String[] args) {
        Locale.setDefault(new Locale("no", "NO"));
        launch(args);
    }

    @Override
    public void start(Stage stage) {
        this.stage = stage;
        stage.setTitle("Period prototype ");
        initUI();
        stage.getScene().getStylesheets().add(getClass().getResource("/period-picker.css").toExternalForm());
        stage.show();
    }

    private void initUI() {
        VBox vbox = new VBox(20);
        vbox.setStyle("-fx-padding: 10;");
        Scene scene = new Scene(vbox, 400, 200);


        stage.setScene(scene);
        final PeriodPickerPrototype periodPickerPrototype = new PeriodPickerPrototype(new PeriodController() {

            SimpleObjectProperty<LocalDate> fromDate = new SimpleObjectProperty<>();
            SimpleObjectProperty<LocalDate> toDate = new SimpleObjectProperty<>();

            {
                final ChangeListener<LocalDate> dateListener = (observable, oldValue, newValue) -> {
                    if (fromDate.getValue() != null && toDate.getValue() != null) {
                        out.println("Selected period " + fromDate.getValue() + " - " + toDate.getValue());
                    }
                };
                fromDate.addListener(dateListener);
                toDate.addListener(dateListener);

            }


            @Override public LocalDate currentDate() {
                return LocalDate.now();
            }

            @Override public SimpleObjectProperty<LocalDate> fromDateProperty() {
                return fromDate;
            }

            @Override public SimpleObjectProperty<LocalDate> toDateProperty() {
                return toDate;
            }


        });

        GridPane gridPane = new GridPane();
        gridPane.setHgap(10);
        gridPane.setVgap(10);
        Label checkInlabel = new Label("Check-In Date:");
        GridPane.setHalignment(checkInlabel, HPos.LEFT);
        gridPane.add(periodPickerPrototype, 0, 1);
        vbox.getChildren().add(gridPane);
    }
}







import java.time.LocalDate;

import javafx.beans.value.ChangeListener;
import javafx.event.ActionEvent;
import javafx.event.EventHandler;
import javafx.scene.control.DateCell;
import javafx.scene.control.DatePicker;
import javafx.scene.control.Label;
import javafx.scene.control.Tooltip;
import javafx.scene.layout.GridPane;
import javafx.util.Callback;
import javafx.util.StringConverter;


/**
 * Selecting a single date or a period - only a prototype.
 * As long as you have made an active choice on the {@code toDate}, the {@code fromDate} and {@code toDate} will have the same date.
 */
public class PeriodPickerPrototype extends GridPane {

    private static final String CSS_CALENDAR_BEFORE = "calendar-before";
    private static final String CSS_CALENDAR_BETWEEN = "calendar-between";
    private static final String CSS_CALENDAR_TODAY = "calendar-today";
    private static final boolean DISPLAY_WEEK_NUMBER = true;

    private Label fromLabel;
    private Label toLabel;

    private DatePicker fromDate;
    private DatePicker toDate;
    private StringConverter<LocalDate> converter;
    private PeriodController controller;
    private ChangeListener<LocalDate> fromDateListener;
    private ChangeListener<LocalDate> toDateListener;
    private Callback<DatePicker, DateCell> toDateCellFactory;
    private Callback<DatePicker, DateCell> fromDateCellFactory;
    private Tooltip todayTooltip;
    private boolean toDateIsActivlyChosenbyUser;

    public PeriodPickerPrototype(final PeriodController periodController)

    {
        this.controller = periodController;
        createComponents();
        makeLayout();
        createHandlers();
        bindAndRegisterHandlers();
        i18n();
        initComponent();
    }

    public void createComponents() {
        fromLabel = new Label();
        toLabel = new Label();
        fromDate = new DatePicker();
        toDate = new DatePicker();
        todayTooltip = new Tooltip();
    }

    public void createHandlers() {
        fromDate.setOnAction(event -> {
            if ((!toDateIsActivlyChosenbyUser) || fromDate.getValue().isAfter(toDate.getValue())) {
                setDateWithoutFiringEvent(fromDate.getValue(), toDate);
                toDateIsActivlyChosenbyUser = false;
            }

        });

        toDate.setOnAction(event -> toDateIsActivlyChosenbyUser = true);

        fromDateCellFactory = new Callback<DatePicker, DateCell>() {
            @Override public DateCell call(final DatePicker datePicker) {
                return new DateCell() {
                    @Override
                    public void updateItem(LocalDate item, boolean empty) {
                        super.updateItem(item, empty);
                        getStyleClass().removeAll(CSS_CALENDAR_TODAY, CSS_CALENDAR_BEFORE, CSS_CALENDAR_BETWEEN);

                        if ((item.isBefore(toDate.getValue()) || item.isEqual(toDate.getValue())) && item.isAfter(fromDate.getValue())) {
                            getStyleClass().add(CSS_CALENDAR_BETWEEN);
                        }

                        if (item.isEqual(controller.currentDate())) {
                            getStyleClass().add(CSS_CALENDAR_TODAY);
                            setTooltip(todayTooltip);
                        } else {
                            setTooltip(null);
                        }
                    }
                };
            }
        };

        toDateCellFactory =
                new Callback<DatePicker, DateCell>() {
                    @Override
                    public DateCell call(final DatePicker datePicker) {
                        return new DateCell() {
                            @Override
                            public void updateItem(LocalDate item, boolean empty) {
                                super.updateItem(item, empty);
                                setDisable(item.isBefore(fromDate.getValue()));
                                getStyleClass().removeAll(CSS_CALENDAR_TODAY, CSS_CALENDAR_BEFORE, CSS_CALENDAR_BETWEEN);


                                if (item.isBefore(fromDate.getValue())) {
                                    getStyleClass().add(CSS_CALENDAR_BEFORE);
                                } else if (item.isBefore(toDate.getValue()) || item.isEqual(toDate.getValue())) {
                                    getStyleClass().add(CSS_CALENDAR_BETWEEN);
                                }
                                if (item.isEqual(controller.currentDate())) {
                                    getStyleClass().add(CSS_CALENDAR_TODAY);
                                    setTooltip(todayTooltip);
                                } else {
                                    setTooltip(null);
                                }
                            }
                        };
                    }
                };
        converter = new DateConverter();
        fromDateListener = (observableValue, oldValue, newValue) -> {
            if (newValue == null) {
                // Restting old value and cancel..
                setDateWithoutFiringEvent(oldValue, fromDate);
                return;
            }
            controller.fromDateProperty().set(newValue);
        };
        toDateListener = (observableValue, oldValue, newValue) -> {
            if (newValue == null) {
                // Restting old value and cancel..
                setDateWithoutFiringEvent(oldValue, toDate);
                return;
            }
            controller.toDateProperty().set(newValue);
        };

    }

    /**
     * Changes the date on {@code datePicker} without fire {@code onAction} event.
     */
    private void setDateWithoutFiringEvent(LocalDate newDate, DatePicker datePicker) {
        final EventHandler<ActionEvent> onAction = datePicker.getOnAction();
        datePicker.setOnAction(null);
        datePicker.setValue(newDate);
        datePicker.setOnAction(onAction);
    }

    public void bindAndRegisterHandlers() {
        toDate.setDayCellFactory(toDateCellFactory);
        fromDate.setDayCellFactory(fromDateCellFactory);
        fromDate.valueProperty().addListener(fromDateListener);
        fromDate.setConverter(converter);
        toDate.valueProperty().addListener(toDateListener);
        toDate.setConverter(converter);

    }

    public void makeLayout() {
        setHgap(6);
        add(fromLabel, 0, 0);
        add(fromDate, 1, 0);
        add(toLabel, 2, 0);
        add(toDate, 3, 0);

        fromDate.setPrefWidth(120);
        toDate.setPrefWidth(120);
        fromLabel.setId("calendar-label");
        toLabel.setId("calendar-label");
    }

    public void i18n() {
        // i18n code replaced with
        fromDate.setPromptText("dd.mm.yyyy");
        toDate.setPromptText("dd.mm.yyyy");
        fromLabel.setText("From");
        toLabel.setText("To");
        todayTooltip.setText("Today");
    }

    public void initComponent() {
        fromDate.setTooltip(null);   // Ønsker ikke tooltip
        setDateWithoutFiringEvent(controller.currentDate(), fromDate);
        fromDate.setShowWeekNumbers(DISPLAY_WEEK_NUMBER);

        toDate.setTooltip(null);   // Ønsker ikke tooltip
        setDateWithoutFiringEvent(controller.currentDate(), toDate);
        toDate.setShowWeekNumbers(DISPLAY_WEEK_NUMBER);
    }


}

/** period-picker.css goes udner resources (using maven) **/ 

.date-picker {
    /*    -fx-font-size: 11pt;*/
}

.calendar-before {
}

.calendar-between {
    -fx-background-color: #bce9ff;
}

.calendar-between:hover {
    -fx-background-color: rgb(0, 150, 201);
}

.calendar-between:focused {
    -fx-background-color: rgb(0, 150, 201);
}

.calendar-today {
    -fx-background-color: rgb(255, 218, 111);
}

.calendar-today:hover {
    -fx-background-color: rgb(0, 150, 201);
}

.calendar-today:focused {
    -fx-background-color: rgb(0, 150, 201);
}

#calendar-label {
    -fx-font-style: italic;
    -fx-fill: rgb(75, 75, 75);
    -fx-font-size: 11;
}

我认为你已经走在正确的轨道上......DateCell并且拖动可以工作,因为如果检测到拖动事件或结束时弹出窗口不会关闭。这使您有机会跟踪用户选择的单元格。

这是一个快速技巧,但它可以帮助您选择范围。

首先,它将获取显示月份内所有单元格的内容和列表,添加拖动事件的侦听器,将拖动开始的第一个单元格标记为拖动开始的第一个单元格,然后选择第一个单元格中的所有单元格以及该单元格下的单元格。实际的鼠标位置,取消选择其余部分。

拖动事件完成后,所选范围将显示在控制台上。您可以重新开始,直到弹出窗口关闭。

private DateCell iniCell=null;
private DateCell endCell=null;

@Override
public void start(Stage primaryStage) {
    DatePicker datePicker=new DatePicker();
    datePicker.setValue(LocalDate.now());

    Scene scene = new Scene(new AnchorPane(datePicker), 300, 250);

    primaryStage.setScene(scene);
    primaryStage.show();

    datePicker.showingProperty().addListener((obs,b,b1)->{
        if(b1){
            DatePickerContent content = (DatePickerContent)((DatePickerSkin)datePicker.getSkin()).getPopupContent();

            List<DateCell> cells = content.lookupAll(".day-cell").stream()
                    .filter(ce->!ce.getStyleClass().contains("next-month"))
                    .map(n->(DateCell)n)
                    .collect(Collectors.toList());

            content.setOnMouseDragged(e->{
                Node n=e.getPickResult().getIntersectedNode();
                DateCell c=null;
                if(n instanceof DateCell){
                    c=(DateCell)n;
                } else if(n instanceof Text){
                    c=(DateCell)(n.getParent());
                }
                if(c!=null && c.getStyleClass().contains("day-cell") &&
                        !c.getStyleClass().contains("next-month")){
                    if(iniCell==null){
                        iniCell=c;
                    }
                    endCell=c;
                }
                if(iniCell!=null && endCell!=null){
                    int ini=(int)Math.min(Integer.parseInt(iniCell.getText()), 
                            Integer.parseInt(endCell.getText()));
                    int end=(int)Math.max(Integer.parseInt(iniCell.getText()), 
                            Integer.parseInt(endCell.getText()));
                    cells.stream()
                        .forEach(ce->ce.getStyleClass().remove("selected"));
                    cells.stream()
                        .filter(ce->Integer.parseInt(ce.getText())>=ini)
                        .filter(ce->Integer.parseInt(ce.getText())<=end)
                        .forEach(ce->ce.getStyleClass().add("selected"));
                }
            });
            content.setOnMouseReleased(e->{
                if(iniCell!=null && endCell!=null){
                    System.out.println("Selection from "+iniCell.getText()+" to "+endCell.getText());
                }
                endCell=null;
                iniCell=null;                    
            });
        }
    });
}

它是这样的:

Range selection on DatePicker

目前,这不会更新文本字段,因为这涉及使用自定义格式化程序。

EDIT

我添加了一个自定义字符串转换器,以在完成选择后在文本字段上显示范围,并且如果输入了有效范围,也可以选择一个范围。

这不是防弹的,但它可以作为概念证明。

private DateCell iniCell=null;
private DateCell endCell=null;

private LocalDate iniDate;
private LocalDate endDate;
final DateTimeFormatter formatter = DateTimeFormatter.ofPattern("d.MM.uuuu", Locale.ENGLISH);    

@Override
public void start(Stage primaryStage) {
    DatePicker datePicker=new DatePicker();
    datePicker.setValue(LocalDate.now());
    datePicker.setConverter(new StringConverter<LocalDate>() {

        @Override
        public String toString(LocalDate object) {
            if(iniDate!=null && endDate!=null){
                return iniDate.format(formatter)+" - "+endDate.format(formatter);
            }
            return object.format(formatter);
        }

        @Override
        public LocalDate fromString(String string) {
            if(string.contains("-")){
                try{
                    iniDate=LocalDate.parse(string.split("-")[0].trim(), formatter);
                    endDate=LocalDate.parse(string.split("-")[1].trim(), formatter);
                } catch(DateTimeParseException dte){
                    return LocalDate.parse(string, formatter);
                }
                return iniDate;
            }
            return LocalDate.parse(string, formatter);
        }
    });
    Scene scene = new Scene(new AnchorPane(datePicker), 300, 250);

    primaryStage.setScene(scene);
    primaryStage.show();

    datePicker.showingProperty().addListener((obs,b,b1)->{
        if(b1){
            DatePickerContent content = (DatePickerContent)((DatePickerSkin)datePicker.getSkin()).getPopupContent();

            List<DateCell> cells = content.lookupAll(".day-cell").stream()
                    .filter(ce->!ce.getStyleClass().contains("next-month"))
                    .map(n->(DateCell)n)
                    .collect(Collectors.toList());

            // select initial range
            if(iniDate!=null && endDate!=null){
                int ini=iniDate.getDayOfMonth();
                int end=endDate.getDayOfMonth();
                cells.stream()
                    .forEach(ce->ce.getStyleClass().remove("selected"));
                cells.stream()
                    .filter(ce->Integer.parseInt(ce.getText())>=ini)
                    .filter(ce->Integer.parseInt(ce.getText())<=end)
                    .forEach(ce->ce.getStyleClass().add("selected"));
            }
            iniCell=null; 
            endCell=null;
            content.setOnMouseDragged(e->{
                Node n=e.getPickResult().getIntersectedNode();
                DateCell c=null;
                if(n instanceof DateCell){
                    c=(DateCell)n;
                } else if(n instanceof Text){
                    c=(DateCell)(n.getParent());
                }
                if(c!=null && c.getStyleClass().contains("day-cell") &&
                        !c.getStyleClass().contains("next-month")){
                    if(iniCell==null){
                        iniCell=c;
                    }
                    endCell=c;
                }
                if(iniCell!=null && endCell!=null){
                    int ini=(int)Math.min(Integer.parseInt(iniCell.getText()), 
                            Integer.parseInt(endCell.getText()));
                    int end=(int)Math.max(Integer.parseInt(iniCell.getText()), 
                            Integer.parseInt(endCell.getText()));
                    cells.stream()
                        .forEach(ce->ce.getStyleClass().remove("selected"));
                    cells.stream()
                        .filter(ce->Integer.parseInt(ce.getText())>=ini)
                        .filter(ce->Integer.parseInt(ce.getText())<=end)
                        .forEach(ce->ce.getStyleClass().add("selected"));
                }
            });
            content.setOnMouseReleased(e->{
                if(iniCell!=null && endCell!=null){
                    iniDate=LocalDate.of(datePicker.getValue().getYear(), 
                                         datePicker.getValue().getMonth(),
                                         Integer.parseInt(iniCell.getText()));
                    endDate=LocalDate.of(datePicker.getValue().getYear(),
                                         datePicker.getValue().getMonth(),
                                         Integer.parseInt(endCell.getText()));
                    System.out.println("Selection from "+iniDate+" to "+endDate);

                    datePicker.setValue(iniDate);
                    int ini=iniDate.getDayOfMonth();
                    int end=endDate.getDayOfMonth();
                    cells.stream()
                        .forEach(ce->ce.getStyleClass().remove("selected"));
                    cells.stream()
                        .filter(ce->Integer.parseInt(ce.getText())>=ini)
                        .filter(ce->Integer.parseInt(ce.getText())<=end)
                        .forEach(ce->ce.getStyleClass().add("selected"));
                }
                endCell=null;
                iniCell=null;                   
            });
        }
    });
}

Range selection and edition

本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

使用 ONE JavaFX 8 DatePicker 选择一个时间段或日期 的相关文章

随机推荐

  • 当只需要一个字节时,为什么 Rust 使用两个字节来表示这个枚举?

    它似乎足够聪明 只为 A 使用一个字节 但不够聪明 为 B 使用一个字节 即使只有 8 8 64 种可能性 有什么方法可以让 Rust 解决这个问题 还是我必须手动实现更紧凑的布局 游乐场链接 allow dead code enum A
  • Python 3:gzip.open() 和模式

    https docs python org 3 library gzip html 我正在考虑使用gzip open 我有点困惑mode争论 模式参数可以是 r rb a ab w wb x 中的任何一个 或 xb 表示二进制模式 或 rt
  • 检测 32 位或 64 位 Windows

    我想检测当前的Windows操作系统是32位还是64位 如何用C 实现呢 我不需要处理器类型 我想要操作系统的位类型 这是因为您可以在 64 位处理器上安装 32 位操作系统 要调用的函数是IsWow64Process or IsWow64
  • 无会话的 Passport js 身份验证

    我是expressjs和passportjs的初学者 我使用护照和 GoogleStrategy 通过谷歌进行身份验证 使用下面的代码我有req user id 123456 in 用户 你好路由处理程序 但我想得到一些类似的没有会话支持的
  • 如何使用 iCloud 访问 Xcode 项目

    我最近购买了一台 MacBook Pro 我将用它来开发 iPhone 应用程序 我希望能够在 Macbook 和 iMac 之间传输 Xcode 项目 就像使用 iCloud 传输 Word 文档一样 有没有一种安全的方法可以做到这一点
  • 递归关系[关闭]

    很难说出这里问的是什么 这个问题模棱两可 含糊不清 不完整 过于宽泛或言辞激烈 无法以目前的形式合理回答 如需帮助澄清此问题以便重新打开 访问帮助中心 如何以最佳复杂度计算非常大的 n 例如 10 14 的 tribonacci 数 Tri
  • 帮助理解为什么我们的应用程序在Win7上弹出UAC对话框

    我们有一个 C 非托管应用程序 它似乎会导致 UAC 提示 似乎发生在Win7 而非 Vista 不幸的是 UAC dlg 是系统模式的 所以我无法附加调试器来检查代码所在的位置 并且在 msdev 下运行 我们使用的是 2008 以提升模
  • C中的任意长度字符串

    我需要对字符串进行一些操作 例如在某些位置添加字母 我不知道它的大小是多少 这取决于输入 如何定义字符串而不指定其大小 我希望它能够适应我放入其中的任何内容 为什么我不能只传递一个空的char 到一个方法 编译器不允许这样做 根据答案 我明
  • 如何避免Java编译中的“Method Too Large”错误?

    我有一个用 bigloo 方案功能语言编写的解析器 我需要将其编译成 java 类 整个解析器被编写为单个函数 不幸的是 这导致 JVM 编译器抛出 方法太大 警告 然后给出 localvar 中的远标签 错误 有什么可能的方法可以避免这个
  • 对于鼻子测试类使用 __init__(self) 而不是 setup(self) 有缺点吗?

    Running nosetests s for class TestTemp def init self print init self even 0 def setup self print setup self odd 1 def te
  • .NET 代码在正常进程退出时执行?

    In C有atexit函数 其中 atexit 函数注册给定的函数 以便在正常进程终止时通过 exit 3 或通过从程序的 main 返回来调用 Python 也有类似的功能 NET 是否提供了在正常进程终止时调用代码的方法 我知道有些事情
  • 如何在 swiftUI 中更改弹出窗口页面的大小和位置?

    我想设置Popover页面的位置和大小 我尝试了func popover的所有参数 我认为它可能与attachmentAnchor和arrowEdge有关 这是我的代码 import SwiftUI struct ContentView V
  • .NET:如何将 XML 文档插入 SQL Server

    我想将任意 XML 插入 SQL Server XML 包含在XmlDocument object 我想要插入的列是nvarchar ntext or xml列 如果它让您的生活更轻松 那么您可以选择它的类型 实际上 这是一个xml柱子 原
  • 如何从 python 中的正则表达式匹配返回字符串? [复制]

    这个问题在这里已经有答案了 我正在使用一个文本文件中的行python脚本 我想寻找一个img文本文档中的标签并将标签作为文本返回 当我运行正则表达式时re match line 它返回一个 sre SRE MATCH目的 我如何让它返回一个
  • 基于堆栈缓冲区的STL分配器?

    我想知道拥有一个符合 C 标准的库是否可行allocator它使用位于堆栈上的 固定大小 缓冲区 不知何故 似乎这个问题还没有以这种方式问过 尽管它may已经在其他地方隐含地回答了 所以基本上 它seems就我的搜索而言 应该可以创建一个使
  • 信号器与查询参数的持久连接。

    我有一个持久连接 我想使用查询参数从一些种子信息开始 这是连接中的覆盖 protected override Task OnConnected IRequest request string connectionId GET QUERY P
  • Web 浏览器 cookie 密钥的最大大小是多少?

    Web 浏览器 cookie 密钥的最大大小是多少 我知道 cookie 的最大大小是 4KB 但是密钥也有限制吗 您读到的 4K 限制是针对整个 cookie 包括名称 值 到期日期等 如果您想支持大多数浏览器 我建议将名称保持在 400
  • Android 的代理混淆了文档资源

    在我看来 关于 Android 上的代理主题有很多令人困惑的资源 首先 似乎所有的方法代理类已被宣布弃用 建议 使用标准 java vm 代理值来查找主机 端口和 排除列表 此调用会忽略排除列表 官方java vm 代理值可以通过以下方式访
  • 如何使用 sed 删除模式之前的换行符/换行符

    标题已经说明了 我想使用一些 linux oneliner 例如 sed 转变 Anytext into Anytext 这可以使用 sed 来完成吗 或者如果不使用 sed 则使用 awk oneliner 来完成 Sure sed N
  • 使用 ONE JavaFX 8 DatePicker 选择一个时间段或日期

    在我当前正在工作的应用程序中 需要从同一个 JavaFX 8 DatePicker 中选择单个日期或时间段 这样做的首选方法如下 选择单个日期 与 DatePicker 的默认行为相同 选择时间段 按住鼠标按钮并拖动到所需的结束 开始日期来