1

我得到以下异常

Exception in thread "AWT-EventQueue-0" java.lang.NoClassDefFoundError: org/divxdede/text/TimeFormat
at org.divxdede.swing.busy.ui.BasicBusyLayerUI.<init>(BasicBusyLayerUI.java:102)
at org.divxdede.swing.busy.ui.BasicBusyLayerUI.<init>(BasicBusyLayerUI.java:138)
at org.divxdede.swing.busy.JBusyComponent.<init>(JBusyComponent.java:105)
at jewelleryerpapplication.GUI.Gold.IssueToRep1.<init>(IssueToRep1.java:136)
at jewelleryerpapplication.GUI.Gold.IssueToRep1.Instance(IssueToRep1.java:164)

我在我的项目中添加了以下库

  • jbusycomponent-1.2.2.jar
  • SwingX 1.6
  • JXLayer 3.0.4
  • Jarvis-Commons 0.1

当我使用下面的代码将JXBusyLayer组件添加到我的JFrame(同时用组件包装现有JTable组件时)JXBusyLayer

     JBusyComponent<JTable> busytblDetailInfo = new JBusyComponent<JTable>(tblDetailInfo);
     myJFrame.add(busytblDetailInfo);

使用链接

 Edit

添加了库 Commons-0.2 并且异常消失了。

Error 2 !

现在在 JBusyControl 包装的控件(JTable)上看不到任何数据。

Edit 2

添加了下面的代码(通过@MadProgrammer 的评论),但问题仍然没有要查看的数据。

        jFrame.remove(tblDetailInfo);
        DefaultTableModel dtm = new DefaultTableModel(data, header);
        tblDetailInfo.setModel(dtm);
        JBusyComponent<JTable> busytblDetailInfo = new JBusyComponent<JTable>(tblDetailInfo_OrderInfo);
        jFrame.add(busytblDetailInfo);
4

1 回答 1

5

我发现它不喜欢被包裹在JScrollPane我认为很奇怪的东西中:P

(I lie, BusyComponent "likes" being added to a JScrollPane; but you probably don't want to)

enter image description here

public class TestBusy {

    public static void main(String[] args) {
        new TestBusy();
    }

    public TestBusy() {
        EventQueue.invokeLater(new Runnable() {
            @Override
            public void run() {
                try {
                    UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
                } catch (ClassNotFoundException | InstantiationException | IllegalAccessException | UnsupportedLookAndFeelException ex) {
                }

                JFrame frame = new JFrame();
                frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
                frame.setLayout(new BorderLayout());
                frame.add(new ContentPane());
                frame.pack();
                frame.setLocationRelativeTo(null);
                frame.setVisible(true);
            }
        });
    }

    public class ContentPane extends JPanel {

        private JTable table;

        public ContentPane() {
            setLayout(new BorderLayout());
            table = new JTable();
            table.setFillsViewportHeight(true);

            DefaultTableModel model = new DefaultTableModel();
            model.addColumn("One");
            model.addColumn("Two");
            model.addColumn("Three");
            model.addColumn("Four");
            model.addColumn("Five");
            model.addColumn("Six");
            model.addColumn("Seven");
            table.setModel(model);
            JScrollPane scrollPane = new JScrollPane(table);

            JBusyComponent<JScrollPane> busyComponent = new JBusyComponent<JScrollPane>(scrollPane);
            add(busyComponent);

            busyComponent.getBusyModel().setMinimum(0);
            busyComponent.getBusyModel().setMaximum(10000);

            busyComponent.setBusy(true);
            BusySwingWorker<Object, Object[]> worker = new BusySwingWorker<Object, Object[]>(busyComponent.getBusyModel()) {

                @Override
                protected void process(List<Object[]> chunks) {
                    DefaultTableModel model = (DefaultTableModel) table.getModel();
                    for (Object[] chunk : chunks) {
                        model.addRow(chunk);
                    }
                }

                @Override
                protected Object doInBackground() throws Exception {
                    for (int index = 0; index < 1000; index++) {
                        setProgress(Math.round((index / 1000f) * 100f));
                        publish(new Object[]{index, "B", "C", "D", "E", "F", "G"});
                        Thread.sleep(5);
                    }
                    return null;
                }
            };
            worker.execute();
        }
    }
}
于 2012-11-30T05:01:00.150 回答