Skip to content

Commit 59e841e

Browse files
committed
优化加密解密工具界面布局
1 parent 6040ab0 commit 59e841e

3 files changed

Lines changed: 66 additions & 25 deletions

File tree

src/main/java/com/xwintop/xJavaFxTool/controller/littleTools/EncryptAndDecryptController.java

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -37,12 +37,6 @@
3737

3838
public class EncryptAndDecryptController extends EncryptAndDecryptView {
3939
private ToggleGroup toggleGroup = new ToggleGroup();
40-
/**
41-
* 字符集.
42-
*/
43-
private String[] charsets = new String[]{GuiUtils.CHARSET_UTF_8, GuiUtils.CHARSET_UTF_16BE,
44-
GuiUtils.CHARSET_UTF_16LE, GuiUtils.CHARSET_UTF_16, GuiUtils.CHARSET_GBK, GuiUtils.CHARSET_Big5,
45-
GuiUtils.CHARSET_ISO_8859_1};
4640

4741
/**
4842
* 加密算法. 空""用于填充一个空位.
@@ -58,16 +52,14 @@ public void initialize(URL location, ResourceBundle resources) {
5852
}
5953

6054
private void initView() {
61-
charsetsBox.getItems().addAll(charsets);
62-
charsetsBox.setValue(charsetsBox.getItems().get(0));
55+
charsetsBox.getItems().addAll(Charset.availableCharsets().keySet());
56+
charsetsBox.setValue("UTF-8");
6357
for (int i = 0; i < cryptos.length; i++) {
6458
if (!"".equals(cryptos[i])) {
6559
RadioButton radioButton = new RadioButton(cryptos[i]);
66-
radioButton.setLayoutX(440 + i % 3 * 100);
67-
radioButton.setLayoutY(60 + i / 3 * 26);
6860
radioButton.setToggleGroup(toggleGroup);
6961
radioButton.setUserData(cryptos[i]);
70-
mainAnchorPane.getChildren().add(radioButton);
62+
cryptosFlowPane.getChildren().add(radioButton);
7163
if (i == 0) {
7264
radioButton.setSelected(true);
7365
}

src/main/java/com/xwintop/xJavaFxTool/view/littleTools/EncryptAndDecryptView.java

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,11 @@
33
import javafx.fxml.FXML;
44
import javafx.fxml.Initializable;
55
import javafx.scene.control.Button;
6-
import javafx.scene.control.ChoiceBox;
6+
import javafx.scene.control.ComboBox;
77
import javafx.scene.control.TextArea;
88
import javafx.scene.control.TextField;
99
import javafx.scene.layout.AnchorPane;
10+
import javafx.scene.layout.FlowPane;
1011

1112
public abstract class EncryptAndDecryptView implements Initializable {
1213
@FXML
@@ -16,11 +17,13 @@ public abstract class EncryptAndDecryptView implements Initializable {
1617
@FXML
1718
protected TextArea decrptyTextArea;
1819
@FXML
19-
protected ChoiceBox<String> charsetsBox;
20+
protected ComboBox<String> charsetsBox;
2021
@FXML
2122
protected TextField keyTextField;
2223
@FXML
2324
protected Button encrptyButton;
2425
@FXML
2526
protected Button decrptyButton;
27+
@FXML
28+
protected FlowPane cryptosFlowPane;
2629
}
Lines changed: 58 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,69 @@
11
<?xml version="1.0" encoding="UTF-8"?>
22

3+
<?import javafx.geometry.Insets?>
34
<?import javafx.scene.control.Button?>
4-
<?import javafx.scene.control.ChoiceBox?>
5+
<?import javafx.scene.control.ComboBox?>
56
<?import javafx.scene.control.Label?>
7+
<?import javafx.scene.control.SplitPane?>
68
<?import javafx.scene.control.TextArea?>
79
<?import javafx.scene.control.TextField?>
810
<?import javafx.scene.layout.AnchorPane?>
11+
<?import javafx.scene.layout.BorderPane?>
12+
<?import javafx.scene.layout.FlowPane?>
13+
<?import javafx.scene.layout.HBox?>
14+
<?import javafx.scene.layout.VBox?>
915

10-
<AnchorPane fx:id="mainAnchorPane" prefHeight="379.0" prefWidth="654.0" xmlns="http://javafx.com/javafx/8.0.141" xmlns:fx="http://javafx.com/fxml/1" fx:controller="com.xwintop.xJavaFxTool.controller.littleTools.EncryptAndDecryptController">
16+
<AnchorPane fx:id="mainAnchorPane" prefHeight="449.0" prefWidth="660.0" xmlns="http://javafx.com/javafx/8.0.171" xmlns:fx="http://javafx.com/fxml/1" fx:controller="com.xwintop.xJavaFxTool.controller.littleTools.EncryptAndDecryptController">
1117
<children>
12-
<Label layoutX="14.0" layoutY="64.0" text="明文:" />
13-
<Label layoutX="14.0" layoutY="264.0" text="密文:" />
14-
<TextArea fx:id="encrptyTextArea" layoutX="50.0" layoutY="14.0" prefHeight="181.0" prefWidth="364.0" />
15-
<TextArea fx:id="decrptyTextArea" layoutX="50.0" layoutY="206.0" prefHeight="166.0" prefWidth="364.0" />
16-
<Label layoutX="435.0" layoutY="25.0" text="字符集:" />
17-
<ChoiceBox fx:id="charsetsBox" layoutX="490.0" layoutY="21.0" prefHeight="23.0" prefWidth="138.0" />
18-
<Button fx:id="encrptyButton" layoutX="431.0" layoutY="348.0" mnemonicParsing="false" onAction="#encrptyAction" prefHeight="23.0" prefWidth="92.0" text="加密" />
19-
<Button fx:id="decrptyButton" layoutX="532.0" layoutY="348.0" mnemonicParsing="false" onAction="#decrptyAction" prefHeight="23.0" prefWidth="92.0" text="解密" />
20-
<Label layoutX="435.0" layoutY="325.0" text="密钥:" />
21-
<TextField fx:id="keyTextField" layoutX="477.0" layoutY="321.0" />
18+
<BorderPane layoutX="14.0" layoutY="14.0" AnchorPane.bottomAnchor="10.0" AnchorPane.leftAnchor="10.0" AnchorPane.rightAnchor="10.0" AnchorPane.topAnchor="10.0">
19+
<center>
20+
<SplitPane dividerPositions="0.5" orientation="VERTICAL">
21+
<items>
22+
<HBox>
23+
<children>
24+
<Label text="明文:" />
25+
<TextArea fx:id="encrptyTextArea" HBox.hgrow="ALWAYS" />
26+
</children>
27+
<padding>
28+
<Insets bottom="5.0" left="5.0" right="5.0" top="5.0" />
29+
</padding>
30+
</HBox>
31+
<HBox>
32+
<children>
33+
<Label text="密文:" />
34+
<TextArea fx:id="decrptyTextArea" HBox.hgrow="ALWAYS" />
35+
</children>
36+
<padding>
37+
<Insets bottom="5.0" left="5.0" right="5.0" top="5.0" />
38+
</padding>
39+
</HBox>
40+
</items>
41+
</SplitPane>
42+
</center>
43+
<top>
44+
<VBox spacing="5.0" BorderPane.alignment="CENTER">
45+
<children>
46+
<HBox alignment="CENTER_LEFT" spacing="5.0">
47+
<children>
48+
<Label text="字符集:" />
49+
<ComboBox fx:id="charsetsBox" editable="true" />
50+
<Label text="密钥:" />
51+
<TextField fx:id="keyTextField" />
52+
<Button fx:id="encrptyButton" mnemonicParsing="false" onAction="#encrptyAction" prefHeight="23.0" prefWidth="92.0" text="加密" />
53+
<Button fx:id="decrptyButton" mnemonicParsing="false" onAction="#decrptyAction" prefHeight="23.0" prefWidth="92.0" text="解密" />
54+
</children>
55+
<padding>
56+
<Insets bottom="5.0" />
57+
</padding>
58+
</HBox>
59+
<FlowPane fx:id="cryptosFlowPane" hgap="5.0" vgap="5.0">
60+
<padding>
61+
<Insets bottom="5.0" />
62+
</padding>
63+
</FlowPane>
64+
</children>
65+
</VBox>
66+
</top>
67+
</BorderPane>
2268
</children>
2369
</AnchorPane>

0 commit comments

Comments
 (0)