detail form first step

This commit is contained in:
RememBerBer 2021-11-23 13:38:07 +08:00
parent 7caa84f1b5
commit decdd7e81a
4 changed files with 43 additions and 7 deletions

View File

@ -8,7 +8,7 @@
<properties/>
<border type="none"/>
<children>
<scrollpane id="9f306">
<scrollpane id="9f306" binding="scrollPane">
<constraints>
<grid row="0" 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>

View File

@ -6,8 +6,11 @@ import com.intellij.uiDesigner.core.GridConstraints;
import com.intellij.uiDesigner.core.GridLayoutManager;
import com.intellij.uiDesigner.core.Spacer;
import com.luoboduner.moo.info.App;
import com.luoboduner.moo.info.ui.Style;
import com.luoboduner.moo.info.util.ScrollUtil;
import lombok.Getter;
import oshi.hardware.ComputerSystem;
import oshi.hardware.HardwareAbstractionLayer;
import oshi.software.os.OperatingSystem;
import javax.swing.*;
@ -47,6 +50,7 @@ public class DetailForm {
private JLabel powerSourceLabel;
private JLabel sensorsLabel;
private JTextPane sensorsTextPane;
private JScrollPane scrollPane;
private static final Log logger = LogFactory.get();
@ -67,11 +71,24 @@ public class DetailForm {
}
private static void initUi() {
DetailForm detailForm = getInstance();
ScrollUtil.smoothPane(detailForm.scrollPane);
Style.emphaticTitleFont(detailForm.getOsLabel());
Style.emphaticTitleFont(detailForm.getPowerSourceLabel());
detailForm.getPowerSourceTextPane().setContentType("text/html; charset=utf-8");
}
private static void initInfo() {
DetailForm detailForm = getInstance();
OperatingSystem operatingSystem = App.si.getOperatingSystem();
ComputerSystem computerSystem = App.si.getHardware().getComputerSystem();
HardwareAbstractionLayer hardware = App.si.getHardware();
ComputerSystem computerSystem = hardware.getComputerSystem();
detailForm.getPowerSourceTextPane().setText(PowerSourceForm.getPowerInfoText(hardware.getPowerSources()));
}
{
@ -91,12 +108,12 @@ public class DetailForm {
private void $$$setupUI$$$() {
mainPanel = new JPanel();
mainPanel.setLayout(new GridLayoutManager(1, 1, new Insets(0, 0, 0, 0), -1, -1));
final JScrollPane scrollPane1 = new JScrollPane();
mainPanel.add(scrollPane1, new GridConstraints(0, 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));
scrollPane1.setBorder(BorderFactory.createTitledBorder(BorderFactory.createEmptyBorder(), null, TitledBorder.DEFAULT_JUSTIFICATION, TitledBorder.DEFAULT_POSITION, null, null));
scrollPane = new JScrollPane();
mainPanel.add(scrollPane, new GridConstraints(0, 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));
scrollPane.setBorder(BorderFactory.createTitledBorder(BorderFactory.createEmptyBorder(), null, TitledBorder.DEFAULT_JUSTIFICATION, TitledBorder.DEFAULT_POSITION, null, null));
final JPanel panel1 = new JPanel();
panel1.setLayout(new GridLayoutManager(13, 1, new Insets(10, 10, 10, 10), -1, -1));
scrollPane1.setViewportView(panel1);
scrollPane.setViewportView(panel1);
final JPanel panel2 = new JPanel();
panel2.setLayout(new GridLayoutManager(2, 1, new Insets(10, 10, 10, 10), -1, -1));
panel1.add(panel2, 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));

View File

@ -130,7 +130,7 @@ public class PowerSourceForm {
}
private static String getPowerInfoText(List<PowerSource> powerSources) {
public static String getPowerInfoText(List<PowerSource> powerSources) {
StringBuilder powerInfoBuilder = new StringBuilder();
for (PowerSource powerSource : powerSources) {

View File

@ -0,0 +1,19 @@
package com.luoboduner.moo.info.util;
import javax.swing.*;
/**
* some functions about scroll
*
* @author <a href="https://github.com/rememberber">RememBerBer</a>
* @since 2021/11/23.
*/
public class ScrollUtil {
public static void smoothPane(JScrollPane scrollPane) {
scrollPane.getVerticalScrollBar().setUnitIncrement(16);
scrollPane.getHorizontalScrollBar().setUnitIncrement(16);
scrollPane.getVerticalScrollBar().setDoubleBuffered(true);
scrollPane.getHorizontalScrollBar().setDoubleBuffered(true);
}
}