小编Kyl*_*leM的帖子

使用多个标题下拉(组合框)

是否有任何小部件或代码可以使用HTML/CSS/JQuery创建一个可以有多个标题的下拉框(HTML选择标记)?标题不应该是可选的.例如,请参见此图片中的"苹果"下拉框: 苹果组组合框

不幸的是,很难找到这样的东西.我觉得我正在重新设计以前做过的东西,但我无法在任何地方找到它.无论如何,如果没有人能找到它我将自己创建它.关于如何创建它的任何想法都是受欢迎的,但我确信它将涉及div,Jquery显示/隐藏,以及CSS用于边框/项目.

html css jquery

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

Lambda与BackgroundWorker

为什么以下语法有效?

BackgroundWorker bw = new BackgroundWorker();
String one = resultFromSomeMethod();
String two = resultFromOtherMethod();
String three = resultFromThirdMethod();
bw.DoWork += (a,b) => TestMethod(one, two, three);
Run Code Online (Sandbox Code Playgroud)

其中TestMethod定义为:

private void TestMethod(String one, String two, String three){
   //Do Stuff!!
}
Run Code Online (Sandbox Code Playgroud)

DoWorkEventHandler被定义为一个带有两个参数的委托:object sender和EventArgs e.但是,上面的TestMethod没有这样的参数.通过我对委托的理解,要创建一个新的委托,该方法必须符合委托的声明.我似乎通过使用lambda绕过了这个限制.上面的语法如何以及为什么工作,即使我尝试创建new DoWorkEventHandler(TestMethod)它肯定不会工作?

我阅读了Eric White 关于Lambda Expressions 的博客,但它似乎没有回答这个问题.

c# lambda

3
推荐指数
4
解决办法
1310
查看次数

spring security中使用自定义方法安全注解

我想用自定义注释标记类中的方法,该注释将使用 spring 安全性控制授权决策。例如:

@Role("ADMIN")
public void accessControlledMethod(){}
Run Code Online (Sandbox Code Playgroud)

我了解这意味着我需要以某种方式注册我的自定义注释“角色”,以便在ConfigAttributes授权决定做出时它可以出现AccessDecisionManager. 但是,我不明白如何使用 spring security 注册我的自定义注释以便它被识别。

我在框架代码中看到了一种潜在的解决方案。有一个名为 SecuredAnnotationSecurityMetadataSource 的类,其文档说“为自定义注释注入 AnnotationMetadataExtractor”。如果这是首选方法,我不确定如何配置 SecuredAnnotationSecurityMetadataSource 或如何将 AnnotationMetadataExtractor 注入其中。

java spring annotations spring-security

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

具有固定高度和可变宽度JButton的布局

我寻找一个具有固定高度JButtons的LayoutManager,它在宽度上扩展以适应其Container的大小.在JButton上面,应该有一个JLabel本身在"选择文件:"的行上.这旨在作为JFileChooser的附件,让用户选择最近的文件.我无法让它看起来很正确,我尝试过使用多个JPanel和LayoutManagers,比如BoxLayout.当使用BoxLayout时,JButton只会扩展到包含文本的范围; 但我希望所有的JButton都具有相同的宽度,所以它们看起来并不好笑.

注意:我还使用了其他LayoutManagers,例如Border和GridLayout,但那些大多数都忽略了我的大小设置,并且看起来不够复杂.我必须手动执行此操作,Netbeans等不是一种选择.

工作示例,但视觉上不正确

import java.awt.Color;
import java.awt.GridLayout;

import javax.swing.JButton;
import javax.swing.JFileChooser;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;


public class Chooser extends JPanel {


    public Chooser(){
        this.setLayout(new GridLayout(0,1));

        JPanel labelPanel = new JPanel();
        JLabel label = new JLabel("Choose a file:");
        labelPanel.add(label);
        labelPanel.setBackground(Color.red);

        JPanel buttonPanel = new JPanel();
        buttonPanel.add(new JButton("long pathname to a file goes here"));
        buttonPanel.setBackground(Color.blue);

        this.add(labelPanel);
        this.add(buttonPanel);
    }


    /**
     * @param args
     */
    public static void main(String[] args) {
        // TODO Auto-generated method stub
        Chooser c = new Chooser(); …
Run Code Online (Sandbox Code Playgroud)

java swing layout-manager

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

使用DefaultListCellRenderer设置JList图标?

下面的代码应该从JFileChooser获取默认目录图标,然后在我自定义的"Recent Directories"列表中使用该图标,该列表作为JFileChooser对话框的附件提供.有人可以解释为什么下面的代码不起作用(特别是为什么在DefaultListRenderer上的setIcon没有做到这一点),并告诉我如何将图标放在JList中的每个项目旁边?我宁愿避免实现我自己的ListCellRenderer,除非这是使其工作的唯一方法.

import java.awt.*;
import java.io.File;

import javax.swing.*;
import javax.swing.border.EmptyBorder;
import javax.swing.event.ListSelectionEvent;
import javax.swing.event.ListSelectionListener;

public class Chooser extends JPanel {
   private static final String[] BUTTON_TEXTS = { "Hello", "Goodbye",
         "Hello Goodbye", "Adios", "This is a long String for WTF", "Hello",
         "Goodbye", "Hello Goodbye", "Adios", "This string WTF" };

   public Chooser(Icon icon) {
      this.setLayout(new BorderLayout());

      JPanel labelPanel = new JPanel(new BorderLayout());
      JLabel label = new JLabel("Recent Directories:");
      labelPanel.add(label, BorderLayout.LINE_START);
      labelPanel.setBackground(Color.LIGHT_GRAY);
      labelPanel.setBorder(new EmptyBorder(5, 10, 5, 0));

      DefaultListModel model = new DefaultListModel();
      JList …
Run Code Online (Sandbox Code Playgroud)

java swing jfilechooser

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

带有列表的Restrictions.eq

我有一个名为Product的课程.每个产品都有一个serial_number.我想返回列表中包含serial_number的所有产品.就像是

Restrictions.eq("serial_number", mySerialNumberList);
Run Code Online (Sandbox Code Playgroud)

这可以简洁地完成,还是我必须构建一个包含大量"OR"属性的巨大查询?

hibernate criteria

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

WOW64 - 从Visual Studio中运行powershell

有人可以解释一下,为什么有必要经历这么多箍以便从visual studio运行PowerShell(作为外部命令)?我知道这与差异有关,但不明白为什么.如果我没记错的话,上下文是64位Windows 7操作系统,32位Visual Studio和System32文件夹中的32位PowerShell.64位操作系统可以毫无问题地运行32/64应用程序,所以这里有什么问题,为什么?

通过互联网搜索我相信这与WOW64有关,因此标签,但我不太确定.我知道操作系统模拟旧的32位软件,但我不明白为什么VS无法运行命令来启动powershell而不经历箍,例如添加'... Native ...'文件夹(即.到我们的教练实际上并不存在).

希望不要混淆.

wow64 visual-studio-2010

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

C#字节数组和C++字节数组之间的元素

我有一个C#array<System::Byte>,我希望将其转换为C++ byte*.我怎样才能做到这一点?我正在使用C++/CLR,因为它允许我在同一个项目中使用托管/非托管代码.我基本上是在编写一个DLL并制作一些可以通过C#调用的方法,但它包含非托管C++代码.

所以基本上,我的C++/CLR方法标题是这样的:

void testMethod(array<Byte>^ bytesFromCSharp);
Run Code Online (Sandbox Code Playgroud)

在其中testMethod我想将其转换bytesFromCSharpbyte*可供其他非托管C++代码使用的内容.我对byte*数组进行了malloced 并编写了一个for循环来逐字节复制,但感觉应该有一个更好的解决方案.

编辑:Hans的技术示例来自他的回答:

//C#
byte[] myBytes = {1,2,3,4};

//C++/CLI
void testMethod(array<byte>^ myBytes) {
    pin_ptr<byte> thePtr = &myBytes[0];
    byte* bPtr = thePtr;
    nativeCode(bPtr);
    ...
}
Run Code Online (Sandbox Code Playgroud)

c# c++-cli

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

根据 ReactJS 中的变量有条件地设置复选框状态

class Example extends React.Component {
  constructor() {
    super();
    this.isChecked = this.isChecked.bind(this);
  }

  isChecked(ex){
    return this.props.defaults && $.inArray(ex, this.props.defaults);
  }

  render() {
    return (
      <div className="example">
        {this.props.items.map(item => (
          var checked = this.isChecked({item.type});

          <span key={item.type}>
            <input type="checkbox" {checked ? 'checked' : ''} name="example" value={item.type} id={item.type} />
            <label htmlFor={item.type}>{item.display}</label>
          </span>
        ))}
      </div>
    );
  }
}
Run Code Online (Sandbox Code Playgroud)

在上面的例子中,我已经向组件传递了一个项目this.props.items列表和一个 defaults 列表this.props.defaults。对于每个项目,如果该项目在默认列表中,我希望它的状态为checked. 保持整体设计不变,我该怎么做?(注意:我意识到我可以重新设计应用程序以避免在地图内声明变量的问题。这不是问题)。

上面的代码不起作用(显然),我只是想让每个人都了解我在这里尝试的内容。如果您运行它,则会在声明“var”的地方出现“意外令牌”之类的错误。

reactjs

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