这是我第一次在JAVA中编程GUI。我正在为我的项目尝试转换器程序,但是当我尝试运行程序时,我没有得到任何输出。我的代码还没有完成。
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>VideoOrganiser</title>
<!-- Latest compiled and minified CSS -->
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u" crossorigin="anonymous">
<!-- Optional theme -->
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap-theme.min.css" integrity="sha384-rHyoN1iRsVXV4nD0JutlnGaslCJuC7uwjduW9SVrLvRYooPp2bWYgmgJQIXwl/Sp" crossorigin="anonymous">
<!-- Latest compiled and minified JavaScript -->
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.1/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
{% load static %}
<link href="{% static 'mfo/base_style.css' %}" rel="stylesheet" type="text/css">
<script src="{% static 'scripts/index.js' %}" type="text/javascript"></script>
<script src="{% static 'scripts/bootstrap-uploadprogress.js' %}" type="text/javascript"> </script>
</head>
<body data-spy="spyscroll">
<nav class="navbar navbar-custom">
<div class="container-fluid">
<!-- Brand and toggle get grouped for better mobile display -->
<div class="navbar-header">
<button type="button" class="navbar-toggle" data-toggle="collapse"
data-target="#bs-example-navbar-collapse-1" aria-expanded="false">
<span class="sr-only">Toggle navigation</span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
</div>
<!-- Collect the nav links, forms, and other content for toggling -->
<div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
<ul class="nav navbar-nav">
<li><a href="/" style="font-size: 200%">VideoOrganiser</a></li>
</ul>
<ul class="nav navbar-nav navbar-right">
<li style="padding-top: 11px">
<!-- Trigger the modal with a button -->
<button type="button" class="btn btn-primary" data-toggle="modal" data-target="#myModal">Upload Media</button>
</li>
</ul>
</div><!-- /.navbar-collapse -->
</div><!-- /.container-fluid -->
</nav>
<!-- Modal -->
<div id="myModal" class="modal fade" role="dialog">
<div class="modal-dialog">
<!-- Modal content-->
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal">×</button>
<h4 class="modal-title">Upload Media</h4>
</div>
<div class="modal-body">
<form id="upload_form" enctype="multipart/form-data" action="" method="post">
{% csrf_token %}
{{ upload_form }}
<input type="submit" id="upload_submit" style="margin-top: 10px" class="btn btn-default" value="Upload" />
</form>
<script>
$("#upload_form").uploadprogress({redirect_url: "/"})
</script>
</div>
<div class="modal-footer">
<button type="submit" class="btn btn-default" data-dismiss="modal">Close</button>
</div>
</div>
</div>
</div>
<div class="container-fluid">
<div class="jumbotron" id="file_system_jumbo"></div>
</div>
答案 0 :(得分:1)
private JTextField txtEnterText;
您未在txtEnterText
中设置任何文字,这就是您的JTextField
为空的原因。您需要在JTextField
txtEnterText
。
示例:
txtEnterText.setText("SOME TEXT");
答案 1 :(得分:1)
但是当我尝试运行程序
时,我没有得到任何输出
String EnterNumber = txtDisplay.getText() + btn0.getText();
txtDisplay.setText(EnterNumber);
根据上面的代码,您尝试将文本添加到JTextArea,但是您永远不会将JTextArea添加到框架中,因此您永远不会看到输出。
因此,解决方案似乎是将文本区域添加到框架中,并删除您从未使用过的文本字段。
上述代码的其他问题:
变量名称不应以大写字母开头。你的大多数变量是正确的。保持一致!!!
要将文字添加到文字区域,您只需使用append(...)
方法即可。
类似的东西:
txtDisplay.append(enterNumber);
答案 2 :(得分:0)
你不是txtDisplay
,对吧?你在每个事件处理程序中都是txtEnterText
。运行它并查看正确显示的数字。