我想在JdatePicker中增加formattedTextField和Button之间的默认间隔。 我尝试在按钮组件上使用setMargin(新的Insets(0,100,0,0)但是会更改按钮内组件的边距 Here is an image of what is happening right now
下方字段的文本字段和日历按钮之间有一个小间隙。我想在顶线引入相同的差距
我尝试了DatePickerButton.setMargin(new Insets(0,100,0,0)
,但这不起作用
JDatePicker myDatePicker = JDateComponentFactory.createJDatePicker();
myDateButton.setShowYearButtons(true);
myDateButton.setTextEditable(true);
myDateButtonComponent = (JComponent) myDateButton;
myDatePickerTextField = ((JDatePickerImpl)myDateButtonComponent).getJFormattedTextField();
myDatePickerTextField.setName("date-Picker");
myDatePickerTextField.setText(EMPTY_STRING);
myDatePickerTextField.setPreferredSize(new Dimension(95,20));
myDatePickerTextField.setEnabled(true);
((JDatePickerImpl) myDateButtonComponent).getComponent(1).setPreferredSize(new Dimension(22, 22));
myDatePickerTextField.setFocusLostBehavior(JFormattedTextField.PERSIST);
myDateButton = ((JButton) ((JDatePickerImpl) myDateButton).getComponent(1));
myDateButton.setText(EMPTY_STRING);
myDateButton.setOpaque(false);
myDateButton.setIcon(Icons.calIcon);
myDateButton.setName("last-published-date-button");
myDateButton.setEnabled(true);