- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException
at my.Posterordering.PosterorderingUI.combostyleActionPerformed(PosterorderingUI.java:394)
at my.Posterordering.PosterorderingUI.access$500(PosterorderingUI.java:17)
at my.Posterordering.PosterorderingUI$6.actionPerformed(PosterorderingUI.java:201)
at javax.swing.JComboBox.fireActionEvent(JComboBox.java:1258)
at javax.swing.JComboBox.setSelectedItem(JComboBox.java:586)
at javax.swing.JComboBox.setSelectedIndex(JComboBox.java:622)
at javax.swing.plaf.basic.BasicComboPopup$Handler.mouseReleased(BasicComboPopup.java:834)
at java.awt.AWTEventMulticaster.mouseReleased(AWTEventMulticaster.java:290)
at java.awt.Component.processMouseEvent(Component.java:6525)
at javax.swing.JComponent.processMouseEvent(JComponent.java:3324)
at javax.swing.plaf.basic.BasicComboPopup$1.processMouseEvent(BasicComboPopup.java:498)
at java.awt.Component.processEvent(Component.java:6290)
at java.awt.Container.processEvent(Container.java:2234)
at java.awt.Component.dispatchEventImpl(Component.java:4881)
at java.awt.Container.dispatchEventImpl(Container.java:2292)
at java.awt.Component.dispatchEvent(Component.java:4703)
at java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:4898)
at java.awt.LightweightDispatcher.processMouseEvent(Container.java:4533)
at java.awt.LightweightDispatcher.dispatchEvent(Container.java:4462)
at java.awt.Container.dispatchEventImpl(Container.java:2278)
at java.awt.Window.dispatchEventImpl(Window.java:2750)
at java.awt.Component.dispatchEvent(Component.java:4703)
at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:758)
at java.awt.EventQueue.access$500(EventQueue.java:97)
at java.awt.EventQueue$3.run(EventQueue.java:709)
at java.awt.EventQueue$3.run(EventQueue.java:703)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.java:75)
at java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.java:86)
at java.awt.EventQueue$4.run(EventQueue.java:731)
at java.awt.EventQueue$4.run(EventQueue.java:729)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.java:75)
at java.awt.EventQueue.dispatchEvent(EventQueue.java:728)
at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:201)
at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:116)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:105)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:101)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:93)
at java.awt.EventDispatchThread.run(EventDispatchThread.java:82)
当我尝试运行代码时遇到问题,这是我的代码:
package my.Posterordering;
/**
*
* @author 100103562
*/
import javax.swing.*;
import javax.swing.JButton;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
public class PosterorderingUI extends javax.swing.JFrame {
/**
* Creates new form PosterorderingUI
*/
Double total = null;
Double size = null;
Double quantity = null;
Double colour = null;
Double style = null;
int postage = 10;
private void BtnHelpActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
JDialogExample jDialogExample = new JDialogExample();
}
private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
dispose();
}
private void jButton4ActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
}
private void BtnHelpMouseClicked(java.awt.event.MouseEvent evt) {
// TODO add your handling code here:
PosterorderingUI newFrame = new PosterorderingUI();
newFrame.setVisible(true);
jLabel15.setText("test");
}
private void comboSizeActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
if (comboSize.getSelectedItem().equals("Large")){
lblpstprice.setText(String.valueOf(10.00));
int size = 10;
lblTotal.setText(String.valueOf(size + postage));
}
else if (comboSize.getSelectedItem().equals("Small")){
lblpstprice.setText(String.valueOf(3.00));
int size = 3;
lblTotal.setText(String.valueOf(size + postage));
}
else if (comboSize.getSelectedItem().equals("Medium")){
lblpstprice.setText(String.valueOf(6.00));
int size = 6;
lblTotal.setText(String.valueOf(size + postage));
}
else {
lblpstprice.setText(String.valueOf("Please select a poster size"));
lblTotal.setText(String.valueOf("Error Occured"));
}
}
private void combostyleActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
if (combostyle.getSelectedItem().equals("Laminated")){
lblstyleprice.setText(String.valueOf(5.00));
int style = 5;
lblTotal.setText(String.valueOf(size + style + postage));
}
else if (combostyle.getSelectedItem().equals("Glossy")){
lblstyleprice.setText(String.valueOf(10.00));
int style = 5;
lblTotal.setText(String.valueOf(size + style + postage));
}
else if (combostyle.getSelectedItem().equals("Uncoated")){
lblstyleprice.setText(String.valueOf(0.00));
int style = 0;
lblTotal.setText(String.valueOf(size + style + postage));
}
else {
lblstyleprice.setText(String.valueOf("Please select a poster style"));
}
}
private void comboclrActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
if (comboclr.getSelectedItem().equals("Black")){
lblcolprice.setText(String.valueOf(2.00));
int colour = 2;
lblTotal.setText(String.valueOf(size + style + colour + postage));
}
else if (comboclr.getSelectedItem().equals("Red")){
lblcolprice.setText(String.valueOf(3.00));
int colour = 3;
lblTotal.setText(String.valueOf(size + style + colour + postage));
}
else if (comboclr.getSelectedItem().equals("Orange")){
lblcolprice.setText(String.valueOf(3.00));
int colour = 3;
lblTotal.setText(String.valueOf(size + style + colour + postage));
}
else if (comboclr.getSelectedItem().equals("Blue")){
lblcolprice.setText(String.valueOf(3.00));
lblTotal.setText(String.valueOf(size + style + colour + postage));
int colour = 3;
}
else if (comboclr.getSelectedItem().equals("Yellow")){
lblcolprice.setText(String.valueOf(3.00));
int colour = 3;
lblTotal.setText(String.valueOf(size + style + colour + postage));
}
else {
lblcolprice.setText(String.valueOf("Please select a color"));
lblTotal.setText(String.valueOf("An error has occured"));
}
if (combostyle.getSelectedItem().equals(" ") || (comboSize.getSelectedItem().equals(" ")) || (comboclr.getSelectedItem().equals(" "))){
lblqtot.setText(String.valueOf("Please complete the form"));
}
else if (comboquant.getSelectedItem().equals(1)){
int number = Integer.parseInt(lblTotal.getText());
int price = 1;
lblqtot.setText(String.valueOf(number * price));
lblTotal.setText(String.valueOf(size + style + colour + postage));
}
else if (comboquant.getSelectedItem().equals(2)){
int totals = Integer.parseInt(lblTotal.getText());
int quantity = 1;
lblTotal.setText(String.valueOf(size + style + colour + postage));
lblqtot.setText(String.valueOf(totals * quantity));
}
else if (comboquant.getSelectedItem().equals(3)){
int totals = Integer.parseInt(lblTotal.getText());
int quantity = 2;
lblTotal.setText(String.valueOf(size + style + colour + postage));
lblqtot.setText(String.valueOf(totals * quantity));
}
else if (comboquant.getSelectedItem().equals(4)){
int totals = Integer.parseInt(lblTotal.getText());
int quantity = 3;
lblTotal.setText(String.valueOf(size + style + colour + postage));
lblqtot.setText(String.valueOf(totals * quantity));
}
else if (comboquant.getSelectedItem().equals(5)){
int totals = Integer.parseInt(lblTotal.getText());
int quantity = 4;
lblTotal.setText(String.valueOf(size + style + colour + postage));
lblqtot.setText(String.valueOf(totals * quantity));
}
else if (comboquant.getSelectedItem().equals(6)){
int totals = Integer.parseInt(lblTotal.getText());
int quantity = 6;
lblTotal.setText(String.valueOf(size + style + colour + postage));
lblqtot.setText(String.valueOf(totals * quantity));
}
else if (comboquant.getSelectedItem().equals(7)){
int totals = Integer.parseInt(lblTotal.getText());
int quantity = 7;
lblTotal.setText(String.valueOf(size + style + colour + postage));
lblqtot.setText(String.valueOf(totals * quantity));
}
else if (comboquant.getSelectedItem().equals(8)){
int totals = Integer.parseInt(lblTotal.getText());
int quantity = 8;
lblTotal.setText(String.valueOf(size + style + colour + postage));
lblqtot.setText(String.valueOf(totals * quantity));
}
else if (comboquant.getSelectedItem().equals(9)){
int totals = Integer.parseInt(lblTotal.getText());
int quantity = 9;
lblTotal.setText(String.valueOf(size + style + colour + postage));
lblqtot.setText(String.valueOf(totals * quantity));
}
else if (comboquant.getSelectedItem().equals(10)){
int totals = Integer.parseInt(lblTotal.getText());
int quantity = 10;
lblTotal.setText(String.valueOf(size + style + colour + postage));
lblqtot.setText(String.valueOf(totals * quantity));
}
else if (comboquant.getSelectedItem().equals(11)){
int totals = Integer.parseInt(lblTotal.getText());
int quantity = 11;
lblTotal.setText(String.valueOf(size + style + colour + postage));
lblqtot.setText(String.valueOf(totals * quantity));
}
else if (comboquant.getSelectedItem().equals(12)){
int totals = Integer.parseInt(lblTotal.getText());
int quantity = 12;
lblTotal.setText(String.valueOf(size + style + colour + postage));
lblqtot.setText(String.valueOf(totals * quantity));
}
else if (comboquant.getSelectedItem().equals(13)){
int totals = Integer.parseInt(lblTotal.getText());
int quantity = 13;
lblTotal.setText(String.valueOf(size + style + colour + postage));
lblqtot.setText(String.valueOf(totals * quantity));
}
else if (comboquant.getSelectedItem().equals(14)){
int totals = Integer.parseInt(lblTotal.getText());
int quantity = 15;
lblTotal.setText(String.valueOf(size + style + colour + postage));
lblqtot.setText(String.valueOf(totals * quantity));
}
else if (comboquant.getSelectedItem().equals("15")){
int totals = Integer.parseInt(lblTotal.getText());
int quantity = 15;
lblTotal.setText(String.valueOf(size + style + colour + postage));
lblqtot.setText(String.valueOf(totals * quantity));
}
}
我希望代码足够容易理解(遗憾的是,它有点困惑!)当我在海报样式组合框中选择任何内容时,我遇到了这个错误。海报尺寸框工作正常,所以我有点难住了!
最佳答案
您的双倍尺寸
始终为空。您没有在组合样式 ActionPerformed() 方法中获得它,但尝试在 sum 中使用
关于java - 如何解决选择组合框项目时出现错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30581932/
是否有某种方法可以使用 JPA 或 Hibernate Crtiteria API 来表示这种 SQL?或者我应该将其作为 native 执行吗? SELECT A.X FROM (SELECT X,
在查询中, select id,name,feature,marks from (....) 我想删除其 id 在另一个 select 语句中存在的那些。 从 (...) 中选择 id 我是 sql
我想响应用户在 select 元素中选择一个项目。然而这个 jQuery: $('#platypusDropDown').select(function () { alert('You sel
这个问题在这里已经有了答案: SQL select only rows with max value on a column [duplicate] (27 个回答) 关闭8年前。 我正在学习 SQL
This question already has answers here: “Notice: Undefined variable”, “Notice: Undefined index”, and
我在 php 脚本中调用 SQL。有时“DE”中没有值,如果是这种情况我想从“EN”中获取值 应该是这样的,但不是这样的 IF (EXISTS (SELECT epf_application_deta
这可能是一个奇怪的问题,但不知道如何研究它。执行以下查询时: SELECT Foo.col1, Foo.col2, Foo.col3 FROM Foo INNER JOIN Bar ON
如何在使用 Camera.DestinationType.FILE_URI. 时在 phonegap camera API 中同时选择或拾取多个图像我能够一次只选择一张图像。我可以使用 this 在
这是一个纯粹的学术问题。这两个陈述实际上是否相同? IF EXISTS (SELECT TOP 1 1 FROM Table1) SELECT 1 ELSE SELECT 0 相对 IF EXIS
我使用 JSoup 来解析 HTML 响应。我有多个 Div 标签。我必须根据 ID 选择 Div 标签。 我的伪代码是这样的 Document divTag = Jsoup.connect(link
我正在处理一个具有多个选择框的表单。当用户从 selectbox1 中选择一个选项时,我需要 selectbox2 active 的另一个值。同样,当他选择 selectbox2 的另一个值时,我需要
Acme Inc. Christa Woods Charlotte Freeman Jeffrey Walton Ella Hubbard Se
我有一个login.html其中form定义如下: First Initial Plus Last Name : 我的do_authorize如下: "; pri
$.get( 'http://www.ufilme.ro/api/load/maron_online/470', function(data
我有一个下拉列表“磅”、“克”、“千克”和“盎司”。我想要这样一种情况,当我选择 gram 来执行一个函数时,当我在输入字段中输入一个值时,当我选择 pounds 时,我想要另一个函数来执行时我在输入
我有一个 GLSL 着色器,它从输入纹理的 channel 之一(例如 R)读取,然后写入输出纹理中的同一 channel 。该 channel 必须由用户选择。 我现在能想到的就是使用一个 int
我想根据下拉列表中的选定值生成输入文本框。 Options 2 3 4 5 就在这个选择框之后,一些输入字段应该按照选定的数字出现。 最佳答案 我建议您使用响应式(Reac
我是 SQL 新手,我想问一下如何根据首选项和分组选择条目。 +----------+----------+------+ | ENTRY_ID | ROUTE_ID | TYPE | +------
我有以下表结构: CREATE TABLE [dbo].[UTS_USERCLIENT_MAPPING_USER_LIST] ( [MAPPING_ID] [int] IDENTITY(1,1
我在移除不必要的床单时遇到了问题。我查看了不同的论坛并将不同的解决方案混合在一起。 此宏删除工作表(第一张工作表除外)。 Sub wrong() Dim sht As Object Applicati
我是一名优秀的程序员,十分优秀!