当我尝试安装mysql2 gem时,它失败并没有明显的错误.有谁知道如何解决这个问题,所以mysql2安装?
$ sudo gem install mysql2
Building native extensions. This could take a while...
ERROR: Error installing mysql2:
ERROR: Failed to build gem native extension.
/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/bin/ruby extconf.rb
checking for rb_thread_blocking_region()... no
checking for mysql_query() in -lmysqlclient... no
checking for main() in -lm... yes
checking for mysql_query() in -lmysqlclient... no
checking for main() in -lz... yes
checking for mysql_query() in -lmysqlclient... no
checking for main() in -lsocket... no
checking for mysql_query() in -lmysqlclient... no
checking for main() in -lnsl... no …
Run Code Online (Sandbox Code Playgroud) Ruby新手在这里试图弄清楚如何使用宝石,到目前为止,体验并不是那么好.
通过gem安装mysql2之后我尝试在一个简单的文件中使用它.
require 'mysql2' #client = Mysql2::Client.new(:host => "localhost", :username => "username")
虽然当我运行这个时,我得到:
Parse.rb:1:in `require': no such file to load -- mysql2 (LoadError) from Parse.rb:1
然而我的宝石列表包含mysql2:
Tanner-Smiths-MacBook-Pro:Humans_vs_Zombies_Parse tanner$ gem list *** LOCAL GEMS *** abstract (1.0.0) actionmailer (3.0.1, 2.3.5, 1.3.6) actionpack (3.0.1, 2.3.5, 1.13.6) actionwebservice (1.2.6) activemodel (3.0.1) activerecord (3.0.1, 2.3.5, 1.15.6) activeresource (3.0.1, 2.3.5) activesupport (3.0.1, 2.3.5, 1.4.4) acts_as_ferret (0.4.3) arel (2.0.2) builder (2.1.2) capistrano (2.5.19, 2.5.2) cgi_multipart_eof_fix (2.5.0) daemons (1.1.0, 1.0.10) dnssd (1.4, 0.6.0) erubis (2.6.6) fastthread (1.0.7, …
我有一个通过JPanel中的GridLayout布局的对象数组.我需要能够在数组中的索引中重新创建对象,并使用GridLayout更新来反映这一点.到目前为止,我无法找到"刷新"或重绘GridLayout.是否可以在不创建整个GridLayout或JPanel的情况下刷新GridLayout?假设我无权访问JFrame.
import javax.swing.*;
import java.awt.*;
public class Test
{
public static void main(String args[])
{
JFrame frame = new JFrame();
JPanel panel = new JPanel();
panel.setLayout(new GridLayout(5,5));
JLabel[][] labels = new JLabel[5][5];
for (int i = 0; i < 5; i++)
{
for (int j = 0; j < 5; j++)
{
labels[j][i] = new JLabel("("+j+", "+i+")");
panel.add(labels[j][i]);
}
}
labels[0][0] = new JLabel("Hello World");
//Without doing it this way (cause my objects can't do this)
//labels[0][0].setText("Hello World!");
frame.add(panel);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); …
Run Code Online (Sandbox Code Playgroud)