1
public class ConsoleControl {

private static Viewer mainGUI;

public static Viewer getMainGUI()
{
    return mainGUI;        
}
    public static void main(String[] args){
    // Imports the Java UI Manager, which allows you to change the basic GUI of the Application
    try { 
        UIManager.setLookAndFeel("com.sun.java.swing.plaf.nimbus.NimbusLookAndFeel"); 
    } 
    catch (ClassNotFoundException | InstantiationException | IllegalAccessException | UnsupportedLookAndFeelException ex) {
}
    MainModel.setPetShop(FileIO.readPetShop("PetShop.csv"));
    MainModel.setPets(FileIO.readPets("Pets.csv"));
    MainModel.setFish(FileIO.readFish("Fish.csv"));

    MainModel.setPetShopHeader(new String[]{"Name","Address","Phone Number","Website","Opening Times"});
    MainModel.setPetsHeader(new String[]{"Shop","Type","Price","Date Acquired","Notes"});
    MainModel.setFishHeader(new String[]{"Shop","Type","Price","Date Acquired","Latin Name","Food Requirements"});
    mainGUI = new Viewer();
    mainGUI.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    }

  public static void actOnTableClick(int selectedRow)
{
    ArrayList<Integer> attRowsToHighlight = new ArrayList<>();
    if (mainGUI.getSelectedTab() == 0)
    {
        PetShop ourPetShop = MainModel.getPetShop().get(selectedRow);

        for (int i = 0; i < MainModel.getPets().size(); i++)
        {
            Pets ourPets = MainModel.getPets().get(i);

            if (ourPets.getShop().equals(ourPetShop.getName()))
            {
              //  System.out.print(ourPets);
                attRowsToHighlight.add(i);
               // System.out.print(i);
            }
        }
        mainGUI.highlightRows(1, attRowsToHighlight);
    }


   } }

なんらかの理由で、このコードは、タイトルに示されているエラーを表示し、膨大な数の例外リストを表示します。次に、コンソールがロードされますが、データはロードされず、コンソールのすべてのセクションにカーソルを合わせて表示する必要があります. 何か助けはありますか?

編集:例外は次のとおりです。

スレッド「AWT-EventQueue-0」での例外 java.lang.ArrayIndexOutOfBoundsException: 1 at javax.swing.JTable$1.getValueAt(JTable.java:689) at javax.swing.JTable.getValueAt(JTable.java:2720) at javax .swing.JTable.prepareRenderer(JTable.java:5718) at javax.swing.plaf.synth.SynthTableUI.paintCell(SynthTableUI.java:684) at javax.swing.plaf.synth.SynthTableUI.paintCells(SynthTableUI.java:581) ) javax.swing.plaf.synth.SynthTableUI.paint(SynthTableUI.java:365) で javax.swing.plaf.synth.SynthTableUI.update(SynthTableUI.java:276) で javax.swing.JComponent.paintComponent(JComponent. java:778) で javax.swing.JComponent.paint(JComponent.java:1054) で javax.swing.JComponent.paintChildren(JComponent.java:887) で javax.swing.JComponent.paint(JComponent.java:1063) でjavax.swing.JViewport.paint(JViewport.java:725) で javax.swing.JComponent.paintChildren(JComponent.java:887) で javax.swing.JComponent.paint(JComponent.java:1063) で javax.swing.JComponent.paintChildren(JComponent.java:887) でjavax.swing.JComponent.paint(JComponent.java:1063) で javax.swing.JComponent.paintChildren(JComponent.java:887) で javax.swing.JComponent.paint(JComponent.java:1063) で javax.swing.JComponent で.paintChildren(JComponent.java:887) at javax.swing.JComponent.paint(JComponent.java:1063) javax.swing.JComponent.paintChildren(JComponent.java:887) at javax.swing.JComponent.paint(JComponent. java:1063) で javax.swing.JLayeredPane.paint(JLayeredPane.java:585) で javax.swing.JComponent.paintChildren(JComponent.java:887) で javax.swing.JComponent.paintToOffscreen(JComponent.java:5228) でjavax.swing.RepaintManager$PaintManager.paintDoubleBuffered(RepaintManager.java:1482) で javax.swing.RepaintManager$PaintManager.paint(RepaintManager.java:1413) で javax.swing.RepaintManager.paint(RepaintManager.java:1206) で javax.swing.JComponent で.paint(JComponent.java:1040) で java.awt.GraphicsCallback$PaintCallback.run(GraphicsCallback.java:39) で sun.awt.SunGraphicsCallback.runOneComponent(SunGraphicsCallback.java:78) で sun.awt.SunGraphicsCallback.runComponents( SunGraphicsCallback.java:115) で java.awt.Container.paint(Container.java:1967) で java.awt.Window.paint(Window.java:3867) で javax.swing.RepaintManager.paintDirtyRegions(RepaintManager.java:781) で) javax.swing.RepaintManager.paintDirtyRegions(RepaintManager.java:728) で javax.swing.RepaintManager.prePaintDirtyRegions(RepaintManager.java:677) javax.swing.RepaintManager.access$700(RepaintManager.java:59) で javax.swing.RepaintManager$ProcessingRunnable.run(RepaintManager.java:1621) で java.awt.event.InvocationEvent.dispatch(InvocationEvent.java: 251) java.awt.EventQueue.dispatchEventImpl(EventQueue.java:705) で java.awt.EventQueue.access$000(EventQueue.java:101) で java.awt.EventQueue$3.run(EventQueue.java:666) でjava.awt.EventQueue$3.run(EventQueue.java:664) で java.security.AccessController.doPrivileged(Native Method) で java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.java:76) で java.awt.EventQueue で。 java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:211) での dispatchEvent(EventQueue.java:675) java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:128) java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:117)で java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:113)で java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:105)で java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:105)でawt.EventDispatchThread.run(EventDispatchThread.java:90) スレッド「AWT-EventQueue-0」での例外 java.lang.ArrayIndexOutOfBoundsException: javax.swing.JTable$1.getValueAt(JTable.java:689) で 1 JTable.getValueAt(JTable.java:2720) で javax.swing.JTable.prepareRenderer(JTable.java:5718) で javax.swing.plaf.synth.SynthTableUI.paintCell(SynthTableUI.java:684) で javax.swing.plaf .synth.SynthTableUI.paintCells(SynthTableUI.java:581) で javax.swing.plaf.synth.SynthTableUI.paint(SynthTableUI.java:365) で javax.swing.plaf.synth.SynthTableUI.update(SynthTableUI.java:276) at javax.swing.JComponent.paintComponent(JComponent.java:778) javax.swing.JComponent.paint(JComponent.java:1054) at javax.swing.JComponent.paintChildren(JComponent.java) :887) javax.swing.JComponent.paint(JComponent.java:1063) で javax.swing.JViewport.paint(JViewport.java:725) で javax.swing.JComponent.paintChildren(JComponent.java:887) で javax .swing.JComponent.paint(JComponent.java:1063) で javax.swing.JComponent.paintChildren(JComponent.java:887) で javax.swing.JComponent.paint(JComponent.java:1063) で javax.swing.JComponent で。 javax.swing.JComponent.paint(JComponent.java:1063) での paintChildren(JComponent.java:887) javax.swing.JComponent.paintChildren(JComponent.java:887) での javax.swing.JComponent.paint(JComponent.java) :1063) javax.swing で。javax.swing.JComponent.paint(JComponent.java:1063) の JComponent.paintChildren(JComponent.java:887) javax.swing.JLayeredPane.paint(JLayeredPane.java:585) の javax.swing.JComponent.paintChildren(JComponent) .java:887) で javax.swing.JComponent.paintToOffscreen(JComponent.java:5228) で javax.swing.RepaintManager$PaintManager.paintDoubleBuffered(RepaintManager.java:1482) で javax.swing.RepaintManager$PaintManager.paint(RepaintManager. java:1413) で javax.swing.RepaintManager.paint(RepaintManager.java:1206) で javax.swing.JComponent.paint(JComponent.java:1040) で java.awt.GraphicsCallback$PaintCallback.run(GraphicsCallback.java:39) で) で sun.awt.SunGraphicsCallback.runOneComponent(SunGraphicsCallback.java:78) で sun.awt.SunGraphicsCallback.runComponents(SunGraphicsCallback.java:115) で java.awt.Container.paint(Container.java:1967) で java.awt.Window.paint(Window.java:3867) で javax.swing.RepaintManager.paintDirtyRegions(RepaintManager.java:781) で javax.swing.RepaintManager.paintDirtyRegions で(RepaintManager.java:728) javax.swing.RepaintManager.prePaintDirtyRegions(RepaintManager.java:677) で javax.swing.RepaintManager.access$700(RepaintManager.java:59) で javax.swing.RepaintManager$ProcessingRunnable.run(RepaintManager) .java:1621) で java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:251) で java.awt.EventQueue.dispatchEventImpl(EventQueue.java:705) で java.awt.EventQueue.access$000(EventQueue.java) :101) java.awt.EventQueue$3.run(EventQueue.java:666) で java.awt.EventQueue$3.run(EventQueue.java:664) で java.security.AccessController で。java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.java:76) の doPrivileged(ネイティブ メソッド) java.awt.EventQueue.dispatchEvent(EventQueue.java:675) の doPrivileged(Native Method) ) java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:128) で java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:117) で java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:113) で java.awt で.EventDispatchThread.pumpEvents(EventDispatchThread.java:105) at java.awt.EventDispatchThread.run(EventDispatchThread.java:90)java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:128) の pumpOneEventForFilters(EventDispatchThread.java:211) java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:117) の java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java) :113) java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:105) で java.awt.EventDispatchThread.run(EventDispatchThread.java:90) でjava.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:128) の pumpOneEventForFilters(EventDispatchThread.java:211) java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:117) の java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java) :113) java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:105) で java.awt.EventDispatchThread.run(EventDispatchThread.java:90) でawt.EventDispatchThread.run(EventDispatchThread.java:90)awt.EventDispatchThread.run(EventDispatchThread.java:90)

4

2 に答える 2

0

この行

PetShop ourPetShop = MainModel.getPetShop().get(selectedRow);

おそらく故障しています。selectedRowは無効になります。

于 2013-01-04T11:45:07.840 に答える