问题列表 - 第21412页

java,程序不会停止 scan.nextLine()

当我运行以下代码时,它停止让我输入服务器名和端口号,之后它应该停止并让我输入用户名,但它从不暂停 scan.nextline() 并直接输入接收者名称?

public static void main(String[] args) throws IOException {
    try {
        System.out.println("\n\n\nTCP Chat Client\n\nEnter server name:");
        Scanner scan = new Scanner(System.in);

        //get server info from user
        serverName = scan.nextLine();

        System.out.println("\nEnter port number:");
        serverPort = scan.nextInt();


        System.out.println("Enter your username:\n");
        userName = scan.nextLine();

        //make connection to server
        cSocket = new Socket(serverName, serverPort);
        out = new PrintWriter(cSocket.getOutputStream(), true);
        in = new BufferedReader(new InputStreamReader(cSocket.getInputStream()));

        //send username to server
        out.println(userName);
        String rcvrname="wefwef";
        String message=null;
        //start messaging
        while(!(rcvrname.equals("exit"))){
            System.out.println("Enter reciever name");
            out.println(scan.nextLine());
            System.out.println("Enter message"); …
Run Code Online (Sandbox Code Playgroud)

java

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

Javascript - 获取所有表 - > tr> id值

我想访问表tr id字段的所有值.

<table>
<tr id="1"></tr>
<tr id="2"></tr>
<tr id="3"></tr>
<tr id="4"></tr>
<tr id="5"></tr>
</table>
Run Code Online (Sandbox Code Playgroud)

我想要做的是,使用一个javascript函数,获取一个数组,并获得访问权限

[1,2,3,4,5]
Run Code Online (Sandbox Code Playgroud)

非常感谢你!

javascript dom

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

让div表现得像一张桌子

所以我真的试图独占使用div,而不是使用表格进行布局,但我仍然被困在这里和那里.今天我有其中一个案例.

考虑以下标记:

<div style="width:943px;margin:0px auto;height:auto">
    <div style="display:block;clear:both">
        <div style="float:left;display:block-inline;clear:none;background:url(tl.png);width:26px;height:25px"></div>
        <div style="float:left;display:block-inline;clear:none;background:url(t.png) repeat-x;width:865px;height:25px"></div>
        <div style="float:left;display:block-inline;clear:none;background:url(tr.png);width:26px;height:25px"></div>
    </div>
    <div style="height:auto;display:block;clear:both">
        <div style="float:left;width:26px;display:block-inline;clear:none;background:url(l.png) repeat-y;width:26px;height:100%"></div>
        <div style="padding:0 15px;height:100%;float:left;width:835px;display:block-inline;background:#FFF;clear:none;">
            <br />
            Some text heeere.
            <br />
            Some more text heeere.
        </div>
        <div style="float:left;width:26px;display:block-inline;clear:none;background:url(r.png) repeat-y;width:26px;height:100%"></div>
    </div>
    <div style="display:block;clear:both">
        <div style="float:left;display:block-inline;clear:none;background:url(bl.png);width:26px;height:25px"></div>
        <div style="float:left;display:block-inline;clear:none;background:url(b.png) repeat-x;width:865px;height:25px"></div>
        <div style="float:left;display:block-inline;clear:none;background:url(br.png);width:26px;height:25px"></div>
    </div>
</div>
Run Code Online (Sandbox Code Playgroud)

现在这就是它的作用:

替代文字http://img97.imageshack.us/img97/4281/screenshot20100215at935.png

请注意,它略高于页面高度.

这就是我想要它做的事情:

替代文字http://img714.imageshack.us/img714/8504/screenshot20100215at936.png

我希望它在不指定高度的情况下流畅地"适应"文本.似乎问题在于除非您将高度指定为100%,否则两个侧面div将无法工作.有没有其他/更简单的方法来做到这一点?

谢谢!

html css xhtml

3
推荐指数
1
解决办法
8994
查看次数

我需要在javascript中阅读rdf

我需要在javascript中紧急阅读rdf文件

javascript rdf

0
推荐指数
1
解决办法
1380
查看次数

使用JQuery scrollTo/localScroll进行负定位

我正在研究一个项目并使用Ariel Flesler的jquery.scrollTo.js和jquery.localScroll.js ...我有本地链接滚动到页面上的各种div.

我遇到的麻烦是我在页面顶部有一个固定位置的导航栏,而ScrollTo正在计算窗口位置(正确)而没有考虑到它.下面是scrollTo.js文件...有人可以告诉我在哪里以及如何我会插入会导致Y轴滚动位置为+ [Y] px的代码?

/**
 * jQuery.ScrollTo - Easy element scrolling using jQuery.
 * Copyright (c) 2007-2009 Ariel Flesler - aflesler(at)gmail(dot)com | http://flesler.blogspot.com
 * Dual licensed under MIT and GPL.
 * Date: 3/9/2009
 * @author Ariel Flesler
 * @version 1.4.1
 *
 * http://flesler.blogspot.com/2007/10/jqueryscrollto.html
 */
;(function($){var m=$.scrollTo=function(b,h,f){$(window).scrollTo(b,h,f)};m.defaults={axis:'xy',duration:parseFloat($.fn.jquery)>=1.3?0:1};m.window=function(b){return $(window).scrollable()};$.fn.scrollable=function(){return this.map(function(){var b=this,h=!b.nodeName||$.inArray(b.nodeName.toLowerCase(),['iframe','#document','html','body'])!=-1;if(!h)return b;var f=(b.contentWindow||b).document||b.ownerDocument||b;return $.browser.safari||f.compatMode=='BackCompat'?f.body:f.documentElement})};$.fn.scrollTo=function(l,j,a){if(typeof j=='object'){a=j;j=0}if(typeof a=='function')a={onAfter:a};if(l=='max')l=9e9;a=$.extend({},m.defaults,a);j=j||a.speed||a.duration;a.queue=a.queue&&a.axis.length>1;if(a.queue)j/=2;a.offset=n(a.offset);a.over=n(a.over);return this.scrollable().each(function(){var k=this,o=$(k),d=l,p,g={},q=o.is('html,body');switch(typeof d){case'number':case'string':if(/^([+-]=)?\d+(\.\d+)?(px)?$/.test(d)){d=n(d);break}d=$(d,this);case'object':if(d.is||d.style)p=(d=$(d)).offset()}$.each(a.axis.split(''),function(b,h){var f=h=='x'?'Left':'Top',i=f.toLowerCase(),c='scroll'+f,r=k[c],s=h=='x'?'Width':'Height';if(p){g[c]=p[i]+(q?0:r-o.offset()[i]);if(a.margin){g[c]-=parseInt(d.css('margin'+f))||0;g[c]-=parseInt(d.css('border'+f+'Width'))||0}g[c]+=a.offset[i]||0;if(a.over[i])g[c]+=d[s.toLowerCase()]()*a.over[i]}else g[c]=d[i];if(/^\d+$/.test(g[c]))g[c]=g[c]<=0?0:Math.min(g[c],u(s));if(!b&&a.queue){if(r!=g[c])t(a.onAfterFirst);delete g[c]}});t(a.onAfter);function t(b){o.animate(g,j,a.easing,b&&function(){b.call(this,l,a)})};function u(b){var h='scroll'+b;if(!q)return k[h];var f='client'+b,i=k.ownerDocument.documentElement,c=k.ownerDocument.body;return Math.max(i[h],c[h])-Math.min(i[f],c[f])}}).end()};function n(b){return typeof b=='object'?b:{top:b,left:b}}})(jQuery);

/**
     * jQuery.LocalScroll - Animated scrolling navigation, using anchors. …
Run Code Online (Sandbox Code Playgroud)

javascript jquery plugins local scrollto

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

Silverlight:共享相同样式文件的多个项目

我有多个silverlight项目,我想使用相同的样式,配色方案和一些模板化对象.

我该如何做到这一点?

silverlight

6
推荐指数
1
解决办法
2781
查看次数

JQuery的好散点图插件(包括样本图片)?

我正在为JQuery寻找一个可靠的图形插件,它可以为我提供一个在我的网站上使用的有吸引力的散点图.我真的不需要很多花哨的功能 - 只是能够根据我给出的X轴和Y轴值在图表上绘制点.

我唯一有点特殊的要求是点有能力成为不同的颜色.除了在X轴上跟踪项目的"状态",以及在Y轴上的"输入时间",我想用它的实际颜色代表它的"状态"(不要与"状态"混淆)点.顺便提一下,有5个州和5个州.

我在快速谷歌搜索中发现了一些很有前途的,但没有看到指定点的颜色的能力(我找到了一个让我改变大小的能力).任何人的任何建议将不胜感激.

下面是我想要的,但我认为点将在5个不同的列(基于5个州)中更清晰地排列.但它可能有助于可视化.

alt text http://i50.tinypic.com/14jrwv7.jpg

谢谢.

jquery plugins graph scatter-plot

6
推荐指数
1
解决办法
4744
查看次数

eclim(eclipse + vim)自动完成

当我在无头模式下使用eclim的自动完成功能时,它会打开常规的自动完成小窗口,但也会打开一个单独的临时预览窗口来显示重载的功能.我怎么能不让刮刮窗出现?(就像在小自动完成窗口中拥有所有内容一样)

java eclim

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

Rails日志文件中的输出行号

从调试的Rails指南,我发现我可以使用这个简单的方法自定义输出到我的日志文件:

logger.debug "Person attributes hash: #{@person.attributes.inspect}"
Run Code Online (Sandbox Code Playgroud)

我决定使用它来跟踪变量如何变化并通过流量控制.

我希望能够看到logger#debug调用方法的代码的行号.像这样的东西:

logger.debug "Person attributes hash: #{@person.attributes.inspect} from line #{LINE_NUMBER_VAR}"
Run Code Online (Sandbox Code Playgroud)

debugging ruby-on-rails line-numbers

6
推荐指数
2
解决办法
3364
查看次数

在双缓冲多线程系统中执行指针交换

当双缓冲由于在线程之间共享的数据时,我使用了一个系统,其中一个线程从一个缓冲区读取,一个线程从另一个缓冲区读取并从第一个缓冲区读取.麻烦的是,我将如何实现指针交换?我需要使用关键部分吗?没有可用的互锁功能实际交换值.我不能从缓冲区1读取一个线程,然后从缓冲区2开始读取,在读取过程中,这将是appcrash,即使其他线程没有开始写入它.

我在Visual Studio Ultimate 2010 RC中使用Windows上的本机C++.

c++ multithreading doublebuffered

6
推荐指数
2
解决办法
3875
查看次数