小编Eri*_*ric的帖子

如何在JFrame中排列多个面板

我正在尝试制作一个简单的计算器来练习图形(我是一个完整的GUI菜鸟).我在使用Polyashenkos校准器和文本区域以及文本区域和按钮之间的空间后有不必要的空间时遇到一些问题.另外,我如何保持这种布局,但消除空间,并使底部3按钮更小.关于我正在做什么或如何做得更好的任何提示将非常感激.谢谢.

在此输入图像描述

import javax.swing.*;
import java.awt.*;

public class calculator {

    public static void main(String[] args) {
        // creates the JFrame(a window with decorations)
        JFrame frame = new JFrame("Calculator"); 
        // stops the program when window is closed
        frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); 
        frame.setSize(377, 350);

        // the main panel of the JFrame, 
        // remembet you cant add content directly to JFrame
        JPanel content = new JPanel(new GridLayout(4, 0)); 
        // panel for the text field
        JPanel textarea = new JPanel(new GridLayout(4, 0)); 
        // panel for the buttons, 
        // …
Run Code Online (Sandbox Code Playgroud)

java swing calculator jpanel layout-manager

7
推荐指数
1
解决办法
2万
查看次数

使用capistrano部署rails应用程序的bitbucket存储库问题

获取githubbitbucket信息库.

无法建立主机'github.com(some_ip_address)'的真实性.

这是我的部署文件.deploy:setup并且deploy:check工作得很好.

require "bundler/capistrano" 
require "rvm/capistrano"

default_run_options[:pty] = true 
ssh_options[:forward_agent] = true

set :repository, 'ssh://git@bitbucket.org/username/repo.git' 
set :scm :git 
set :scm_verbose, true
set :user, 'root'
set :deploy_via, :remote_cache
set :migrate_target, :current
set :branch, 'master'
set :application, 'my_app_name' 
set :domain, 'my_domain_ip_address'
set :applicationdir, "/home/deploy/domains/#{application}"
set :deploy_to, "/home/deploy/domains/#{application}"
role :web, domain role :app, domain role :db,  domain, :primary => true
set :keep_releases, 5
set :rvm_type, :system

after 'deploy:restart', 'deploy:cleanup'

namespace :deploy do   
  task :start …
Run Code Online (Sandbox Code Playgroud)

deployment capistrano ruby-on-rails bitbucket rvm-capistrano

4
推荐指数
1
解决办法
5229
查看次数

嵌套路由和form_for以及NoMethodError

正如下面所述的错误消息,我不使用"user_profiles_path"作为复数,因为我在嵌套资源中定义了"resource:profile".

NoMethodError in Profiles#new
Run Code Online (Sandbox Code Playgroud)

显示/home/smileymike/rails_projects/bffmapp_v2/app/views/profiles/new.html.erb其中线#20提出:

undefined method `user_profiles_path' for #<#<Class:0x90266ac>:0xa041294>
Run Code Online (Sandbox Code Playgroud)

模型:

class User < ActiveRecord::Base
  has_one :profile

class Profile < ActiveRecord::Base
  attr_accessible :name, :surname
  belongs_to :user
Run Code Online (Sandbox Code Playgroud)

routes.rb中:

  resources :users do
    resource :profile  (note: has_one)
  end
Run Code Online (Sandbox Code Playgroud)

查看:profiles/new.html.erb

<div class="row">
  <div class="span6 offset3">
    <%= form_for([@user, @profile]) do |f| %>
      <%= f.label :name %>
      <%= f.text_field :name %>

      <%= f.label :surname %>
      <%= f.text_field :surname %>

      <%= f.submit "Create my profile", class: "btn btn-large btn-primary" %>
    <% end %>
  </div>
</div>
Run Code Online (Sandbox Code Playgroud)

路线

    user_profile …
Run Code Online (Sandbox Code Playgroud)

controller ruby-on-rails form-for nested-resources ruby-on-rails-3

2
推荐指数
1
解决办法
1098
查看次数