标签: application-resource

图像加载的路径

我想在框架中添加图像但是我无法理解应该保留图像文件的位置以及如何给出图像的路径?

我已将图像放在My Document文件夹中并给出该路径,但它给出了错误消息.

我有以下代码.

import java.awt.*; 
import java.awt.image.BufferedImage; 
import java.io.*; 
import javax.imageio.ImageIO; 
import javax.swing.*;   

public class Test extends JPanel {
    BufferedImage image;

    public Test(BufferedImage image) {
        this.image = image;
    }

    protected void paintComponent(Graphics g) {
        super.paintComponent(g);
        // Draw image centered.
        int x = (getWidth() - image.getWidth())/2;
        int y = (getHeight() - image.getHeight())/2;
        g.drawImage(image, x, y, this);
    }

    public static void main(String[] args) throws IOException {
        String path = "images.jpeg";
        BufferedImage image = ImageIO.read(new File(path));
        Test contentPane = new …
Run Code Online (Sandbox Code Playgroud)

java swing image paintcomponent application-resource

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

如何在Zend Framework 1.11.x中的application.ini中注册自定义应用程序资源

我创建了自定义应用程序资源:

class Custom_Entitymanager extends Zend_Application_Resource_ResourceAbstract{
    //...
    public function init (){
        //...
        $em = \Doctrine\ORM\EntityManager::create($options['connection'],  $config);
        return $em;
    }
}
Run Code Online (Sandbox Code Playgroud)

我把它放在MyProject\library\Custom\Entitymanager.php档案里

当我想要检索时Entitymanager使用:

$em = $this->getInvokeArg('bootstrap')->getResource('entityManager');
Run Code Online (Sandbox Code Playgroud)

我得到null对象.

如何在application.ini文件中注册我的自定义应用程序资源?

resources zend-framework application-resource

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