小编Tra*_*Can的帖子

Eclipse无法创建可运行的jar - 没有选择资源

当我尝试将项目导出为可运行的jar时,Eclise给出了以下错误:

没有选择资源.

该项目在Eclipse中运行良好,我已经尝试在导出之前清理项目,但是没有用.

有想法该怎么解决这个吗.

java eclipse executable-jar

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

在Java DOM文档中设置名称空间和前缀

我正在尝试将ResultSet转换为XML文件.我首先使用这个例子进行序列化.

import  org.w3c.dom.bootstrap.DOMImplementationRegistry;
import  org.w3c.dom.Document;
import  org.w3c.dom.ls.DOMImplementationLS;
import  org.w3c.dom.ls.LSSerializer;

...

DOMImplementationRegistry registry = DOMImplementationRegistry.newInstance();

DOMImplementationLS impl = 
    (DOMImplementationLS)registry.getDOMImplementation("LS");

...     

LSSerializer writer = impl.createLSSerializer();
String str = writer.writeToString(document);
Run Code Online (Sandbox Code Playgroud)

在我完成这项工作后,我尝试验证我的XML文件,有几个警告.一个关于没有doctype的人.所以我尝试了另一种方法来实现它.我遇到了Transformer课程.这个类让我设置编码,doctype等.

以前的实现支持自动命名空间修复.以下不是.

private static Document toDocument(ResultSet rs) throws Exception {   
    DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
    factory.setNamespaceAware(true);
    DocumentBuilder builder = factory.newDocumentBuilder();
    Document doc = builder.newDocument();

    URL namespaceURL = new URL("http://www.w3.org/2001/XMLSchema-instance");
    String namespace = "xmlns:xsi="+namespaceURL.toString();

    Element messages = doc.createElementNS(namespace, "messages");
    doc.appendChild(messages);

    ResultSetMetaData rsmd = rs.getMetaData();
    int colCount = rsmd.getColumnCount();

    String attributeValue = "true";
    String attribute = …
Run Code Online (Sandbox Code Playgroud)

java xml serialization transformer-model

12
推荐指数
3
解决办法
6万
查看次数

使用FlowLayout时,JTextField显示为切口...请解释

有人可以向我解释一下,为什么每次我使用FlowLayout布局管理器时,我的文本字段都显示为切口.

一段时间以来,我已经突然反对这个问题了,我似乎无法弄清楚为什么会出错.

我觉得这是一件很简单的事情,我一次又一次地忽略了,所以如果有人愿意向我解释这个现象,我将永远感激不尽.

import java.awt.Container;
import java.awt.FlowLayout;

import javax.swing.JFrame;
import javax.swing.JTextField;

public class Console
{   
    public Console()
    {
        makeConsole();
    }

    private void makeConsole()
    {
        JFrame console = new JFrame("ArchiveConsole");
        Container base  = console.getContentPane();
        base.setSize(400, 250);
        console.setSize(base.getSize());
        base.setLayout(new FlowLayout(FlowLayout.CENTER, 5,5));

        JTextField tf = new JTextField();
        tf.setSize(base.getWidth(), 25);
        base.add(tf);

        console.setVisible(true);
    }
}
Run Code Online (Sandbox Code Playgroud)

java swing jtextfield flowlayout

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