小编use*_*079的帖子

java正则表达式查找和替换

我试图在输入中找到环境变量并用值替换它们.

env变量的模式是 ${\\.}

Pattern myPattern = Pattern.compile( "(${\\.})" );
String line ="${env1}sojods${env2}${env3}";
Run Code Online (Sandbox Code Playgroud)

我怎么能代替env11env22env33,所以在此之后我将有一个新的字符串1sojods23

java regex

10
推荐指数
5
解决办法
4万
查看次数

在RowLayout SWT Java中更改元素的顺序

有没有办法改变在行布局中创建的元素的顺序,我想在首先显示的元素中显示它.例如,如果我创建element1,那么element2 element3,element4

我想将布局视为element4 element3 element2 element1

这意味着最后创建的元素将是将在shell中显示的第一个元素.

有没有简单的方法来处理行布局并执行它.

我想更改以下示例以显示Button99 Button98 Button97 Button96 Button95 Button94 ....................................

import org.eclipse.swt.SWT;
import org.eclipse.swt.layout.RowLayout;
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Shell;

public class TestExample
{
    public static void main(String[] args)
    {
        Display display = Display.getDefault();
        Shell shell = new Shell(display);
        RowLayout rowLayout = new RowLayout();

        shell.setLayout(rowLayout);

        for (int i=0;i<100;i++)
        {
            Button b1 = new Button(shell, SWT.PUSH);
            b1.setText("Button"+i);

        }
        shell.open();
        while (!display.isDisposed())
        {
            if (!display.readAndDispatch())
            {
                display.sleep();
            }
        }
    }
}
Run Code Online (Sandbox Code Playgroud)

提前致谢.

java swt

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

在Jaxb中获取元素的Dynamic属性

我有以下带有许多属性的XML标记.没有给出属性的数量/名称,因为我在运行时获取XML,而我只知道标记的名称.如何使用JAXB将所有属性作为一个Map<String, String>

如何将其添加到以下Java代码中:

import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlAttribute;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;

@XmlRootElement(name = "script ")
@XmlAccessorType(javax.xml.bind.annotation.XmlAccessType.FIELD)
public class SearchScriptElement
{

    @XmlAttribute(name = "script")
    private String script = "";

    public String getScript()
    {
        return name;
    }

    public void setScript(String name)
    {
        this.name = name;
    }
}
Run Code Online (Sandbox Code Playgroud)

XML示例:我可以拥有许多在运行时未知的属性:

<ScriptList>
    <script name="xxx" value="sss" id=100 >
    <script>
    <script name="xxx" value="sss" id=100 alias="sss">
    <script>
</ScriptList>
Run Code Online (Sandbox Code Playgroud)

java jaxb

5
推荐指数
2
解决办法
3086
查看次数

标签 统计

java ×3

jaxb ×1

regex ×1

swt ×1