public void showPostById(int id, java.awt.Component dialogParent){
JOptionPane optionPane = new JOptionPane(Localization.format("retrieval_format", String.valueOf(id)), JOptionPane.INFORMATION_MESSAGE);
JButton button = new JButton(Localization.getString("cancel"));
optionPane.setOptions(new Object[]{button});
JDialog dialog = optionPane.createDialog(dialogParent, Localization.getString("retrieving"));
button.addActionListener(event -> dialog.dispose());
dialog.setModalityType(ModalityType.MODELESS);
dialog.setVisible(true);
executor.execute(() -> {
List<Post> searchPosts = mapi.listPosts(1, 1, "id:" + id);
SwingUtilities.invokeLater(() -> {
if (dialog.isDisplayable()){
dialog.dispose();
if (!searchPosts.isEmpty()){
showPostFrame.showPost(searchPosts.get(0));
}else{
JOptionPane.showMessageDialog(null, Localization.getString("id_doesnot_exists"),
Localization.getString("error"), JOptionPane.ERROR_MESSAGE);
}
}
});
});
}
MoebooruViewer.java 文件源码
java
阅读 32
收藏 0
点赞 0
评论 0
项目:moebooru-viewer
作者:
评论列表
文章目录