私はJFrameの名前の「jf_suggestionは」空の当初のJListが含まれている必要があり、それはDB、その名前の「jf_seggestion_liste」から文字列のリストで満たされます。JPA + SwingWorkerの:クエリエラー
//This is the method of triggering event
private void libel_articleKeyTyped(java.awt.event.KeyEvent evt) {
SwingWorker<Vector,String> sw=new SwingWorker<Vector,String>() {
@Override
protected Vector doInBackground() throws Exception {
ArticleJpaController ajc=null;
Vector l_article=(Vector) ajc.finArticleBylibelle(libel_article.getText());
return l_article;
}
@Override
protected void done(){
Vector l_article=null;
try {
l_article=get();
} catch (InterruptedException ex) {
Logger.getLogger(main.class.getName()).log(Level.SEVERE, null, ex);
} catch (ExecutionException ex) {
Logger.getLogger(main.class.getName()).log(Level.SEVERE, null, ex);
}
// filling the JList by recovered values
jf_seggestion_liste.setListData(l_article);
//we display our suggestion box
jf_suggestion.setVisible(true);
//recovering the size of our JXForamtedTextField
Rectangle rect = libel_article.getBounds();
//we create a new rectangle & setbounds(...) to the JFrame
Rectangle rectc = new Rectangle(rect.x+rect.width+23, rect.y+rect.height, 250, 350);
jf_suggestion.setBounds(rectc);
}
};
sw.execute();
}
: このJFrameの& JListのは、これは、カスタマイズされた提案システムがある
JXFormatedTextFieldの文字は、その「libel_article」という名前のユーザーの種類が... ...ここではソースコードだ時はいつでも表示されます文字列のリストを取得する方法:
public List<String> finArticleBylibelle(String libelle){
EntityManager em = getEntityManager();
Query qr= em.createQuery("SELECT a.libel FROM Article a WHERE a.libel='"+libelle+"'");
return qr.getResultList();
}
私も試してみました:
public List<String> finArticleBylibelle(String libelle){
EntityManager em = getEntityManager();
Query qr= em.createQuery("SELECT a.libel FROM Article a");
return qr.getResultList();
}
私はこのエラーを受け取ります(のl_article = get();)。):
java.util.concurrent.ExecutionException: java.lang.NullPointerException
at java.util.concurrent.FutureTask$Sync.innerGet(FutureTask.java:252)
at java.util.concurrent.FutureTask.get(FutureTask.java:111)
at javax.swing.SwingWorker.get(SwingWorker.java:602)
at glob.main$20.done(main.java:1241)
at javax.swing.SwingWorker$5.run(SwingWorker.java:737)
at javax.swing.SwingWorker$DoSubmitAccumulativeRunnable.run(SwingWorker.java:832)
at sun.swing.AccumulativeRunnable.run(AccumulativeRunnable.java:112)
at javax.swing.SwingWorker$DoSubmitAccumulativeRunnable.actionPerformed(SwingWorker.java:842)
at javax.swing.Timer.fireActionPerformed(Timer.java:312)
at javax.swing.Timer$DoPostEvent.run(Timer.java:244)
at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:251)
at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:705)
at java.awt.EventQueue.access$000(EventQueue.java:101)
at java.awt.EventQueue$3.run(EventQueue.java:666)
at java.awt.EventQueue$3.run(EventQueue.java:664)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.java:76)
at java.awt.EventQueue.dispatchEvent(EventQueue.java:675)
at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:211)
at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:128)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:117)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:113)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:105)
at java.awt.EventDispatchThread.run(EventDispatchThread.java:90)
Caused by: java.lang.NullPointerException
at glob.main$20.doInBackground(main.java:1232)
at glob.main$20.doInBackground(main.java:1226)
at javax.swing.SwingWorker$1.call(SwingWorker.java:296)
at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:334)
at java.util.concurrent.FutureTask.run(FutureTask.java:166)
at javax.swing.SwingWorker.run(SwingWorker.java:335)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1110)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:603)
at java.lang.Thread.run(Thread.java:722)
Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException
at javax.swing.JList$5.getSize(JList.java:1722)
at javax.swing.plaf.basic.BasicListUI.updateLayoutState(BasicListUI.java:1342)
at javax.swing.plaf.basic.BasicListUI.maybeUpdateLayoutState(BasicListUI.java:1311)
at javax.swing.plaf.basic.BasicListUI.getPreferredSize(BasicListUI.java:578)
at javax.swing.JComponent.getPreferredSize(JComponent.java:1660)
at javax.swing.ScrollPaneLayout.layoutContainer(ScrollPaneLayout.java:790)
at java.awt.Container.layout(Container.java:1503)
at java.awt.Container.doLayout(Container.java:1492)
at java.awt.Container.validateTree(Container.java:1688)
at java.awt.Container.validateTree(Container.java:1697)
at java.awt.Container.validateTree(Container.java:1697)
at java.awt.Container.validateTree(Container.java:1697)
at java.awt.Container.validateTree(Container.java:1697)
at java.awt.Container.validateTree(Container.java:1697)
at java.awt.Container.validate(Container.java:1623)
at java.awt.Container.validateUnconditionally(Container.java:1660)
at java.awt.Window.show(Window.java:1032)
at java.awt.Component.show(Component.java:1651)
at java.awt.Component.setVisible(Component.java:1603)
at java.awt.Window.setVisible(Window.java:1013)
at glob.main$20.done(main.java:1252)
at javax.swing.SwingWorker$5.run(SwingWorker.java:737)
at javax.swing.SwingWorker$DoSubmitAccumulativeRunnable.run(SwingWorker.java:832)
at sun.swing.AccumulativeRunnable.run(AccumulativeRunnable.java:112)
お問い合わせください!
何でもいい?? LOL、Solved ^^:repalce ArticleJpaController ajc = null; ArticleJpaControllerによるajc =新しいArticleJpaController(emf); :) –
'このエラー(行l_article = get();')を取得してください。SwingWorkerについてのこの例は、ここ2週間で同じマルウェアが存在するため、どこにありますか?http://stackoverflow.com/a/9229603/714968? – mKorbel
@mKorbel:笑、前に、私は2つの質問の著者です^^、 "最後の2週間"それは今朝だと思います:-) –