- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我已经查看并测试了各种方法,但是这个面板(通过另一个面板组件调用)将看不到 actionListener 已设置。我正在 Netbeans 7.0 中工作。这是面板代码:
public class PanelAddClient extends javax.swing.JPanel {
private AppEventListener appEventListener;
public PanelAddClient() {
initComponents();
//paneClientDBTable = new PanelClientDBTable(sqlModule);
}
/**
* This method is called from within the constructor to initialize the form.
* WARNING: Do NOT modify this code. The content of this method is always
* regenerated by the Form Editor.
*/
@SuppressWarnings("unchecked")
// <editor-fold defaultstate="collapsed" desc="Generated Code">
private void initComponents() {
java.awt.GridBagConstraints gridBagConstraints;
jToolBar1 = new javax.swing.JToolBar();
filler1 = new javax.swing.Box.Filler(new java.awt.Dimension(500, 0), new java.awt.Dimension(500, 0), new java.awt.Dimension(500, 32767));
jLabel11 = new javax.swing.JLabel();
jPanel1 = new javax.swing.JPanel();
jLabel1 = new javax.swing.JLabel();
textClientNo = new javax.swing.JTextField();
jLabel2 = new javax.swing.JLabel();
textFName = new javax.swing.JTextField();
jLabel3 = new javax.swing.JLabel();
textLName = new javax.swing.JTextField();
jLabel4 = new javax.swing.JLabel();
textStreetAddress = new javax.swing.JTextField();
jLabel5 = new javax.swing.JLabel();
textCity = new javax.swing.JTextField();
jLabel6 = new javax.swing.JLabel();
comboStatebox = new javax.swing.JComboBox();
jLabel7 = new javax.swing.JLabel();
textZipCode = new javax.swing.JTextField();
jPanel2 = new javax.swing.JPanel();
jLabel8 = new javax.swing.JLabel();
textHomePhone = new javax.swing.JTextField();
jLabel9 = new javax.swing.JLabel();
textMobilePhone = new javax.swing.JTextField();
jLabel10 = new javax.swing.JLabel();
textEmail = new javax.swing.JTextField();
buttonAddClient = new javax.swing.JButton();
setLayout(new java.awt.BorderLayout());
jToolBar1.setBackground(new java.awt.Color(102, 0, 102));
jToolBar1.setFloatable(false);
jToolBar1.setRollover(true);
jToolBar1.add(filler1);
jLabel11.setFont(new java.awt.Font("Tahoma", 1, 18)); // NOI18N
jLabel11.setForeground(new java.awt.Color(51, 255, 51));
jLabel11.setText("Add New Client Panel");
jToolBar1.add(jLabel11);
add(jToolBar1, java.awt.BorderLayout.PAGE_START);
jPanel1.setBackground(new java.awt.Color(204, 0, 204));
jLabel1.setFont(new java.awt.Font("Tahoma", 1, 12)); // NOI18N
jLabel1.setForeground(new java.awt.Color(255, 255, 255));
jLabel1.setText("Client Number:");
textClientNo.setToolTipText("");
textClientNo.setPreferredSize(new java.awt.Dimension(50, 15));
jLabel2.setFont(new java.awt.Font("Tahoma", 1, 12)); // NOI18N
jLabel2.setForeground(new java.awt.Color(255, 255, 255));
jLabel2.setText("First Name :");
jLabel2.setToolTipText("");
textFName.setToolTipText("");
jLabel3.setFont(new java.awt.Font("Tahoma", 1, 12)); // NOI18N
jLabel3.setForeground(new java.awt.Color(255, 255, 255));
jLabel3.setText("Last Name :");
jLabel3.setToolTipText("");
textLName.setToolTipText("");
jLabel4.setFont(new java.awt.Font("Tahoma", 1, 12)); // NOI18N
jLabel4.setForeground(new java.awt.Color(255, 255, 255));
jLabel4.setText("Stree Address :");
textStreetAddress.setToolTipText("");
jLabel5.setFont(new java.awt.Font("Tahoma", 1, 12)); // NOI18N
jLabel5.setForeground(new java.awt.Color(255, 255, 255));
jLabel5.setText("City :");
textCity.setToolTipText("");
jLabel6.setFont(new java.awt.Font("Tahoma", 1, 12)); // NOI18N
jLabel6.setForeground(new java.awt.Color(255, 255, 255));
jLabel6.setText("State :");
comboStatebox.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "AL", "AK", "MS", "CA", "TX", "OK", "GA", "SC", "TN", "NC", "NY", "IL", "LA", "IN", "WA", "ND", "SD", "MD", "CO", "MA", "RI" }));
jLabel7.setFont(new java.awt.Font("Tahoma", 1, 12)); // NOI18N
jLabel7.setForeground(new java.awt.Color(255, 255, 255));
jLabel7.setText("Zip Code :");
textZipCode.setToolTipText("");
jPanel2.setBackground(new java.awt.Color(204, 0, 204));
jPanel2.setBorder(javax.swing.BorderFactory.createTitledBorder(null, "Contact Information", javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, javax.swing.border.TitledBorder.DEFAULT_POSITION, new java.awt.Font("Tahoma", 1, 12), java.awt.Color.white)); // NOI18N
jPanel2.setForeground(new java.awt.Color(255, 255, 255));
jPanel2.setLayout(new java.awt.GridBagLayout());
jLabel8.setFont(new java.awt.Font("Tahoma", 1, 12)); // NOI18N
jLabel8.setForeground(new java.awt.Color(255, 255, 255));
jLabel8.setText("Phone Number :");
jPanel2.add(jLabel8, new java.awt.GridBagConstraints());
textHomePhone.setPreferredSize(new java.awt.Dimension(100, 20));
jPanel2.add(textHomePhone, new java.awt.GridBagConstraints());
jLabel9.setFont(new java.awt.Font("Tahoma", 1, 12)); // NOI18N
jLabel9.setForeground(new java.awt.Color(255, 255, 255));
jLabel9.setText("Mobile Phone :");
gridBagConstraints = new java.awt.GridBagConstraints();
gridBagConstraints.gridx = 0;
jPanel2.add(jLabel9, gridBagConstraints);
textMobilePhone.setPreferredSize(new java.awt.Dimension(100, 20));
gridBagConstraints = new java.awt.GridBagConstraints();
gridBagConstraints.gridx = 1;
gridBagConstraints.gridy = 1;
jPanel2.add(textMobilePhone, gridBagConstraints);
jLabel10.setFont(new java.awt.Font("Tahoma", 1, 12)); // NOI18N
jLabel10.setForeground(new java.awt.Color(255, 255, 255));
jLabel10.setText("Email :");
gridBagConstraints = new java.awt.GridBagConstraints();
gridBagConstraints.gridx = 0;
gridBagConstraints.gridy = 2;
jPanel2.add(jLabel10, gridBagConstraints);
textEmail.setToolTipText("");
textEmail.setMaximumSize(new java.awt.Dimension(100, 27));
textEmail.setMinimumSize(new java.awt.Dimension(100, 20));
textEmail.setPreferredSize(new java.awt.Dimension(100, 20));
gridBagConstraints = new java.awt.GridBagConstraints();
gridBagConstraints.gridx = 1;
gridBagConstraints.gridy = 2;
jPanel2.add(textEmail, gridBagConstraints);
buttonAddClient.setBackground(new java.awt.Color(204, 153, 0));
buttonAddClient.setFont(new java.awt.Font("Tahoma", 1, 12)); // NOI18N
buttonAddClient.setForeground(new java.awt.Color(153, 0, 0));
buttonAddClient.setText("Add Client Now");
buttonAddClient.setFocusable(false);
buttonAddClient.setHorizontalAlignment(javax.swing.SwingConstants.LEFT);
buttonAddClient.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
buttonAddClient.setInheritsPopupMenu(true);
buttonAddClient.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
buttonAddClient.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
buttonAddClientActionPerformed(evt);
}
});
javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
jPanel1.setLayout(jPanel1Layout);
jPanel1Layout.setHorizontalGroup(
jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel1Layout.createSequentialGroup()
.addContainerGap()
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
.addGroup(jPanel1Layout.createSequentialGroup()
.addComponent(jLabel1)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addComponent(textClientNo, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGroup(jPanel1Layout.createSequentialGroup()
.addComponent(jLabel4)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addComponent(textStreetAddress, javax.swing.GroupLayout.PREFERRED_SIZE, 352, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGroup(jPanel1Layout.createSequentialGroup()
.addComponent(jLabel2)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addComponent(textFName, javax.swing.GroupLayout.PREFERRED_SIZE, 91, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(31, 31, 31)
.addComponent(jLabel3)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(textLName))
.addGroup(jPanel1Layout.createSequentialGroup()
.addComponent(jLabel5)
.addGap(18, 18, 18)
.addComponent(textCity, javax.swing.GroupLayout.PREFERRED_SIZE, 97, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(40, 40, 40)
.addComponent(jLabel6)
.addGap(18, 18, 18)
.addComponent(comboStatebox, javax.swing.GroupLayout.PREFERRED_SIZE, 80, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(18, 18, 18)
.addComponent(jLabel7)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(textZipCode, javax.swing.GroupLayout.PREFERRED_SIZE, 46, javax.swing.GroupLayout.PREFERRED_SIZE)))
.addContainerGap(267, Short.MAX_VALUE))
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel1Layout.createSequentialGroup()
.addComponent(jPanel2, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addContainerGap())
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel1Layout.createSequentialGroup()
.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(buttonAddClient)
.addGap(279, 279, 279))
);
jPanel1Layout.setVerticalGroup(
jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel1Layout.createSequentialGroup()
.addGap(40, 40, 40)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(textClientNo, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jLabel1))
.addGap(18, 18, 18)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jLabel2)
.addComponent(textFName, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jLabel3)
.addComponent(textLName, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGap(18, 18, 18)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jLabel4)
.addComponent(textStreetAddress, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGap(18, 18, 18)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jLabel5)
.addComponent(textCity, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jLabel6)
.addComponent(comboStatebox, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jLabel7)
.addComponent(textZipCode, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGap(30, 30, 30)
.addComponent(jPanel2, javax.swing.GroupLayout.PREFERRED_SIZE, 100, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(18, 18, 18)
.addComponent(buttonAddClient)
.addContainerGap())
);
add(jPanel1, java.awt.BorderLayout.CENTER);
}// </editor-fold>
private void buttonAddClientActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
//card.show(panelMain, PANEL_SQLDB_RESULT);
//SQLModule sqlModule = new SQLModule();
//this.appEventListener = appEventListener;
//JOptionPane.showMessageDialog(null, "Button Add Client Clicked On", "Client ADD Button Click", JOptionPane.ERROR_MESSAGE);
String clientNo = textClientNo.getText();
String clientFName = textFName.getText();
String clientLName = textLName.getText();
if (clientNo.equals("")) {
JOptionPane.showMessageDialog(this, "You must enter a Client Number (Client ID).", "Error", JOptionPane.ERROR_MESSAGE);
textClientNo.requestFocus();
return;
}
System.out.print("JUST BEFORE APP-EVENT " + clientNo + " was HIT!");
//appEventListener.buttonAddClientActionPerformed(clientNo, clientFName, clientLName);
if (appEventListener != null) {
System.out.print(" appEventListener " + clientNo + " was Secondly HIT!");
appEventListener.buttonAddClientActionPerformed(clientNo, clientFName, clientLName);
}
}
<小时/>
这就是我得到空指针(或缺少空指针)的地方..,由于 appEventListener 为空,因此该代码永远不会被执行。
<小时/>if (appEventListener != null) {
System.out.print(" appEventListener " + clientNo + " was Secondly HIT!");
appEventListener.buttonAddClientActionPerformed(clientNo, clientFName, clientLName);
}
Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException
at com.zflex.cims.panels.PanelAddClient.buttonAddClientActionPerformed(PanelAddClient.java:297)
at com.zflex.cims.panels.PanelAddClient.access$000(PanelAddClient.java:16)
at com.zflex.cims.panels.PanelAddClient$1.actionPerformed(PanelAddClient.java:181)
at javax.swing.AbstractButton.fireActionPerformed(AbstractButton.java:1995)
at javax.swing.AbstractButton$Handler.actionPerformed(AbstractButton.java:2318)
at javax.swing.DefaultButtonModel.fireActionPerformed(DefaultButtonModel.java:387)
at javax.swing.DefaultButtonModel.setPressed(DefaultButtonModel.java:242)
at javax.swing.plaf.basic.BasicButtonListener.mouseReleased(BasicButtonListener.java:236)
at java.awt.Component.processMouseEvent(Component.java:6038)
at javax.swing.JComponent.processMouseEvent(JComponent.java:3260)
at java.awt.Component.processEvent(Component.java:5803)
at java.awt.Container.processEvent(Container.java:2058)
at java.awt.Component.dispatchEventImpl(Component.java:4410)
at java.awt.Container.dispatchEventImpl(Container.java:2116)
at java.awt.Component.dispatchEvent(Component.java:4240)
at java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:4322)
at java.awt.LightweightDispatcher.processMouseEvent(Container.java:3986)
at java.awt.LightweightDispatcher.dispatchEvent(Container.java:3916)
at java.awt.Container.dispatchEventImpl(Container.java:2102)
at java.awt.Window.dispatchEventImpl(Window.java:2429)
at java.awt.Component.dispatchEvent(Component.java:4240)
at java.awt.EventQueue.dispatchEvent(EventQueue.java:599)
at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:273)
at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:183)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:173)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:168)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:160)
at java.awt.EventDispatchThread.run(EventDispatchThread.java:121)
就在 APP-EVENT 6565 即将结束之前
<小时/>public interface AppEventListener {
public void buttonAddClientActionPerformed(String clientNo, String clientFName, String clientLName);
//void buttonDisplayRawLDAPStatsActionPerformed();
}
最佳答案
您声明了事件监听器,但从未像这样初始化它:
private AppEventListener appEventListener = new AppEventListener();
在使用之前声明它(例如在 initComponet()
中)
关于java - 我在面板上有一个用于按钮的 actionListener,获取空指针,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15948499/
我正在编写一个具有以下签名的 Java 方法。 void Logger(Method method, Object[] args); 如果一个方法(例如 ABC() )调用此方法 Logger,它应该
我是 Java 新手。 我的问题是我的 Java 程序找不到我试图用作的图像文件一个 JButton。 (目前这段代码什么也没做,因为我只是得到了想要的外观第一的)。这是我的主课 代码: packag
好的,今天我在接受采访,我已经编写 Java 代码多年了。采访中说“Java 垃圾收集是一个棘手的问题,我有几个 friend 一直在努力弄清楚。你在这方面做得怎么样?”。她是想骗我吗?还是我的一生都
我的 friend 给了我一个谜语让我解开。它是这样的: There are 100 people. Each one of them, in his turn, does the following
如果我将使用 Java 5 代码的应用程序编译成字节码,生成的 .class 文件是否能够在 Java 1.4 下运行? 如果后者可以工作并且我正在尝试在我的 Java 1.4 应用程序中使用 Jav
有关于why Java doesn't support unsigned types的问题以及一些关于处理无符号类型的问题。我做了一些搜索,似乎 Scala 也不支持无符号数据类型。限制是Java和S
我只是想知道在一个 java 版本中生成的字节码是否可以在其他 java 版本上运行 最佳答案 通常,字节码无需修改即可在 较新 版本的 Java 上运行。它不会在旧版本上运行,除非您使用特殊参数 (
我有一个关于在命令提示符下执行 java 程序的基本问题。 在某些机器上我们需要指定 -cp 。 (类路径)同时执行java程序 (test为java文件名与.class文件存在于同一目录下) jav
我已经阅读 StackOverflow 有一段时间了,现在我才鼓起勇气提出问题。我今年 20 岁,目前在我的家乡(罗马尼亚克卢日-纳波卡)就读 IT 大学。足以介绍:D。 基本上,我有一家提供簿记应用
我有 public JSONObject parseXML(String xml) { JSONObject jsonObject = XML.toJSONObject(xml); r
我已经在 Java 中实现了带有动态类型的简单解释语言。不幸的是我遇到了以下问题。测试时如下代码: def main() { def ks = Map[[1, 2]].keySet()
一直提示输入 1 到 10 的数字 - 结果应将 st、rd、th 和 nd 添加到数字中。编写一个程序,提示用户输入 1 到 10 之间的任意整数,然后以序数形式显示该整数并附加后缀。 public
我有这个 DownloadFile.java 并按预期下载该文件: import java.io.*; import java.net.URL; public class DownloadFile {
我想在 GUI 上添加延迟。我放置了 2 个 for 循环,然后重新绘制了一个标签,但这 2 个 for 循环一个接一个地执行,并且标签被重新绘制到最后一个。 我能做什么? for(int i=0;
我正在对对象 Student 的列表项进行一些测试,但是我更喜欢在 java 类对象中创建硬编码列表,然后从那里提取数据,而不是连接到数据库并在结果集中选择记录。然而,自从我这样做以来已经很长时间了,
我知道对象创建分为三个部分: 声明 实例化 初始化 classA{} classB extends classA{} classA obj = new classB(1,1); 实例化 它必须使用
我有兴趣使用 GPRS 构建车辆跟踪系统。但是,我有一些问题要问以前做过此操作的人: GPRS 是最好的技术吗?人们意识到任何问题吗? 我计划使用 Java/Java EE - 有更好的技术吗? 如果
我可以通过递归方法反转数组,例如:数组={1,2,3,4,5} 数组结果={5,4,3,2,1}但我的结果是相同的数组,我不知道为什么,请帮助我。 public class Recursion { p
有这样的标准方式吗? 包括 Java源代码-测试代码- Ant 或 Maven联合单元持续集成(可能是巡航控制)ClearCase 版本控制工具部署到应用服务器 最后我希望有一个自动构建和集成环境。
我什至不知道这是否可能,我非常怀疑它是否可能,但如果可以,您能告诉我怎么做吗?我只是想知道如何从打印机打印一些文本。 有什么想法吗? 最佳答案 这里有更简单的事情。 import javax.swin
我是一名优秀的程序员,十分优秀!