线程“AWT-EventQueue-0”中的异常java.lang.IllegalArgumentException:null项目中的描边

时间:2014-02-26 02:40:27

标签: java multithreading swing jsp jfreechart

我收到此错误“ 线程“AWT-EventQueue-0”中的异常java.lang.IllegalArgumentException:null Stroke“ 在jsp中执行代码时。 jsp在另一个项目中工作正常但是当我在我的项目中使用它时,它收到了这个错误。

jsp代码是:

<%@ page language="java" import="java.util.*,java.sql.*,com.ibm.database.*,org.jfree.*" pageEncoding="ISO-8859-1"%>
<%String path = request.getContextPath();String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>

<%@ page import="java.awt.*"%>
<%@ page import="java.sql.Connection"%>
<%@ page import="java.sql.PreparedStatement"%>
<%@ page import="java.sql.ResultSet"%>

<%@ page import="org.jfree.chart.ChartFactory"%>
<%@ page import="org.jfree.chart.ChartFrame"%>
<%@ page import="org.jfree.chart.JFreeChart"%>
<%@ page import="org.jfree.chart.plot.PlotOrientation"%>
<%@ page import="org.jfree.data.category.DefaultCategoryDataset"%>
<%@ page import="org.jfree.chart.plot.CategoryPlot"%>

<%
String pc="SP120";//request.getParameter("pc");
String sc="SC14";//request.getParameter("sc");
BarChart lc= new BarChart(pc,sc);
response.sendRedirect("ViewMIS.jsp");
%>
<%! 
 public class BarChart {

public BarChart(String pc,String sc) 
{
     String title;
     title="Deviation between Forecasted and Actual Demand for Part "+pc+" of Service Centre "+sc;
     final DefaultCategoryDataset dataset = createDataset(pc,sc);
     final JFreeChart chart1 = createChart(dataset,title);
     ChartFrame frame = new ChartFrame("BarChart", chart1);
     frame.setSize(500,500);
     frame.setVisible(true);
}

private DefaultCategoryDataset createDataset(String pc,String sc)
{
    DefaultCategoryDataset dataset = new DefaultCategoryDataset();
    int i,j,k;
    try
    {
        Connection con=DbConnection.getMyConnection();
        PreparedStatement st=con.prepareStatement("select * from FDATA WHERE PARTCODE=? AND SERVICECENTREID=?");
        st.setString(1,pc);
        st.setString(2,sc);
        ResultSet rs1=st.executeQuery();    
        while(rs1.next())
        {
            i=rs1.getInt("WEEK");
            String h="WEEK "+i;
            j=rs1.getInt("FORECASTEDDATA");
            Connection con1=DbConnection.getMyConnection();
            PreparedStatement st1=con1.prepareStatement("select * from PASTCONSUMPTIONDATA WHERE PARTCODE=? AND SERVICECENTREID=?");
            st1.setString(1,pc);
            st1.setString(2,sc);
            ResultSet rs2=st1.executeQuery();
            while(rs2.next())
            {
                k=rs2.getInt("AMOUNTCONSUMED");
                dataset.setValue(j, "Forecasted Demand",h );
                dataset.setValue(k, "Actual Demand", h);
            }
        }
    }catch(Exception e){ e.printStackTrace(); }
    return dataset;
}

private JFreeChart createChart(final DefaultCategoryDataset dataset,String title)
{
    final JFreeChart chart = ChartFactory.createBarChart3D(
             title,      // chart title
            "Week",       // x axis label
            "Demand",          // y axis label
            dataset,            // data
            PlotOrientation.VERTICAL,
            true,                     // include legend
            true,                     // tooltips
            true );
     chart.setBackgroundPaint(Color.white);
     final CategoryPlot plot = chart.getCategoryPlot();
     plot.setBackgroundPaint(Color.lightGray);
     plot.setDomainGridlinePaint(Color.white);
     plot.setRangeGridlinePaint(Color.white);
     plot.setRangeCrosshairVisible(true);
    return chart;
}   
}
%>

错误是:

Exception in thread "AWT-EventQueue-0" java.lang.IllegalArgumentException: null Stroke
at sun.java2d.SunGraphics2D.setStroke(SunGraphics2D.java:1061)
at org.jfree.chart.plot.CategoryPlot.drawRangeLine(CategoryPlot.java:2415)
at org.jfree.chart.plot.CategoryPlot.draw(CategoryPlot.java:2041)
at org.jfree.chart.plot.Plot.draw(Plot.java:767)
at org.jfree.chart.JFreeChart.draw(JFreeChart.java:974)
at org.jfree.chart.ChartPanel.paintComponent(ChartPanel.java:1132)
at javax.swing.JComponent.paint(JComponent.java:1027)
at javax.swing.JComponent.paintChildren(JComponent.java:864)
at javax.swing.JComponent.paint(JComponent.java:1036)
at javax.swing.JLayeredPane.paint(JLayeredPane.java:564)
at javax.swing.JComponent.paintChildren(JComponent.java:864)
at javax.swing.JComponent.paintToOffscreen(JComponent.java:5129)
at javax.swing.RepaintManager$PaintManager.paintDoubleBuffered(RepaintManager.java:1472)
at javax.swing.RepaintManager$PaintManager.paint(RepaintManager.java:1403)
at javax.swing.RepaintManager.paint(RepaintManager.java:1217)
at javax.swing.JComponent.paint(JComponent.java:1013)
at java.awt.GraphicsCallback$PaintCallback.run(GraphicsCallback.java:21)
at sun.awt.SunGraphicsCallback.runOneComponent(SunGraphicsCallback.java:60)
at sun.awt.SunGraphicsCallback.runComponents(SunGraphicsCallback.java:97)
at java.awt.Container.paint(Container.java:1780)
at javax.swing.RepaintManager.paintDirtyRegions(RepaintManager.java:814)
at javax.swing.RepaintManager.paintDirtyRegions(RepaintManager.java:714)
at javax.swing.RepaintManager.seqPaintDirtyRegions(RepaintManager.java:694)
at javax.swing.SystemEventQueueUtilities$ComponentWorkRequest.run(SystemEventQueueUtilities.java:128)
at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:209)
at java.awt.EventQueue.dispatchEvent(EventQueue.java:597)
at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:269)
at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:184)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:174)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:169)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:161)

0 个答案:

没有答案