小编Dee*_*pak的帖子

java中属性文件的路径

我有一个属性文件,它在一个默认包中,我使用属性文件的类也在同一个默认包中.如果我只使用文件名而没有任何路径我会收到错误.显然这是不正确的,因为我应该给某种路径来引用tat文件.我将构建应用程序使其成为一个jar文件,所以我应该如何给出路径,因为属性文件应该进入该jar文件.我正在使用Netbeans IDE.

编辑

 Properties pro = new Properties();

    try {            
        pro.load(new FileInputStream("pos_config.properties"));
        pro.setProperty("pos_id", "2");
        pro.setProperty("shop_type", "2");
        pro.store(new FileOutputStream("pos_config.properties"), null);
        String pos_id = pro.getProperty("pos_id");
        if(pos_id.equals("")){
           pos_id="0" ;
        }
        global_variables.station_id = Integer.parseInt(pos_id);
        String shop_type = pro.getProperty("shop_type");
        if(shop_type.equals("")){
           shop_type="0" ;
        }
        global_variables.shop_type = Integer.parseInt(shop_type);
    } catch (IOException ex) {
        Logger.getLogger(Main.class.getName()).log(Level.SEVERE, null, ex);
    }
Run Code Online (Sandbox Code Playgroud)

java resources jar properties

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

Java Swing按钮颜色

我正在使用NET Beans IDE在LINUX中开发我的应用程序.我使用synthetica包来产生新的外观和感觉.一直都很好.

现在我的下一个阶段是在某些数据库状态发生变化时为按钮添加颜色.

例如:

在一家餐馆,我有2张桌子,当有8个人进来用餐时,我将在我的软件中创建2个桌子,因为人们无人看管我希望这两个桌子的按钮是绿色的.处理任何这些表的订单时,处理表的按钮颜色应更改为橙色.处理时,它应该是闪烁的颜色.如何在java中执行此操作?我将负责数据库更新我只想知道如何更改按钮的颜色和添加闪烁技术.

java swing netbeans

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

用于Java桌面应用程序的框架

我不熟悉java的任何主要框架,但我仍然设法开发桌面应用程序.这些天人们都在谈论spring,strut,hibernate等.我想知道那里有多少种类的框架,以及哪些框架通常用于开发涉及数据库的桌面应用程序.

您认为哪些是桌面应用程序开发人员必须学习的.提前致谢..

java desktop-application jsr296

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

Java Swing在运行时添加/删除jButtons

我的应用程序有一个模块,允许用户在运行时在jLayeredpane上添加jButton.我想为这个动态添加的内容添加动作侦听器,并且还必须提供在运行时删除动态添加的按钮的访问权限.有没有办法做到这一点?

private Map<String, JButton> dynamicButtons;

public void addButton(String name) {
    JButton b = new JButton(name);
    b.addActionListener(new java.awt.event.ActionListener() {

        public void actionPerformed(java.awt.event.ActionEvent evt) {
            jButton1ActionPerformed(evt);
        }
    });

    jLayeredPane2.add(b);
    dynamicButtons.put(name, b);
    jLayeredPane2.invalidate();
}

public void removeButton(String name) {
    JButton b = dynamicButtons.remove(name);
    jLayeredPane2.remove(b);
    jLayeredPane2.invalidate();
}
Run Code Online (Sandbox Code Playgroud)

java swing components

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

从数据库填充JTree

我有一个包含字段category_id,category_name和parent_category_id的表.parent_category_id具有来自category_id的值,表示父子关系.我没有任何固定级别的层次结构,它可能达到5级或10级并且没有限制.我需要一个代码来实现这个JTree以使事情对我有用.我也应该能够为菜单栏实现相同的功能..请帮我这个..

谷歌搜索后我发现了这个,

Map<String, Node> idToNode = new HashMap<String, Node>();   

//create nodes from ResultSet   
while ( resultSet.next() ){       
    Node node = //create node -contains info, parent id, and its own id from ResultSet
    //put node into idToNode, keyed with its id   
}   

//link together   
Iterator<String> it = idToNode.keySet().iterator();   
Node root = null;   
while ( it.hasNext() ){          
    Node node = idToNode.get(it.next());       
    Node parent = idToNode.get(node.getParentId());   
    if ( parent == null ) {  
        root = node;  
    }else{  
       parent.addChild(node);  
    }  
}
Run Code Online (Sandbox Code Playgroud)

我如何编写这些注释说明?

java mysql swing jtree

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

如何将JTextField限制为ax个字符数

我必须限制JTextField中的字符数.我使用以下代码来做到这一点,但问题是我使用虚拟键盘将数据提供给JTextField.因此偏移量始终设置为0.当我输入超过指定数量的字符时,它会重置字段并从头开始执行.例如,如果我的限制是3个字符并且我进入xyz0我的有限文本框,则读取字符z,然后清除该字段并重新启动.所以我留0在了现场.代码如下.

  public class JTextFieldLimit extends PlainDocument {
  private int limit;  
  public JTextFieldLimit(int limit) {  
   super();  
   this.limit = limit;  
   }  
    @Override  
  public void insertString( int offset, String  str, AttributeSet attr ) throws   BadLocationException {  
    if (str == null) return;  
            System.out.println("from document helper getLength():"+getLength());  
            System.out.println("from document helper str.length():"+str.length());  
            System.out.println("from document helper str:"+str);  
            System.out.println("from document helper attr:"+attr);  
            System.out.println("from document helper offset:"+offset);  
    if ((getLength() + str.length()) <= limit) {  
      super.insertString(offset, str, attr);  
    }  
  }  
}  
Run Code Online (Sandbox Code Playgroud)

java swing jtextfield

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

mysqli :: real_connect和连接数据库中的新mysqli对象有什么区别?

我正在使用此方法连接到mysqldb:

$this->_Con = new mysqli($this->_DB['Server'],$this->_DB['User'],$this->_DB['Pass'],$this->_DB['DB']);
Run Code Online (Sandbox Code Playgroud)

使用此方法连接时有什么区别:

$this->_Con = mysqli_init();
$this->_Con->real_connect($this->_DB['Server'],$this->_DB['User'],$this->_DB['Pass'],$this->_DB['DB']);
Run Code Online (Sandbox Code Playgroud)

php mysqli

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

处理Codeigniter查询中的括号

我有以下代码块,预计会返回 count

    $sql = "SELECT sum(count) as count 
            FROM multipleowners WHERE owner = ? " . $localityquery;
    $queryarray = array($owner, $locality);
    $query = $this->db->query($sql, $queryarray);
    if ($query->num_rows() > 0)
    {
        $result = $query->row_array();
        $count = $result['count']; 
    }
Run Code Online (Sandbox Code Playgroud)

但是当我尝试打印时,我得到空值$count.

我用过print_r($this->db->last_query());,得到了以下查询,

SELECT sum(count) as count FROM multipleowners WHERE owner = 'Davenports Harbour Trustee (2012) Limited' and locality = 'Auckland Central'
Run Code Online (Sandbox Code Playgroud)

当我直接执行此查询到我的时,Postgresql IDE我得到了countas 的输出2.

这个查询出错了什么地方?我怀疑的存在()WHERE条款.我该如何解决 ?

更新 …

php postgresql activerecord codeigniter

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

使用静态类型是个好主意吗?

我知道静态类型和其他类型之间的区别,但我不确定在哪里使用.现在我在所有地方都使用静态类型来避免对象实例化.以这种方式使用它是一个好主意吗?在所有地方使用静态类型有什么特别的缺点吗?

编辑

你怎么称呼它static String staff

java

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

每两周对mysql记录进行分组

我想在其时间戳字段Fortnightly上对记录进行分组.我现在每周都在做,但我也希望它每两周一次.我怎么做 ?有没有一种特定的方法来实现这一点,比如我们如何使用WEEK('timestamp','%d-%m-%Y')函数分组几周?

在下面的图像中,您可以看到日期21和14出现两周10.有任何建议吗?

mysql

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