V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
claysec
V2EX  ›  Java

用 jformdesigner 画出来的 RsyntaxTextArea 无法正确显示行数

  •  
  •   claysec ·
    boku7 · 2022-09-09 10:23:57 +08:00 · 1041 次点击
    这是一个创建于 836 天前的主题,其中的信息可能已经有所发展或是发生改变。

    我用 jformdesigner 设计了一个界面,并且开启了显示行数,当前 ui 也有行数显示,如下 bhW7b 但是在我运行起来之后就没有行数显示了 H9o4Q 刚开始以为是 Flat 皮肤和 Mig 布局问题 但是我使用官方 demo 进行测试时候发现是可以显示行数的。 ykucy

    所以我不知道怎么解决这个问题了。找遍全网也没有类似的问题,

    测试代码:

    
    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.*;
    import net.miginfocom.swing.*;
    import org.fife.ui.rsyntaxtextarea.*;
    import org.fife.ui.rtextarea.*;
    
    /**
     * @author unknown
     */
    public class Database extends JFrame {
        public Database() {
            initComponents();
        }
    
        private void createUIComponents() {
            // TODO: add custom component creation code here
        }
    
        private void commonSql(ActionEvent e) {
            if(leftSplitPane.getDividerLocation() == 0){
                leftSplitPane.setDividerLocation(180);
            }else {
                leftSplitPane.setDividerLocation(0);
            }
    
        }
    
        private void initComponents() {
            // JFormDesigner - Component initialization - DO NOT MODIFY  //GEN-BEGIN:initComponents
            leftSplitPane = new JSplitPane();
            scrollPane1 = new JScrollPane();
            commonSQLStatementslLst = new JList();
            splitPane2 = new JSplitPane();
            panel1 = new JPanel();
            rTextScrollPane1 = new RTextScrollPane();
            sqlTextArea = new RSyntaxTextArea();
            label1 = new JLabel();
            encodeComboBox = new JComboBox<>();
            runSqlButton = new JButton();
            commonSqlButton = new JButton();
            scrollPane2 = new JScrollPane();
            sqlResutlTable = new JTable();
    
            //======== this ========
            Container contentPane = getContentPane();
            contentPane.setLayout(new CardLayout());
    
            //======== leftSplitPane ========
            {
                leftSplitPane.setDividerLocation(0);
    
                //======== scrollPane1 ========
                {
                    scrollPane1.setViewportView(commonSQLStatementslLst);
                }
                leftSplitPane.setLeftComponent(scrollPane1);
    
                //======== splitPane2 ========
                {
                    splitPane2.setOrientation(JSplitPane.VERTICAL_SPLIT);
                    splitPane2.setDividerLocation(160);
    
                    //======== panel1 ========
                    {
                        panel1.setLayout(new MigLayout(
                            "insets 0,hidemode 3",
                            // columns
                            "[fill]" +
                            "[fill]" +
                            "[fill]" +
                            "[fill]" +
                            "[grow,fill]",
                            // rows
                            "[grow,fill]" +
                            "[]"));
    
                        //======== rTextScrollPane1 ========
                        {
                            rTextScrollPane1.setLineNumbersEnabled(true);
    
                            //---- sqlTextArea ----
                            sqlTextArea.setParserDelay(0);
                            sqlTextArea.setSyntaxEditingStyle("text/sql");
                            rTextScrollPane1.setViewportView(sqlTextArea);
                        }
                        panel1.add(rTextScrollPane1, "cell 0 0 5 1");
    
                        //---- label1 ----
                        label1.setText("\u7f16\u7801:");
                        panel1.add(label1, "cell 0 1");
    
                        //---- encodeComboBox ----
                        encodeComboBox.setModel(new DefaultComboBoxModel<>(new String[] {
                            "UTF-8",
                            "GBK",
                            "GB2312"
                        }));
                        panel1.add(encodeComboBox, "cell 1 1");
    
                        //---- runSqlButton ----
                        runSqlButton.setText("\u8fd0\u884c");
                        panel1.add(runSqlButton, "cell 2 1");
    
                        //---- commonSqlButton ----
                        commonSqlButton.setText("\u5e38\u7528SQL\u8bed\u53e5");
                        commonSqlButton.addActionListener(e -> commonSql(e));
                        panel1.add(commonSqlButton, "cell 3 1");
                    }
                    splitPane2.setTopComponent(panel1);
    
                    //======== scrollPane2 ========
                    {
                        scrollPane2.setViewportView(sqlResutlTable);
                    }
                    splitPane2.setBottomComponent(scrollPane2);
                }
                leftSplitPane.setRightComponent(splitPane2);
            }
            contentPane.add(leftSplitPane, "card1");
            pack();
            setLocationRelativeTo(getOwner());
            // JFormDesigner - End of component initialization  //GEN-END:initComponents
        }
    
        // JFormDesigner - Variables declaration - DO NOT MODIFY  //GEN-BEGIN:variables
        private JSplitPane leftSplitPane;
        private JScrollPane scrollPane1;
        private JList commonSQLStatementslLst;
        private JSplitPane splitPane2;
        private JPanel panel1;
        private RTextScrollPane rTextScrollPane1;
        private RSyntaxTextArea sqlTextArea;
        private JLabel label1;
        private JComboBox<String> encodeComboBox;
        private JButton runSqlButton;
        private JButton commonSqlButton;
        private JScrollPane scrollPane2;
        private JTable sqlResutlTable;
        // JFormDesigner - End of variables declaration  //GEN-END:variables
    
        public static void main(String[] args) {
            new Database().setVisible(true);
    
        }
    }
    
    

    希望各位大佬能够帮忙看看是怎么回事。这事困扰我好久了

    目前尚无回复
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   实用小工具   ·   1014 人在线   最高记录 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 24ms · UTC 20:23 · PVG 04:23 · LAX 12:23 · JFK 15:23
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.