我无法获得弹出对话框的文本框的值.我遵循了其他StackOverflow问题的建议,这些问题说在program.cs中创建了一个公共变量:
public static string cashTendered { get; set; }
Run Code Online (Sandbox Code Playgroud)
然后我创建了这样的对话框:
Cash cashform = new Cash();
cashform.ShowDialog();
Run Code Online (Sandbox Code Playgroud)
当用户按下对话框上的按钮时,会调用:
if (isNumeric(textBox1.Text, System.Globalization.NumberStyles.Float))
{
Program.cashTendered = textBox1.Text;
this.Close();
}
else
{
MessageBox.Show("Please enter a valid amount of cash tendered. E.g. '5.50'");
}
Run Code Online (Sandbox Code Playgroud)
然而,Program.cashTendered保持为null.难道我做错了什么?谢谢!
我正在尝试将字符串转换为DateTime,并且在一台计算机上,它工作正常,但在另一台计算机上,它没有!它运行的计算机运行32位Windows 7,它无法运行的计算机运行64位Windows 7.继承人鳕鱼:
for (int i = 0; i < (lines / 5); i++)
{
MessageBox.Show(stringArray[(i * 5) + 4]);
TransactionList.Add(new Transaction
{
TotalEarned = Convert.ToDouble(stringArray[(i * 5)]),
TotalCost = Convert.ToDouble(stringArray[(i * 5) + 1]),
TotalHST = Convert.ToDouble(stringArray[(i * 5) + 2]),
Category = stringArray[(i * 5) + 3],
HoursSince2013 = Convert.ToDateTime(stringArray[(i * 5) + 4])
});
}
Run Code Online (Sandbox Code Playgroud)
该MessageBox是那里只是为了检查什么字符串未能转换,这是这一点,在第一次迭代:10/26/2013 11:58:03 AM
任何线索为什么这是无法在我的一台电脑上转换?我完全糊涂了......
谢谢!弥敦道
我正在尝试在 Java Swing 应用程序中编写一个简单的动画或物理示例。我已经打开并运行了实际的 Windows 应用程序,但我无法弄清楚如何实际绘制我的形状,以及如何格式化用于帧之间计算的代码,诸如此类的东西。
我读过一些关于重写绘制方法的内容,但我不知道这意味着什么,而且我不相信我在现在使用的代码中使用它。这是我的代码:
public class Physics extends JFrame{
public Physics() {
initUI();
}
private void initUI() {
JPanel panel = new JPanel();
getContentPane().add(panel);
panel.setLayout(null);
final JLabel label = new JLabel("Hi, press the button to do something");
label.setBounds(20, 0, 2000, 60);
final JButton submitButton = new JButton("Start");
submitButton.setBounds(20, 150, 80, 20);
submitButton.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
//Put button code here later
}
});
panel.add(label);
panel.add(submitButton);
setTitle("Program");
setSize(300, 250);
setLocationRelativeTo(null);
setDefaultCloseOperation(EXIT_ON_CLOSE);
}
public static …Run Code Online (Sandbox Code Playgroud) 在如下的程序中:
package testing;
import MarcoLib.Mouse;
import MarcoLib.Timings;
public class Testing {
/**
* @param args the command line arguments
*/
public static void main(String[] args) {
Mouse.pressMouse(1);
}
}
Run Code Online (Sandbox Code Playgroud)
有没有办法在Mouse.pressMouse()没有使用鼠标前缀的情况下打电话?
出于某种原因,在这个for循环中,我达到1,并导致index out of range错误.Items.Count等于4,我检查了断点,并且StockList.Count也等于4.我似乎无法弄清楚为什么我会达到一个,任何想法?
for (int i = 0; i <= (Items.Count / 4) - 1; i++)
{
for (int ii = 0;ii <= Program.StockList.Count - 1;i++)
{
if (Items[(i * 4) + 3] == Program.StockList[ii].ID) //Crash here
{
MessageBox.Show(Program.StockList[ii].Name + " Match!");
}
}
}
Run Code Online (Sandbox Code Playgroud) 在我的程序中,我收到错误:
An unhandled exception of type 'System.NullReferenceException' occurred in POS System.exe
Additional information: Object reference not set to an instance of an object.
Run Code Online (Sandbox Code Playgroud)
当我尝试向TransactionList添加内容时会发生这种情况,如下所示.TransactionList是一个类实例列表,声明如下:
public static List<Transaction> TransactionList { get; set; }
这是Transaction类:
class Transaction
{
public double TotalEarned { get; set; }
public double TotalHST { get; set; }
public double TotalCost { get; set; }
public string Category { get; set; }
public int DaysSince2013 { get; set; }
}
Run Code Online (Sandbox Code Playgroud)
有什么线索在这里错了吗?我似乎无法找到为什么抛出这个错误...谢谢!
for (int i = 0; i < …Run Code Online (Sandbox Code Playgroud) 我想通过一年的订阅来销售我一直在努力的程序.你怎么建议我这样做?显然,检查DateTime.Now不起作用,因为用户可以改变他的计算机时间.我想在我的程序文件中有一个加密的数字,从360倒数到0,但如果用户只是经常重新粘贴他们的程序文件,那么计时器永远不会耗尽.
你们觉得我应该做些什么?我可以访问网站和服务器,除了基本的HTML之外,我对Web开发知之甚少.让程序检查一个Web服务以查看密钥是否已过期是最好的方法吗?唯一的问题是,如果用户没有互联网,那就会出现问题.
让我知道你们的想法:D
谢谢