问题列表 - 第45052页

jpanel -java内部垂直jbutton

我有一个边框布局,有4个面板,北,南,东,西.例如在东侧我有一个jpanel,它有四个按钮.我的问题是所有按钮都对齐到顶部,我想对齐中心.在css中,例如保证金顶部或顶部:50%.

有任何想法吗?

    JPanel contentor3 = new JPanel();
  contentor.add(contentor3, BorderLayout.EAST);
  contentor3.setBackground(Color.green);
  contentor3.setPreferredSize(new Dimension(120, 750));

  contentor3.add(btn[1]);
  btn[1].setText("btn1");
Run Code Online (Sandbox Code Playgroud)

java swing center jbutton

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

启动方向错误

我是StackOverflow的新手,也是Objective-c的新手.

我已经试着寻找几个星期来找到一些东西给我一些暗示该做什么,但我似乎无法通过这个问题而不问问题.感觉它应该很简单,但......

我在旋转"rootView"控制器时遇到问题.它应该在横向上显示(在我决定使用导航控制器之前它已经完成).模拟器以正确的方向显示,但它已将视图旋转90度向左旋转,因此文本从下到上,侧向读取,因此您必须向左旋转头部.视图的最左侧部分是可见的,但视图的其余部分从屏幕顶部开始.这是一个大型的程序(我发现,一般来说,使用objective-c,但仍然享受它......),但这里是我认为重要的代码区域的要点:

在appDelegate中,我创建了一个窗口,我的rootViewcontroller和navcontroller:

// .h file:
UIWindow *window;
wordHelper3ViewController *viewController;
UINavigationController *navigationController;
Run Code Online (Sandbox Code Playgroud)

然后在实施中:

//.m file
- (BOOL)application:(UIApplication *)applicationdidFinishLaunchingWithOptions:(NSDictionary *)launchOptions {    
    // Hide status bar
    application.statusBarHidden = YES;
        // --- Add the view controller's view to the window and display.
    [window addSubview:viewController.view];
    [window addSubview:navigationController.view];
    [window makeKeyAndVisible];
    return YES;
}
Run Code Online (Sandbox Code Playgroud)

然后我在dealloc中释放所有这些.

在我的根视图中,我这样做:

// Override to allow orientations other than the default portrait orientation.
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
    // Return YES for supported orientations
    if (interfaceOrientation == UIInterfaceOrientationLandscapeRight){
        return YES;
    } else { …
Run Code Online (Sandbox Code Playgroud)

iphone objective-c orientation

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

Rails 3查找星期几

我正在尝试制作自己的日历,因为我似乎无法获得任何事件日历的帮助所以我想要做的是显示星期几,即.. 2011年1月1日星期六有一个简单的命令来获得那天还是我需要别的东西

ruby-on-rails-3

63
推荐指数
3
解决办法
5万
查看次数

使JRuby继承Java代理设置

我想从JRuby上运行的Rails代码发出HTTP请求.

我怎样才能重新使用http.proxyHost,http.proxyPort和http.nonProxyHosts设置,给JVM运行它?

ruby proxy http jruby jrubyonrails

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

组合生成的迭代算法

可能重复:
从n返回k个元素的所有组合的算法

是否有任何迭代算法生成N个数字的组合,一次取'r'?

algorithm

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

与缩进对齐

我的文本必须是正确对齐的,当这个文本占用多行并换行时,新行必须与之后的行区分开,所以我试图让它在右侧缩进,但我找不到有效的解决方案.

我已经尝试了[htmlhelp论坛帖子#8327]和[codingforums线程#58451]的建议,以及两者的组合无济于事(无法发布链接.抱歉.).还有其他方法可以实现吗?

我的尝试:

div.poem li:after
{
 content: " ";
 display: inline-block;
 width: 10px; 
}
Run Code Online (Sandbox Code Playgroud)

有什么,但我不希望它缩进,如果文本只占用一行.

div.poem li::first-line::after
{
 content: "asdf";
}
Run Code Online (Sandbox Code Playgroud)

什么也没做

div.poem li:first-line
{
 color: red;
 margin-right: 200px;
 padding-right: 200px;
}
Run Code Online (Sandbox Code Playgroud)

第一行的文字变为红色(这样我就知道发生了什么)但是边距和填充没有做任何事情.

HTML:

<div class='poem'>
    <ul class='poem'>
        <li>Here's one line of the poem</li>
        <li>This is the second line of the same stanza, which is long and will wrap around</li>
        <li>Part of the line above is now on line 3, and looks like it's supposed to be a line of …
Run Code Online (Sandbox Code Playgroud)

css

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

使用递归块时EXC_BAD_ACCESS

我正在尝试使用块创建递归.它工作了一段时间,但最终它崩溃并给我一个糟糕的访问异常.这是我的代码:

BOOL (^Block)(Square *square, NSMutableArray *processedSquares) = ^(Square *square, NSMutableArray *processedSquares) {
    [processedSquares addObject:square];

    if (square.nuked) {
        return YES; // Found a nuked square, immediately return
    }

    for (Square *adjacentSquare in square.adjacentSquares) {
        if ([processedSquares containsObject:adjacentSquare]) {
            continue; // Prevent infinite recursion
        }

        if (Block(adjacentSquare, processedSquares)) {
            return YES;
        }
    }

    return NO;
};

__block NSMutableArray *processedSquares = [NSMutableArray array];
BOOL foundNukedSquare = Block(square, processedSquares);
Run Code Online (Sandbox Code Playgroud)

说明:我有一个Square具有BOOL 的类nuked.它还有一个adjacentSquares包含其他Squares 的NSArray .

我想检查一个正方形或其中一个"连接"方块是否被核化.

该数组processedSquares是为了跟踪我检查过的方块,以防止无限递归.

当我运行它时,它正在执行此块的大量调用(如预期的那样).但在某些时候,它在最后一行崩溃并出现访问异常. …

iphone recursion cocoa-touch objective-c objective-c-blocks

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

为什么必须调用URLConnection#getInputStream才能写出URLConnection#getOutputStream?

我试着写出URLConnection#getOutputStream,然而,在我打电话之前,实际上没有数据被发送URLConnection#getInputStream.即使我设置URLConnnection#doInput为false,它仍然不会发送.有人知道为什么吗?API文档中没有任何内容可以描述这一点.

URLConnection上的Java API文档:http://download.oracle.com/javase/6/docs/api/java/net/URLConnection.html

Java的读取和编写URLConnection的教程:http://download.oracle.com/javase/tutorial/networking/urls/readingWriting.html

import java.io.IOException;
import java.io.OutputStreamWriter;
import java.net.URL;
import java.net.URLConnection;

public class UrlConnectionTest {

    private static final String TEST_URL = "http://localhost:3000/test/hitme";

    public static void main(String[] args) throws IOException  {

        URLConnection urlCon = null;
        URL url = null;
        OutputStreamWriter osw = null;

        try {
            url = new URL(TEST_URL);
            urlCon = url.openConnection();
            urlCon.setDoOutput(true);
            urlCon.setRequestProperty("Content-Type", "text/plain");            

            ////////////////////////////////////////
            // SETTING THIS TO FALSE DOES NOTHING //
            ////////////////////////////////////////
            // urlCon.setDoInput(false);

            osw …
Run Code Online (Sandbox Code Playgroud)

java httpurlconnection

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

iphone - 用于后退按钮的自定义UIBarButtonItem

我想在导航栏中使用自定义项目作为后退按钮.

UIImage *backButtonImage = [UIImage imageNamed:@"backbutton.png"];
UIBarButtonItem *customItem = [[UIBarButtonItem alloc] initWithImage:backButtonImage style:UIBarButtonItemStylePlain target:nil action:nil];
[self.navigationItem setBackBarButtonItem: customItem];
[customItem release];
Run Code Online (Sandbox Code Playgroud)

我最终得到的是我周围有边框的图像.它看起来像这样(我的图像是后退按钮):

返回键

我该怎样摆脱边界?我究竟做错了什么?

iphone uibarbuttonitem uinavigationitem

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

RenderSection()内部部分与母版页

我有一个部分"边栏"添加到母版页(布局)和我正在使用的部分内部:

@RenderSection("SearchList", required: false)
Run Code Online (Sandbox Code Playgroud)

在其中一个使用我正在做的母版页的视图中:

@section SearchList {
    // bunch of html
}
Run Code Online (Sandbox Code Playgroud)

但它给了我错误:

无法直接请求文件"〜/ Views/Shared/_SideBar.cshtml",因为它调用"IsSectionDefined"方法.

这有什么不对?

c# asp.net-mvc razor

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