我试图在输入中找到环境变量并用值替换它们.
env变量的模式是 ${\\.}
Pattern myPattern = Pattern.compile( "(${\\.})" );
String line ="${env1}sojods${env2}${env3}";
Run Code Online (Sandbox Code Playgroud)
我怎么能代替env1用1和env2用2和env3用3,所以在此之后我将有一个新的字符串1sojods23?
有没有办法改变在行布局中创建的元素的顺序,我想在首先显示的元素中显示它.例如,如果我创建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)
提前致谢.
我有以下带有许多属性的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)