oshi first

This commit is contained in:
RememBerBer 2021-11-12 13:57:37 +08:00
parent 1a7b88260f
commit 57641259ed
2 changed files with 72 additions and 4 deletions

View File

@ -8,7 +8,7 @@
<properties/>
<border type="none"/>
<children>
<grid id="39897" layout-manager="GridLayoutManager" row-count="2" column-count="1" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
<grid id="39897" layout-manager="GridLayoutManager" row-count="4" column-count="1" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
<margin top="10" left="10" bottom="10" right="10"/>
<constraints>
<grid row="0" column="0" row-span="1" col-span="1" vsize-policy="3" hsize-policy="3" anchor="0" fill="3" indent="0" use-parent-layout="false"/>
@ -52,6 +52,42 @@
</component>
</children>
</scrollpane>
<grid id="2fc20" layout-manager="GridLayoutManager" row-count="1" column-count="2" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
<margin top="0" left="0" bottom="0" right="0"/>
<constraints>
<grid row="2" column="0" row-span="1" col-span="1" vsize-policy="3" hsize-policy="3" anchor="0" fill="3" indent="0" use-parent-layout="false"/>
</constraints>
<properties/>
<border type="none"/>
<children>
<component id="9901c" class="javax.swing.JLabel">
<constraints>
<grid row="0" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
</constraints>
<properties>
<text value="Java properties"/>
</properties>
</component>
<hspacer id="c8205">
<constraints>
<grid row="0" column="1" row-span="1" col-span="1" vsize-policy="1" hsize-policy="6" anchor="0" fill="1" indent="0" use-parent-layout="false"/>
</constraints>
</hspacer>
</children>
</grid>
<scrollpane id="1f4b6">
<constraints>
<grid row="3" column="0" row-span="1" col-span="1" vsize-policy="7" hsize-policy="7" anchor="0" fill="3" indent="0" use-parent-layout="false"/>
</constraints>
<properties/>
<border type="none"/>
<children>
<component id="72f9e" class="javax.swing.JTable" binding="javaPropsTable">
<constraints/>
<properties/>
</component>
</children>
</scrollpane>
</children>
</grid>
</children>

View File

@ -11,6 +11,7 @@ import javax.swing.*;
import javax.swing.table.DefaultTableModel;
import java.awt.*;
import java.util.Map;
import java.util.Properties;
/**
* VariablesForm
@ -25,6 +26,7 @@ public class VariablesForm {
private static VariablesForm variablesForm;
private JPanel mainPanel;
private JTable sysEnvVarTable;
private JTable javaPropsTable;
public static VariablesForm getInstance() {
if (variablesForm == null) {
@ -42,13 +44,15 @@ public class VariablesForm {
private static void initUi() {
getInstance().getSysEnvVarTable().setShowGrid(true);
getInstance().getJavaPropsTable().setShowGrid(true);
}
private static void initInfo() {
initListTable();
initSysEnvVarTable();
initJavaPropsTable();
}
public static void initListTable() {
public static void initSysEnvVarTable() {
String[] headerNames = {"Key", "Value"};
DefaultTableModel model = new DefaultTableModel(null, headerNames);
@ -64,6 +68,22 @@ public class VariablesForm {
getInstance().getSysEnvVarTable().setModel(model);
}
public static void initJavaPropsTable() {
String[] headerNames = {"Key", "Value"};
DefaultTableModel model = new DefaultTableModel(null, headerNames);
Properties properties = System.getProperties();
Object[] data;
for (Map.Entry<Object, Object> objectObjectEntry : properties.entrySet()) {
data = new Object[2];
data[0] = objectObjectEntry.getKey();
data[1] = objectObjectEntry.getValue();
model.addRow(data);
}
getInstance().getJavaPropsTable().setModel(model);
}
{
// GUI initializer generated by IntelliJ IDEA GUI Designer
// >>> IMPORTANT!! <<<
@ -82,7 +102,7 @@ public class VariablesForm {
mainPanel = new JPanel();
mainPanel.setLayout(new GridLayoutManager(1, 1, new Insets(0, 0, 0, 0), -1, -1));
final JPanel panel1 = new JPanel();
panel1.setLayout(new GridLayoutManager(2, 1, new Insets(10, 10, 10, 10), -1, -1));
panel1.setLayout(new GridLayoutManager(4, 1, new Insets(10, 10, 10, 10), -1, -1));
mainPanel.add(panel1, new GridConstraints(0, 0, 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));
final JPanel panel2 = new JPanel();
panel2.setLayout(new GridLayoutManager(1, 2, new Insets(0, 0, 0, 0), -1, -1));
@ -96,6 +116,18 @@ public class VariablesForm {
panel1.add(scrollPane1, new GridConstraints(1, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_WANT_GROW, null, null, null, 0, false));
sysEnvVarTable = new JTable();
scrollPane1.setViewportView(sysEnvVarTable);
final JPanel panel3 = new JPanel();
panel3.setLayout(new GridLayoutManager(1, 2, new Insets(0, 0, 0, 0), -1, -1));
panel1.add(panel3, new GridConstraints(2, 0, 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));
final JLabel label2 = new JLabel();
label2.setText("Java properties");
panel3.add(label2, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false));
final Spacer spacer2 = new Spacer();
panel3.add(spacer2, new GridConstraints(0, 1, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_WANT_GROW, 1, null, null, null, 0, false));
final JScrollPane scrollPane2 = new JScrollPane();
panel1.add(scrollPane2, new GridConstraints(3, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_WANT_GROW, null, null, null, 0, false));
javaPropsTable = new JTable();
scrollPane2.setViewportView(javaPropsTable);
}
/**