some codes optimization
This commit is contained in:
parent
f8c155f843
commit
fb08602d41
|
@ -34,7 +34,7 @@
|
||||||
<grid row="0" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="0" fill="1" indent="0" use-parent-layout="false"/>
|
<grid row="0" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="0" fill="1" indent="0" use-parent-layout="false"/>
|
||||||
</constraints>
|
</constraints>
|
||||||
<properties>
|
<properties>
|
||||||
<text value="立即安装"/>
|
<text value="Install Now"/>
|
||||||
</properties>
|
</properties>
|
||||||
</component>
|
</component>
|
||||||
<component id="5723f" class="javax.swing.JButton" binding="buttonCancel">
|
<component id="5723f" class="javax.swing.JButton" binding="buttonCancel">
|
||||||
|
@ -42,7 +42,7 @@
|
||||||
<grid row="0" column="2" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="0" fill="1" indent="0" use-parent-layout="false"/>
|
<grid row="0" column="2" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="0" fill="1" indent="0" use-parent-layout="false"/>
|
||||||
</constraints>
|
</constraints>
|
||||||
<properties>
|
<properties>
|
||||||
<text value="取消"/>
|
<text value="Cancel"/>
|
||||||
</properties>
|
</properties>
|
||||||
</component>
|
</component>
|
||||||
<component id="69219" class="javax.swing.JButton" binding="buttonDownloadFromWeb">
|
<component id="69219" class="javax.swing.JButton" binding="buttonDownloadFromWeb">
|
||||||
|
@ -50,7 +50,7 @@
|
||||||
<grid row="0" column="1" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="0" fill="1" indent="0" use-parent-layout="false"/>
|
<grid row="0" column="1" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="0" fill="1" indent="0" use-parent-layout="false"/>
|
||||||
</constraints>
|
</constraints>
|
||||||
<properties>
|
<properties>
|
||||||
<text value="打开下载页面"/>
|
<text value="Open Download Page"/>
|
||||||
</properties>
|
</properties>
|
||||||
</component>
|
</component>
|
||||||
</children>
|
</children>
|
||||||
|
|
|
@ -158,13 +158,13 @@ public class UpdateDialog extends JDialog {
|
||||||
panel2.setLayout(new GridLayoutManager(1, 3, new Insets(0, 0, 0, 0), -1, -1));
|
panel2.setLayout(new GridLayoutManager(1, 3, new Insets(0, 0, 0, 0), -1, -1));
|
||||||
panel1.add(panel2, new GridConstraints(0, 1, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, null, null, 0, false));
|
panel1.add(panel2, new GridConstraints(0, 1, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, null, null, 0, false));
|
||||||
buttonOK = new JButton();
|
buttonOK = new JButton();
|
||||||
buttonOK.setText("立即安装");
|
buttonOK.setText("Install Now");
|
||||||
panel2.add(buttonOK, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false));
|
panel2.add(buttonOK, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false));
|
||||||
buttonCancel = new JButton();
|
buttonCancel = new JButton();
|
||||||
buttonCancel.setText("取消");
|
buttonCancel.setText("Cancel");
|
||||||
panel2.add(buttonCancel, new GridConstraints(0, 2, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false));
|
panel2.add(buttonCancel, new GridConstraints(0, 2, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false));
|
||||||
buttonDownloadFromWeb = new JButton();
|
buttonDownloadFromWeb = new JButton();
|
||||||
buttonDownloadFromWeb.setText("打开下载页面");
|
buttonDownloadFromWeb.setText("Open Download Page");
|
||||||
panel2.add(buttonDownloadFromWeb, new GridConstraints(0, 1, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false));
|
panel2.add(buttonDownloadFromWeb, new GridConstraints(0, 1, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false));
|
||||||
final JPanel panel3 = new JPanel();
|
final JPanel panel3 = new JPanel();
|
||||||
panel3.setLayout(new GridLayoutManager(4, 1, new Insets(0, 0, 0, 0), -1, -1));
|
panel3.setLayout(new GridLayoutManager(4, 1, new Insets(0, 0, 0, 0), -1, -1));
|
||||||
|
|
|
@ -34,7 +34,7 @@
|
||||||
<grid row="0" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="0" fill="1" indent="0" use-parent-layout="false"/>
|
<grid row="0" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="0" fill="1" indent="0" use-parent-layout="false"/>
|
||||||
</constraints>
|
</constraints>
|
||||||
<properties>
|
<properties>
|
||||||
<text value="立即下载"/>
|
<text value="Download Now"/>
|
||||||
</properties>
|
</properties>
|
||||||
</component>
|
</component>
|
||||||
<component id="5723f" class="javax.swing.JButton" binding="buttonCancel">
|
<component id="5723f" class="javax.swing.JButton" binding="buttonCancel">
|
||||||
|
@ -42,7 +42,7 @@
|
||||||
<grid row="0" column="1" row-span="1" col-span="2" vsize-policy="0" hsize-policy="3" anchor="0" fill="1" indent="0" use-parent-layout="false"/>
|
<grid row="0" column="1" row-span="1" col-span="2" vsize-policy="0" hsize-policy="3" anchor="0" fill="1" indent="0" use-parent-layout="false"/>
|
||||||
</constraints>
|
</constraints>
|
||||||
<properties>
|
<properties>
|
||||||
<text value="取消"/>
|
<text value="Cancel"/>
|
||||||
</properties>
|
</properties>
|
||||||
</component>
|
</component>
|
||||||
</children>
|
</children>
|
||||||
|
|
|
@ -128,10 +128,10 @@ public class UpdateInfoDialog extends JDialog {
|
||||||
panel2.setLayout(new GridLayoutManager(1, 3, new Insets(0, 0, 0, 0), -1, -1));
|
panel2.setLayout(new GridLayoutManager(1, 3, new Insets(0, 0, 0, 0), -1, -1));
|
||||||
panel1.add(panel2, new GridConstraints(0, 1, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, null, null, 0, false));
|
panel1.add(panel2, new GridConstraints(0, 1, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, null, null, 0, false));
|
||||||
buttonOK = new JButton();
|
buttonOK = new JButton();
|
||||||
buttonOK.setText("立即下载");
|
buttonOK.setText("Download Now");
|
||||||
panel2.add(buttonOK, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false));
|
panel2.add(buttonOK, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false));
|
||||||
buttonCancel = new JButton();
|
buttonCancel = new JButton();
|
||||||
buttonCancel.setText("取消");
|
buttonCancel.setText("Cancel");
|
||||||
panel2.add(buttonCancel, new GridConstraints(0, 1, 1, 2, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false));
|
panel2.add(buttonCancel, new GridConstraints(0, 1, 1, 2, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false));
|
||||||
final Spacer spacer2 = new Spacer();
|
final Spacer spacer2 = new Spacer();
|
||||||
panel1.add(spacer2, new GridConstraints(0, 2, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_WANT_GROW, 1, null, null, null, 0, false));
|
panel1.add(spacer2, new GridConstraints(0, 2, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_WANT_GROW, 1, null, null, null, 0, false));
|
||||||
|
|
|
@ -178,6 +178,9 @@ public class CpuForm {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Codes are copied from Hutool and have some modifications.
|
||||||
|
*/
|
||||||
private static void initPcuInfo() {
|
private static void initPcuInfo() {
|
||||||
CentralProcessor processor = App.si.getHardware().getProcessor();
|
CentralProcessor processor = App.si.getHardware().getProcessor();
|
||||||
DecimalFormat format = new DecimalFormat("#.00");
|
DecimalFormat format = new DecimalFormat("#.00");
|
||||||
|
@ -278,6 +281,7 @@ public class CpuForm {
|
||||||
Sensors sensors = App.si.getHardware().getSensors();
|
Sensors sensors = App.si.getHardware().getSensors();
|
||||||
|
|
||||||
cpuForm.getTemperatureLabel().setText(String.format("%.1f°C", sensors.getCpuTemperature()));
|
cpuForm.getTemperatureLabel().setText(String.format("%.1f°C", sensors.getCpuTemperature()));
|
||||||
|
// Tips are copied from oshi.
|
||||||
cpuForm.getTemperatureLabel().setToolTipText("On Windows, if not running Open Hardware Monitor, \n" +
|
cpuForm.getTemperatureLabel().setToolTipText("On Windows, if not running Open Hardware Monitor, \n" +
|
||||||
"requires elevated permissions and hardware BIOS that supports publishing to WMI. \n" +
|
"requires elevated permissions and hardware BIOS that supports publishing to WMI. \n" +
|
||||||
"In this case, returns the temperature of the \"Thermal Zone\" \n" +
|
"In this case, returns the temperature of the \"Thermal Zone\" \n" +
|
||||||
|
|
|
@ -81,6 +81,9 @@ public class NetworkForm {
|
||||||
serviceStartPerSecond.scheduleAtFixedRate(NetworkForm::initNetworkSpeed, 0, 1, TimeUnit.SECONDS);
|
serviceStartPerSecond.scheduleAtFixedRate(NetworkForm::initNetworkSpeed, 0, 1, TimeUnit.SECONDS);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Codes are copied from oshi and have some modifications.
|
||||||
|
*/
|
||||||
private static void initInterfaces() {
|
private static void initInterfaces() {
|
||||||
JTable interfacesTable = getInstance().getInterfacesTable();
|
JTable interfacesTable = getInstance().getInterfacesTable();
|
||||||
|
|
||||||
|
@ -101,6 +104,8 @@ public class NetworkForm {
|
||||||
JTextPane parametersTextPane = networkForm.getParametersTextPane();
|
JTextPane parametersTextPane = networkForm.getParametersTextPane();
|
||||||
parametersTextPane.setContentType("text/plain; charset=utf-8");
|
parametersTextPane.setContentType("text/plain; charset=utf-8");
|
||||||
|
|
||||||
|
String contentType = "text/html; charset=utf-8";
|
||||||
|
parametersTextPane.setContentType(contentType);
|
||||||
parametersTextPane.setText(buildParamsText(App.si.getOperatingSystem()));
|
parametersTextPane.setText(buildParamsText(App.si.getOperatingSystem()));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -161,19 +166,25 @@ public class NetworkForm {
|
||||||
}
|
}
|
||||||
|
|
||||||
private static String buildParamsText(OperatingSystem os) {
|
private static String buildParamsText(OperatingSystem os) {
|
||||||
NetworkParams params = os.getNetworkParams();
|
NetworkParams networkParams = os.getNetworkParams();
|
||||||
StringBuilder sb = new StringBuilder("Host Name: ").append(params.getHostName());
|
StringBuilder builder = new StringBuilder();
|
||||||
if (!params.getDomainName().isEmpty()) {
|
builder.append("<br/>");
|
||||||
sb.append("\nDomain Name: ").append(params.getDomainName());
|
builder.append("<b>Domain Name: </b>").append(networkParams.getDomainName());
|
||||||
}
|
builder.append("<br/><b>Host Name: </b>").append(networkParams.getHostName());
|
||||||
sb.append("\nIPv4 Default Gateway: ").append(params.getIpv4DefaultGateway());
|
builder.append("<br/><b>Ipv4 Default Gateway: </b>").append(networkParams.getIpv4DefaultGateway());
|
||||||
if (!params.getIpv6DefaultGateway().isEmpty()) {
|
builder.append("<br/><b>Ipv6 Default Gateway: </b>").append(networkParams.getIpv6DefaultGateway());
|
||||||
sb.append("\nIPv6 Default Gateway: ").append(params.getIpv6DefaultGateway());
|
builder.append("<br/><b>Dns Servers: </b>").append(Arrays.toString(networkParams.getDnsServers()));
|
||||||
}
|
builder.append("<br/>");
|
||||||
sb.append("\nDNS Servers: ").append(getIPAddressesString(params.getDnsServers()));
|
builder.append("<br/>");
|
||||||
return sb.toString();
|
return builder.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Codes are copied from oshi and have some modifications.
|
||||||
|
*
|
||||||
|
* @param ipAddressArr
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
private static String getIPAddressesString(String[] ipAddressArr) {
|
private static String getIPAddressesString(String[] ipAddressArr) {
|
||||||
StringBuilder sb = new StringBuilder();
|
StringBuilder sb = new StringBuilder();
|
||||||
boolean first = true;
|
boolean first = true;
|
||||||
|
@ -190,6 +201,12 @@ public class NetworkForm {
|
||||||
return sb.toString();
|
return sb.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Codes are copied from oshi and have some modifications.
|
||||||
|
*
|
||||||
|
* @param list
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
private static Object[][] parseInterfaces(List<NetworkIF> list) {
|
private static Object[][] parseInterfaces(List<NetworkIF> list) {
|
||||||
Map<NetworkIF, Integer> intfSortValueMap = new HashMap<>(INIT_HASH_SIZE);
|
Map<NetworkIF, Integer> intfSortValueMap = new HashMap<>(INIT_HASH_SIZE);
|
||||||
for (NetworkIF intf : list) {
|
for (NetworkIF intf : list) {
|
||||||
|
@ -217,6 +234,11 @@ public class NetworkForm {
|
||||||
return intfArr;
|
return intfArr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Codes are copied from oshi and have some modifications.
|
||||||
|
*
|
||||||
|
* @param tableColumnModel
|
||||||
|
*/
|
||||||
private static void resizeColumns(TableColumnModel tableColumnModel) {
|
private static void resizeColumns(TableColumnModel tableColumnModel) {
|
||||||
TableColumn column;
|
TableColumn column;
|
||||||
int tW = tableColumnModel.getTotalColumnWidth();
|
int tW = tableColumnModel.getTotalColumnWidth();
|
||||||
|
|
|
@ -58,6 +58,9 @@ public class ProcessesForm {
|
||||||
private static void initUi() {
|
private static void initUi() {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Codes are copied from oshi and have some modifications.
|
||||||
|
*/
|
||||||
private static void initInfo() {
|
private static void initInfo() {
|
||||||
OperatingSystem os = App.si.getOperatingSystem();
|
OperatingSystem os = App.si.getOperatingSystem();
|
||||||
TableModel model = new DefaultTableModel(parseProcesses(os.getProcesses(null, null, 0), App.si), COLUMNS);
|
TableModel model = new DefaultTableModel(parseProcesses(os.getProcesses(null, null, 0), App.si), COLUMNS);
|
||||||
|
@ -94,6 +97,13 @@ public class ProcessesForm {
|
||||||
timer.start();
|
timer.start();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Codes are copied from oshi and have some modifications.
|
||||||
|
*
|
||||||
|
* @param list
|
||||||
|
* @param si
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
private static Object[][] parseProcesses(List<OSProcess> list, SystemInfo si) {
|
private static Object[][] parseProcesses(List<OSProcess> list, SystemInfo si) {
|
||||||
long totalMem = si.getHardware().getMemory().getTotal();
|
long totalMem = si.getHardware().getMemory().getTotal();
|
||||||
int cpuCount = si.getHardware().getProcessor().getLogicalProcessorCount();
|
int cpuCount = si.getHardware().getProcessor().getLogicalProcessorCount();
|
||||||
|
@ -140,6 +150,11 @@ public class ProcessesForm {
|
||||||
return procArr;
|
return procArr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Codes are copied from oshi and have some modifications.
|
||||||
|
*
|
||||||
|
* @param tableColumnModel
|
||||||
|
*/
|
||||||
private static void resizeColumns(TableColumnModel tableColumnModel) {
|
private static void resizeColumns(TableColumnModel tableColumnModel) {
|
||||||
TableColumn column;
|
TableColumn column;
|
||||||
int tW = tableColumnModel.getTotalColumnWidth();
|
int tW = tableColumnModel.getTotalColumnWidth();
|
||||||
|
|
|
@ -49,6 +49,12 @@ public class UsbForm {
|
||||||
infoPane.setText(getUsbString(App.si.getHardware()));
|
infoPane.setText(getUsbString(App.si.getHardware()));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Codes are copied from oshi and have some modifications.
|
||||||
|
*
|
||||||
|
* @param hal
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
private static String getUsbString(HardwareAbstractionLayer hal) {
|
private static String getUsbString(HardwareAbstractionLayer hal) {
|
||||||
StringBuilder sb = new StringBuilder();
|
StringBuilder sb = new StringBuilder();
|
||||||
boolean first = true;
|
boolean first = true;
|
||||||
|
|
|
@ -11,8 +11,8 @@ import javax.swing.*;
|
||||||
public class ScrollUtil {
|
public class ScrollUtil {
|
||||||
|
|
||||||
public static void smoothPane(JScrollPane scrollPane) {
|
public static void smoothPane(JScrollPane scrollPane) {
|
||||||
scrollPane.getVerticalScrollBar().setUnitIncrement(16);
|
scrollPane.getVerticalScrollBar().setUnitIncrement(14);
|
||||||
scrollPane.getHorizontalScrollBar().setUnitIncrement(16);
|
scrollPane.getHorizontalScrollBar().setUnitIncrement(14);
|
||||||
scrollPane.getVerticalScrollBar().setDoubleBuffered(true);
|
scrollPane.getVerticalScrollBar().setDoubleBuffered(true);
|
||||||
scrollPane.getHorizontalScrollBar().setDoubleBuffered(true);
|
scrollPane.getHorizontalScrollBar().setDoubleBuffered(true);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue