javax.jnlp.UnavailableServiceException: uninitialized問題

zhonghuaas 2014-01-03 10:05:23
//Loading, displaying and scaling an image in an applet

import java.awt.BorderLayout;
import java.awt.Graphics;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.jnlp.FileContents;
import javax.jnlp.FileOpenService;
import javax.jnlp.ServiceManager;
import javax.swing.ImageIcon;
import javax.swing.JApplet;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.JTextField;

public class LoadImageAndScale extends JApplet
{
private ImageIcon image;//references image to display
private JPanel scaleJPanel;//JPanel containing the scale-selector
private JLabel percentJLabel;//label for JTextField
private JTextField scaleInputJTextField;//obtains user's input
private JButton scaleChangeJButton;//initiates scaling of image
private double scaleValue = 1.0; //scale percentage for image

//load image when applet is loaded
public void init()
{
scaleJPanel = new JPanel();
percentJLabel = new JLabel("scale percent:");
scaleInputJTextField = new JTextField("100");
scaleChangeJButton= new JButton("Set Scale");

// add components and place scaleJPanel in applet's NORTH region
scaleJPanel.add(percentJLabel);
scaleJPanel.add(scaleInputJTextField);
scaleJPanel.add(scaleChangeJButton);
add(scaleJPanel,BorderLayout.NORTH);

//register event handler for scaleChangeJButton
scaleChangeJButton.addActionListener(
new ActionListener()
{
//when the JButton is pressed,set scaleValue and repaint
public void actionPerformed(ActionEvent e)
{
scaleValue = Double.parseDouble(
scaleInputJTextField.getText())/100.0;
repaint();//causes image to be redisplayed at new scale
}// end method actionPerformed
}//end anonymous inner class
);//end call to addActionListener

//use JNLP services to open an image file that the user selects
try
{
//get a reference to the FileOpenService
FileOpenService fileOpenService =
(FileOpenService) ServiceManager.lookup(
"javax.jnlp.FileOpenService");

//get file's contents from the FileOpenService
FileContents contents =
fileOpenService.openFileDialog(null, null);

//byte array to store image's data
byte[] imageData = new byte[(int) contents.getLength()];
contents.getInputStream().read(imageData);//read image bytes
image = new ImageIcon(imageData);//create the image

//if image successfully loaded,create and add DrawJPanel
add(new DrawJPanel(),BorderLayout.CENTER);
}//end try
catch(Exception e)
{
e.printStackTrace();
}// end catch
}//end method init

//DrawJPanel used to display loaded image
private class DrawJPanel extends JPanel
{
//display image
public void paintComponent(Graphics g)
{
super.paintComponent(g);

//the following values are used to center the image
double spareWidth=
getWidth()-scaleValue*image.getIconHeight();
double spareHeight=
getHeight()-scaleValue*image.getIconHeight();

//draw image with scaled width and height
g.drawImage(image.getImage(),
(int) (spareWidth)/2,(int)(spareHeight)/2,
(int) (image.getIconWidth()*scaleValue),
(int) (image.getIconHeight()*scaleValue),this);
}//end method paint
}//end class DrawJPanel

}//end class LoadImageAndScale
----------------------------------
以上是源码。在eclipse里编的,然后直接运行run。但没有出现“open”对话框。是和java start有关吗?如何达成效果啊,可以用eclipse做到吗?

----------------------------
javax.jnlp.UnavailableServiceException: uninitialized
at javax.jnlp.ServiceManager.lookup(Unknown Source)
at LoadImageAndScale.init(LoadImageAndScale.java:61)
at sun.applet.AppletPanel.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)


这是错误信息。
---------
没有出现“open”对话框,这是为什么啊?
...全文
329 2 打赏 收藏 转发到动态 举报
写回复
用AI写文章
2 条回复
切换为时间正序
请发表友善的回复…
发表回复
另一花生 2014-01-30
  • 打赏
  • 举报
回复
想回答,但是你这种贴了一堆代码谁愿意看呢,你这样做javax.jnlp.UnavailableServiceException: uninitialized把这个去百度看看,应该是没有触发弹出对话框所以不open
zhonghuaas 2014-01-04
  • 打赏
  • 举报
回复
无人回答吗?
内容概要:本文提出了一种基于加权稀疏矩阵恢复与加速交替方向乘子法(ADMM)的单通道盲解混响算法,并提供了完整的Matlab代码实现。该方法旨在从仅有的单路接收信号中有效分离出原始声源信号,克服传统多通道方法对硬件的依赖。核心技术结合了信号在时频域的稀疏性先验,通过构建加权机制以增强稀疏矩阵恢复的准确性,并引入加速ADMM算法来优化求解过程,显著提升了算法的收敛速度与计算效率。该算法特别适用于麦克风阵列受限或无法部署的复杂声学环境,能够有效抑制混响干扰,从而显著提升语音信号的清晰度与后续语音识别系统的性能。; 适合人群:具备扎实的数字信号处理、凸优化理论及稀疏表示基础,从事音频信号处理、语音增强、盲源分离或相关领域研究与开发工作的研究生、科研人员及工程技术人员。; 使用场景及目标:①解决单麦克风场景下的语音混响去除难题,提升语音通信质量;②应用于智能助听器、车载语音系统、远程视频会议、人机交互等存在严重混响的实际应用场景;③为盲解卷积、稀疏信号恢复等领域的研究提供一种高效的算法实现范例与优化思路。; 阅读建议:建议读者在深入理解信号稀疏性、ADMM优化框架等理论基础上,结合所提供的Matlab代码进行实践,重点分析加权策略的设计原理及其对恢复性能的影响,并通过调整正则化参数、权重因子等关键变量,探究其在不同混响强度和噪声条件下的鲁棒性与泛化能力。

62,622

社区成员

发帖
与我相关
我的任务
社区描述
Java 2 Standard Edition
社区管理员
  • Java SE
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧