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"/>
|
||||
</constraints>
|
||||
<properties>
|
||||
<text value="立即安装"/>
|
||||
<text value="Install Now"/>
|
||||
</properties>
|
||||
</component>
|
||||
<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"/>
|
||||
</constraints>
|
||||
<properties>
|
||||
<text value="取消"/>
|
||||
<text value="Cancel"/>
|
||||
</properties>
|
||||
</component>
|
||||
<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"/>
|
||||
</constraints>
|
||||
<properties>
|
||||
<text value="打开下载页面"/>
|
||||
<text value="Open Download Page"/>
|
||||
</properties>
|
||||
</component>
|
||||
</children>
|
||||
|
|
|
@ -158,13 +158,13 @@ public class UpdateDialog extends JDialog {
|
|||
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));
|
||||
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));
|
||||
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));
|
||||
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));
|
||||
final JPanel panel3 = new JPanel();
|
||||
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"/>
|
||||
</constraints>
|
||||
<properties>
|
||||
<text value="立即下载"/>
|
||||
<text value="Download Now"/>
|
||||
</properties>
|
||||
</component>
|
||||
<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"/>
|
||||
</constraints>
|
||||
<properties>
|
||||
<text value="取消"/>
|
||||
<text value="Cancel"/>
|
||||
</properties>
|
||||
</component>
|
||||
</children>
|
||||
|
|
|
@ -128,10 +128,10 @@ public class UpdateInfoDialog extends JDialog {
|
|||
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));
|
||||
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));
|
||||
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));
|
||||
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));
|
||||
|
|
|
@ -178,6 +178,9 @@ public class CpuForm {
|
|||
|
||||
}
|
||||
|
||||
/**
|
||||
* Codes are copied from Hutool and have some modifications.
|
||||
*/
|
||||
private static void initPcuInfo() {
|
||||
CentralProcessor processor = App.si.getHardware().getProcessor();
|
||||
DecimalFormat format = new DecimalFormat("#.00");
|
||||
|
@ -278,6 +281,7 @@ public class CpuForm {
|
|||
Sensors sensors = App.si.getHardware().getSensors();
|
||||
|
||||
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" +
|
||||
"requires elevated permissions and hardware BIOS that supports publishing to WMI. \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);
|
||||
}
|
||||
|
||||
/**
|
||||
* Codes are copied from oshi and have some modifications.
|
||||
*/
|
||||
private static void initInterfaces() {
|
||||
JTable interfacesTable = getInstance().getInterfacesTable();
|
||||
|
||||
|
@ -101,6 +104,8 @@ public class NetworkForm {
|
|||
JTextPane parametersTextPane = networkForm.getParametersTextPane();
|
||||
parametersTextPane.setContentType("text/plain; charset=utf-8");
|
||||
|
||||
String contentType = "text/html; charset=utf-8";
|
||||
parametersTextPane.setContentType(contentType);
|
||||
parametersTextPane.setText(buildParamsText(App.si.getOperatingSystem()));
|
||||
}
|
||||
|
||||
|
@ -161,19 +166,25 @@ public class NetworkForm {
|
|||
}
|
||||
|
||||
private static String buildParamsText(OperatingSystem os) {
|
||||
NetworkParams params = os.getNetworkParams();
|
||||
StringBuilder sb = new StringBuilder("Host Name: ").append(params.getHostName());
|
||||
if (!params.getDomainName().isEmpty()) {
|
||||
sb.append("\nDomain Name: ").append(params.getDomainName());
|
||||
}
|
||||
sb.append("\nIPv4 Default Gateway: ").append(params.getIpv4DefaultGateway());
|
||||
if (!params.getIpv6DefaultGateway().isEmpty()) {
|
||||
sb.append("\nIPv6 Default Gateway: ").append(params.getIpv6DefaultGateway());
|
||||
}
|
||||
sb.append("\nDNS Servers: ").append(getIPAddressesString(params.getDnsServers()));
|
||||
return sb.toString();
|
||||
NetworkParams networkParams = os.getNetworkParams();
|
||||
StringBuilder builder = new StringBuilder();
|
||||
builder.append("<br/>");
|
||||
builder.append("<b>Domain Name: </b>").append(networkParams.getDomainName());
|
||||
builder.append("<br/><b>Host Name: </b>").append(networkParams.getHostName());
|
||||
builder.append("<br/><b>Ipv4 Default Gateway: </b>").append(networkParams.getIpv4DefaultGateway());
|
||||
builder.append("<br/><b>Ipv6 Default Gateway: </b>").append(networkParams.getIpv6DefaultGateway());
|
||||
builder.append("<br/><b>Dns Servers: </b>").append(Arrays.toString(networkParams.getDnsServers()));
|
||||
builder.append("<br/>");
|
||||
builder.append("<br/>");
|
||||
return builder.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* Codes are copied from oshi and have some modifications.
|
||||
*
|
||||
* @param ipAddressArr
|
||||
* @return
|
||||
*/
|
||||
private static String getIPAddressesString(String[] ipAddressArr) {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
boolean first = true;
|
||||
|
@ -190,6 +201,12 @@ public class NetworkForm {
|
|||
return sb.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* Codes are copied from oshi and have some modifications.
|
||||
*
|
||||
* @param list
|
||||
* @return
|
||||
*/
|
||||
private static Object[][] parseInterfaces(List<NetworkIF> list) {
|
||||
Map<NetworkIF, Integer> intfSortValueMap = new HashMap<>(INIT_HASH_SIZE);
|
||||
for (NetworkIF intf : list) {
|
||||
|
@ -217,6 +234,11 @@ public class NetworkForm {
|
|||
return intfArr;
|
||||
}
|
||||
|
||||
/**
|
||||
* Codes are copied from oshi and have some modifications.
|
||||
*
|
||||
* @param tableColumnModel
|
||||
*/
|
||||
private static void resizeColumns(TableColumnModel tableColumnModel) {
|
||||
TableColumn column;
|
||||
int tW = tableColumnModel.getTotalColumnWidth();
|
||||
|
|
|
@ -58,6 +58,9 @@ public class ProcessesForm {
|
|||
private static void initUi() {
|
||||
}
|
||||
|
||||
/**
|
||||
* Codes are copied from oshi and have some modifications.
|
||||
*/
|
||||
private static void initInfo() {
|
||||
OperatingSystem os = App.si.getOperatingSystem();
|
||||
TableModel model = new DefaultTableModel(parseProcesses(os.getProcesses(null, null, 0), App.si), COLUMNS);
|
||||
|
@ -94,6 +97,13 @@ public class ProcessesForm {
|
|||
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) {
|
||||
long totalMem = si.getHardware().getMemory().getTotal();
|
||||
int cpuCount = si.getHardware().getProcessor().getLogicalProcessorCount();
|
||||
|
@ -140,6 +150,11 @@ public class ProcessesForm {
|
|||
return procArr;
|
||||
}
|
||||
|
||||
/**
|
||||
* Codes are copied from oshi and have some modifications.
|
||||
*
|
||||
* @param tableColumnModel
|
||||
*/
|
||||
private static void resizeColumns(TableColumnModel tableColumnModel) {
|
||||
TableColumn column;
|
||||
int tW = tableColumnModel.getTotalColumnWidth();
|
||||
|
|
|
@ -49,6 +49,12 @@ public class UsbForm {
|
|||
infoPane.setText(getUsbString(App.si.getHardware()));
|
||||
}
|
||||
|
||||
/**
|
||||
* Codes are copied from oshi and have some modifications.
|
||||
*
|
||||
* @param hal
|
||||
* @return
|
||||
*/
|
||||
private static String getUsbString(HardwareAbstractionLayer hal) {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
boolean first = true;
|
||||
|
|
|
@ -11,8 +11,8 @@ import javax.swing.*;
|
|||
public class ScrollUtil {
|
||||
|
||||
public static void smoothPane(JScrollPane scrollPane) {
|
||||
scrollPane.getVerticalScrollBar().setUnitIncrement(16);
|
||||
scrollPane.getHorizontalScrollBar().setUnitIncrement(16);
|
||||
scrollPane.getVerticalScrollBar().setUnitIncrement(14);
|
||||
scrollPane.getHorizontalScrollBar().setUnitIncrement(14);
|
||||
scrollPane.getVerticalScrollBar().setDoubleBuffered(true);
|
||||
scrollPane.getHorizontalScrollBar().setDoubleBuffered(true);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue