JAVAFX - 创建一个新窗口

时间:2017-09-19 12:28:40

标签: java javafx

我想创建一个从按钮激活的新窗口,但是当这个新窗口打开时,主窗口无法使用。

2 个答案:

答案 0 :(得分:0)

制作新 #vote_form.html <form action="{% url 'add_vote' suggestion.id %}" method="post"> {% csrf_token %} <input type="submit" value="I want to vote"> </form> #urls.py urlpatterns = [ url(r'^suggestion/(?P<pk>\d+)/$', views.SuggestionDetail.as_view(), name="suggestion_detail"), url(r'^suggestion/(?P<pk>\d+)/vote/$', views.add_vote, name='add_vote'), ] #models.py class Vote(models.Model): suggestion = models.ForeignKey(Suggestion) voter = models.ForeignKey('auth.User') vote_count = models.BooleanField() #views.py def add_vote(request, pk): suggestion = get_object_or_404(Suggestion, pk=pk) vote = Vote( suggestion = suggestion, voter = request.user, vote_count = True) has_user_voted = Vote.objects.filter(voter=request.user, suggestion=suggestion).count() if has_user_voted < 1: vote.save() else: messages.error(request, 'It seems you have already voted, only one vote is allowed') return HttpResponseRedirect(reverse('suggestion_detail', args=(suggestion.id,))) 时,必须将其他窗口设为所有者,然后将其设置为窗口模式。

Stage newStage

答案 1 :(得分:0)

创建新舞台并向其添加所需对象时添加:

    newStage.initModality(Modality.APPLICATION_MODAL);
    newStage.showAndWait();