file dialog experiments (swing only)
cleanup git-svn-id: https://only.mawhrin.net/repos/FBReaderJ/trunk@414 6a642e6f-84f6-412e-ac94-c4a38d5a04b0
BIN
icons/filetree/fb2.png
Normal file
After Width: | Height: | Size: 523 B |
BIN
icons/filetree/folder.png
Normal file
After Width: | Height: | Size: 680 B |
BIN
icons/filetree/html.png
Normal file
After Width: | Height: | Size: 1.1 KiB |
BIN
icons/filetree/mobipocket.png
Normal file
After Width: | Height: | Size: 523 B |
BIN
icons/filetree/oeb.png
Normal file
After Width: | Height: | Size: 523 B |
BIN
icons/filetree/openreader.png
Normal file
After Width: | Height: | Size: 523 B |
BIN
icons/filetree/palm.png
Normal file
After Width: | Height: | Size: 523 B |
BIN
icons/filetree/plucker.png
Normal file
After Width: | Height: | Size: 523 B |
BIN
icons/filetree/rtf.png
Normal file
After Width: | Height: | Size: 654 B |
BIN
icons/filetree/tcr.png
Normal file
After Width: | Height: | Size: 523 B |
BIN
icons/filetree/unknown.png
Normal file
After Width: | Height: | Size: 523 B |
BIN
icons/filetree/upfolder.png
Normal file
After Width: | Height: | Size: 836 B |
BIN
icons/filetree/weasel.png
Normal file
After Width: | Height: | Size: 523 B |
BIN
icons/filetree/zipfolder.png
Normal file
After Width: | Height: | Size: 695 B |
27
src/org/fbreader/fbreader/AddBookAction.java
Normal file
|
@ -0,0 +1,27 @@
|
|||
package org.fbreader.fbreader;
|
||||
|
||||
import org.zlibrary.core.dialogs.ZLDialogManager;
|
||||
|
||||
class AddBookAction extends FBAction {
|
||||
AddBookAction(FBReader fbreader) {
|
||||
super(fbreader);
|
||||
}
|
||||
|
||||
public boolean isVisible() {
|
||||
return fbreader().getMode() != FBReader.ViewMode.FOOTNOTE;
|
||||
}
|
||||
|
||||
public void run() {
|
||||
ZLDialogManager.getInstance().runSelectionDialog("addFileDialog", null);
|
||||
/*
|
||||
FBFileHandler handler;
|
||||
if (ZLDialogManager::instance().selectionDialog(ZLResourceKey("addFileDialog"), handler)) {
|
||||
BookDescriptionPtr description = handler.description();
|
||||
if (!description.isNull() && fbreader().runBookInfoDialog(description->fileName())) {
|
||||
BookList().addFileName(description->fileName());
|
||||
fbreader().setMode(FBReader::BOOK_TEXT_MODE);
|
||||
}
|
||||
}
|
||||
*/
|
||||
}
|
||||
}
|
|
@ -59,7 +59,7 @@ public final class FBReader extends ZLApplication {
|
|||
addAction(ActionCode.SHOW_OPTIONS, new DummyAction(this));
|
||||
addAction(ActionCode.SHOW_CONTENTS, new ShowContentsAction(this));
|
||||
addAction(ActionCode.SHOW_BOOK_INFO, new DummyAction(this));
|
||||
addAction(ActionCode.ADD_BOOK, new DummyAction(this));
|
||||
addAction(ActionCode.ADD_BOOK, new AddBookAction(this));
|
||||
addAction(ActionCode.SEARCH, new DummyAction(this));
|
||||
addAction(ActionCode.FIND_NEXT, new DummyAction(this));
|
||||
addAction(ActionCode.FIND_PREVIOUS, new DummyAction(this));
|
||||
|
|
|
@ -57,7 +57,6 @@ public class FB2Reader extends ZLXMLReader {
|
|||
|
||||
// private BookModel myBookModel = new BookModel();
|
||||
|
||||
@Override
|
||||
public void characterDataHandler(char[] ch, int start, int length) {
|
||||
if (length == 0) {
|
||||
return;
|
||||
|
@ -69,7 +68,6 @@ public class FB2Reader extends ZLXMLReader {
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void characterDataHandlerFinal(char[] ch, int start, int length) {
|
||||
if (length == 0) {
|
||||
return;
|
||||
|
@ -81,7 +79,6 @@ public class FB2Reader extends ZLXMLReader {
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void endElementHandler(String tagName) {
|
||||
FB2Tag tag;
|
||||
tag = getTag(tagName);
|
||||
|
@ -188,7 +185,6 @@ public class FB2Reader extends ZLXMLReader {
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void startElementHandler(String tagName, Map<String, String> attributes) {
|
||||
String id = attributes.get("id");
|
||||
if (id != null) {
|
||||
|
@ -368,7 +364,6 @@ public class FB2Reader extends ZLXMLReader {
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void endDocumentHandler() {
|
||||
myTagsByName.clear();
|
||||
}
|
||||
|
|
|
@ -346,7 +346,7 @@ public abstract class ZLApplication {
|
|||
myItems.add(new SeparatorItem());
|
||||
}
|
||||
|
||||
List<Item> getItems() {
|
||||
List<Item> items() {
|
||||
return Collections.unmodifiableList(myItems);
|
||||
}
|
||||
|
||||
|
@ -374,7 +374,7 @@ public abstract class ZLApplication {
|
|||
}
|
||||
|
||||
public String getTooltip() {
|
||||
return myTooltip.hasValue() ? myTooltip.value() : "";
|
||||
return myTooltip.hasValue() ? myTooltip.getValue() : null;
|
||||
}
|
||||
|
||||
ButtonGroup getButtonGroup() {
|
||||
|
@ -425,7 +425,7 @@ public abstract class ZLApplication {
|
|||
|
||||
public final class ButtonGroup {
|
||||
public final int UnselectAllButtonsActionId;
|
||||
public final Set<ButtonItem> Items = new HashSet<ButtonItem>();
|
||||
public final HashSet<ButtonItem> Items = new HashSet<ButtonItem>();
|
||||
public ButtonItem PressedItem;
|
||||
|
||||
ButtonGroup(int unselectAllButtonsActionId) {
|
||||
|
@ -456,7 +456,7 @@ public abstract class ZLApplication {
|
|||
}
|
||||
|
||||
public void addItem(int actionId, String key) {
|
||||
myItems.add(new Menubar.PlainItem(myResource.getResource(key).value(), actionId));
|
||||
myItems.add(new Menubar.PlainItem(myResource.getResource(key).getValue(), actionId));
|
||||
}
|
||||
|
||||
public void addSeparator() {
|
||||
|
@ -469,7 +469,7 @@ public abstract class ZLApplication {
|
|||
return submenu;
|
||||
}
|
||||
|
||||
List<Item> getItems() {
|
||||
List<Item> items() {
|
||||
return Collections.unmodifiableList(myItems);
|
||||
}
|
||||
}
|
||||
|
@ -500,7 +500,7 @@ public abstract class ZLApplication {
|
|||
}
|
||||
|
||||
public String getMenuName() {
|
||||
return getResource().value();
|
||||
return getResource().getValue();
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -515,7 +515,7 @@ public abstract class ZLApplication {
|
|||
//MenuVisitor
|
||||
static public abstract class MenuVisitor {
|
||||
public final void processMenu(Menu menu) {
|
||||
for (Menu.Item item : menu.getItems()) {
|
||||
for (Menu.Item item : menu.items()) {
|
||||
if (item instanceof Menubar.PlainItem) {
|
||||
processItem((Menubar.PlainItem)item);
|
||||
} else if (item instanceof Menubar.Submenu) {
|
||||
|
|
|
@ -22,7 +22,7 @@ abstract public class ZLApplicationWindow {
|
|||
protected void init() {
|
||||
myApplication.setViewWidget(createViewWidget());
|
||||
|
||||
List<ZLApplication.Toolbar.Item> toolbarItems = myApplication.getToolbar().getItems();
|
||||
List<ZLApplication.Toolbar.Item> toolbarItems = myApplication.getToolbar().items();
|
||||
for (ZLApplication.Toolbar.Item item: toolbarItems) {
|
||||
addToolbarItem(item);
|
||||
}
|
||||
|
@ -66,7 +66,7 @@ abstract public class ZLApplicationWindow {
|
|||
abstract public void addToolbarItem(ZLApplication.Toolbar.Item item);
|
||||
|
||||
protected void refresh() {
|
||||
List<ZLApplication.Toolbar.Item> items = getApplication().getToolbar().getItems();
|
||||
List<ZLApplication.Toolbar.Item> items = getApplication().getToolbar().items();
|
||||
boolean enableToolbarSpace = false;
|
||||
ZLApplication.Toolbar.Item lastSeparator = null;
|
||||
for (ZLApplication.Toolbar.Item item : items) {
|
||||
|
|
|
@ -16,7 +16,7 @@ public final class ZLKeyBindings {
|
|||
private static final String BINDED_ACTION = "Action";
|
||||
|
||||
private final String myName;
|
||||
private final Map<String, Integer> myBindingsMap = new TreeMap<String, Integer>();
|
||||
private final TreeMap<String,Integer> myBindingsMap = new TreeMap<String, Integer>();
|
||||
private boolean myIsChanged;
|
||||
|
||||
public ZLKeyBindings(String name) {
|
||||
|
|
|
@ -13,46 +13,44 @@ public abstract class ZLDialogManager {
|
|||
public static final String APPLY_BUTTON = "apply";
|
||||
|
||||
public static final String COLOR_KEY = "color";
|
||||
public static final String DIALOG_TITLE = "title";
|
||||
|
||||
protected ZLDialogManager() {
|
||||
ourInstance = this;
|
||||
}
|
||||
|
||||
public static ZLDialogManager getInstance() {
|
||||
return ourInstance;
|
||||
}
|
||||
|
||||
abstract public boolean runSelectionDialog(String key, ZLTreeHandler handler);
|
||||
|
||||
public static boolean isInitialized() {
|
||||
return ourInstance != null;
|
||||
abstract public void showInformationBox(String key, String message);
|
||||
|
||||
public void showInformationBox(String key) {
|
||||
showInformationBox(key, getDialogMessage(key));
|
||||
}
|
||||
|
||||
public abstract void showErrorBox(String key, String message);
|
||||
|
||||
public void showErrorBox(String key) {
|
||||
showErrorBox(key, getDialogMessage(key));
|
||||
}
|
||||
|
||||
//public abstract void createApplicationWindow(ZLApplication application);
|
||||
|
||||
public static String getButtonText(String key) {
|
||||
return getResource().getResource("button").getResource(key).getValue();
|
||||
}
|
||||
|
||||
public static void deleteInstance() {
|
||||
ourInstance = null;
|
||||
public static String getDialogMessage(String key) {
|
||||
return getResource().getResource(key).getResource("message").getValue();
|
||||
}
|
||||
|
||||
public void informationBox(String key) {
|
||||
informationBox(key, dialogMessage(key));
|
||||
public static String getDialogTitle(String key) {
|
||||
return getResource().getResource(key).getResource("title").getValue();
|
||||
}
|
||||
|
||||
public void errorBox(String key) {
|
||||
errorBox(key, dialogMessage(key));
|
||||
}
|
||||
|
||||
public abstract void errorBox(String key, String message);
|
||||
|
||||
public abstract void informationBox(String key, String message);
|
||||
|
||||
public abstract void createApplicationWindow(ZLApplication application);
|
||||
|
||||
public static String dialogMessage(String key) {
|
||||
return resource().getResource(key).getResource("message").value();
|
||||
}
|
||||
|
||||
public static String dialogTitle(String key) {
|
||||
return resource().getResource(key).getResource(DIALOG_TITLE).value();
|
||||
}
|
||||
|
||||
protected static ZLResource resource() {
|
||||
protected static ZLResource getResource() {
|
||||
return ZLResource.resource("dialog");
|
||||
}
|
||||
}
|
||||
|
|
4
src/org/zlibrary/core/dialogs/ZLTreeHandler.java
Normal file
|
@ -0,0 +1,4 @@
|
|||
package org.zlibrary.core.dialogs;
|
||||
|
||||
public class ZLTreeHandler {
|
||||
}
|
|
@ -8,18 +8,15 @@ final class ZLMissingResource extends ZLResource {
|
|||
super(ourValue);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ZLResource getResource(String key) {
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasValue() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String value() {
|
||||
public String getValue() {
|
||||
return ourValue;
|
||||
}
|
||||
|
||||
|
|
|
@ -20,8 +20,6 @@ abstract public class ZLResource {
|
|||
}
|
||||
|
||||
abstract public boolean hasValue();
|
||||
|
||||
abstract public String value();
|
||||
|
||||
abstract public String getValue();
|
||||
abstract public ZLResource getResource(String key);
|
||||
}
|
||||
|
|
|
@ -49,11 +49,10 @@ final class ZLTreeResource extends ZLResource {
|
|||
return myHasValue;
|
||||
}
|
||||
|
||||
public String value() {
|
||||
public String getValue() {
|
||||
return myHasValue ? myValue : ZLMissingResource.ourValue;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ZLResource getResource(String key) {
|
||||
if (myChildren != null) {
|
||||
ZLResource child = myChildren.get(key);
|
||||
|
@ -74,14 +73,12 @@ final class ZLTreeResource extends ZLResource {
|
|||
read(string);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void endElementHandler(String tag) {
|
||||
if (!myStack.isEmpty() && (NODE.equals(tag))) {
|
||||
myStack.remove(myStack.size() - 1);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void startElementHandler(String tag, Map<String, String> attributes) {
|
||||
if (!myStack.isEmpty() && (NODE.equals(tag))) {
|
||||
String name = attributes.get("name");
|
||||
|
|
|
@ -1,8 +1,6 @@
|
|||
package org.zlibrary.text.model;
|
||||
|
||||
import java.util.Iterator;
|
||||
|
||||
public interface ZLTextParagraph extends Iterable<ZLTextParagraph.Entry> {
|
||||
public interface ZLTextParagraph {
|
||||
interface Entry {
|
||||
byte TEXT = 1;
|
||||
byte IMAGE = 2;
|
||||
|
@ -11,7 +9,7 @@ public interface ZLTextParagraph extends Iterable<ZLTextParagraph.Entry> {
|
|||
byte FIXED_HSPACE = 5;
|
||||
}
|
||||
|
||||
interface EntryIterator extends Iterator<Entry> {
|
||||
interface EntryIterator {
|
||||
byte getType();
|
||||
|
||||
char[] getTextData();
|
||||
|
@ -20,6 +18,9 @@ public interface ZLTextParagraph extends Iterable<ZLTextParagraph.Entry> {
|
|||
|
||||
byte getControlKind();
|
||||
boolean getControlIsStart();
|
||||
|
||||
boolean hasNext();
|
||||
Entry next();
|
||||
}
|
||||
|
||||
public EntryIterator iterator();
|
||||
|
|
|
@ -70,9 +70,6 @@ abstract class ZLTextModelImpl implements ZLTextModel {
|
|||
}
|
||||
|
||||
public ZLTextParagraph.Entry next() {
|
||||
if (myCounter == myLength) {
|
||||
throw new NoSuchElementException();
|
||||
}
|
||||
ZLTextParagraph.Entry entry = null;
|
||||
if (myDataOffset == DATA_BLOCK_SIZE) {
|
||||
++myDataIndex;
|
||||
|
@ -127,10 +124,6 @@ abstract class ZLTextModelImpl implements ZLTextModel {
|
|||
++myCounter;
|
||||
return entry;
|
||||
}
|
||||
|
||||
public void remove() {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
}
|
||||
|
||||
abstract void increaseLastParagraphSize();
|
||||
|
|
|
@ -70,9 +70,11 @@ final class ZLTextTreeParagraphImpl extends ZLTextParagraphImpl implements ZLTex
|
|||
|
||||
public int getFullSize() {
|
||||
int size = 1;
|
||||
if (myChildren != null) {
|
||||
for (ZLTextTreeParagraph child : myChildren) {
|
||||
size += child.getFullSize();
|
||||
final ArrayList<ZLTextTreeParagraph> children = myChildren;
|
||||
if (children != null) {
|
||||
final int length = children.size();
|
||||
for (int i = 0; i < length; ++i) {
|
||||
size += children.get(i).getFullSize();
|
||||
}
|
||||
}
|
||||
return size;
|
||||
|
|
|
@ -89,7 +89,6 @@ public class ZLTextStyleCollection {
|
|||
myCollection = collection;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void startElementHandler(String tag, Map<String,String> attributes) {
|
||||
final String BASE = "base";
|
||||
final String STYLE = "style";
|
||||
|
|
|
@ -13,6 +13,7 @@ import org.zlibrary.core.options.ZLIntegerRangeOption;
|
|||
import org.zlibrary.core.options.ZLOption;
|
||||
import org.zlibrary.ui.swing.library.ZLSwingLibrary;
|
||||
import org.zlibrary.ui.swing.view.ZLSwingViewWidget;
|
||||
import org.zlibrary.ui.swing.util.ZLSwingIconUtil;
|
||||
|
||||
@SuppressWarnings("serial")
|
||||
public class ZLSwingApplicationWindow extends ZLApplicationWindow {
|
||||
|
@ -86,7 +87,10 @@ public class ZLSwingApplicationWindow extends ZLApplicationWindow {
|
|||
myFrame.setJMenuBar(myMenuBar);
|
||||
myFrame.addKeyListener(new MyKeyListener());
|
||||
myFrame.setFocusable(true);
|
||||
}
|
||||
|
||||
public JFrame getFrame() {
|
||||
return myFrame;
|
||||
}
|
||||
|
||||
public void run() {
|
||||
|
@ -148,7 +152,6 @@ public class ZLSwingApplicationWindow extends ZLApplicationWindow {
|
|||
|
||||
}
|
||||
|
||||
|
||||
public void setCaption(String caption) {
|
||||
myFrame.setTitle(caption);
|
||||
}
|
||||
|
@ -180,10 +183,8 @@ public class ZLSwingApplicationWindow extends ZLApplicationWindow {
|
|||
|
||||
MyButtonAction(ZLApplication.Toolbar.ButtonItem item) {
|
||||
myItem = item;
|
||||
String iconFileName = "icons/toolbar/" + myItem.getIconName() + ".png";
|
||||
java.net.URL iconURL = getClass().getClassLoader().getResource(iconFileName);
|
||||
ImageIcon icon = (iconURL != null) ? new ImageIcon(iconURL) : new ImageIcon(iconFileName);
|
||||
putValue(Action.SMALL_ICON, icon);
|
||||
final String iconFileName = "icons/toolbar/" + myItem.getIconName() + ".png";
|
||||
putValue(Action.SMALL_ICON, ZLSwingIconUtil.getIcon(iconFileName));
|
||||
putValue(Action.SHORT_DESCRIPTION, item.getTooltip());
|
||||
}
|
||||
|
||||
|
|
|
@ -1,12 +1,12 @@
|
|||
package org.zlibrary.ui.swing.dialogs;
|
||||
|
||||
import javax.swing.*;
|
||||
|
||||
import org.zlibrary.core.dialogs.*;
|
||||
import org.zlibrary.core.application.ZLApplication;
|
||||
import org.zlibrary.core.dialogs.ZLDialogManager;
|
||||
import org.zlibrary.core.resources.ZLResource;
|
||||
import org.zlibrary.ui.swing.application.ZLSwingApplicationWindow;
|
||||
|
||||
import javax.swing.JOptionPane;
|
||||
|
||||
public class ZLSwingDialogManager extends ZLDialogManager {
|
||||
private ZLSwingApplicationWindow myApplicationWindow;
|
||||
|
||||
|
@ -14,26 +14,31 @@ public class ZLSwingDialogManager extends ZLDialogManager {
|
|||
}
|
||||
|
||||
public static void createInstance() {
|
||||
ourInstance = new ZLSwingDialogManager();
|
||||
new ZLSwingDialogManager();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void errorBox(String key, String message) {
|
||||
// TODO Auto-generated method stub
|
||||
JOptionPane.showMessageDialog(null, message, dialogTitle(key), 1, null);
|
||||
public boolean runSelectionDialog(String key, ZLTreeHandler handler) {
|
||||
new ZLSwingSelectionDialog(myApplicationWindow.getFrame()).run();
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void informationBox(String key, String message) {
|
||||
// TODO Auto-generated method stub
|
||||
JOptionPane.showMessageDialog(null, message, dialogTitle(key), 1, null);
|
||||
public void showErrorBox(String key, String message) {
|
||||
JOptionPane.showMessageDialog(myApplicationWindow.getFrame(), message, getDialogTitle(key), 1, null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void createApplicationWindow(ZLApplication application) {
|
||||
public void showInformationBox(String key, String message) {
|
||||
JOptionPane.showMessageDialog(myApplicationWindow.getFrame(), message, getDialogTitle(key), 1, null);
|
||||
}
|
||||
|
||||
public ZLSwingApplicationWindow createApplicationWindow(ZLApplication application) {
|
||||
myApplicationWindow = new ZLSwingApplicationWindow(application);
|
||||
return myApplicationWindow;
|
||||
}
|
||||
|
||||
static JButton createButton(String key) {
|
||||
String text = getButtonText(key).replace("&", "");
|
||||
return new JButton(text);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
|
|
|
@ -0,0 +1,70 @@
|
|||
package org.zlibrary.ui.swing.dialogs;
|
||||
|
||||
import javax.swing.*;
|
||||
import java.awt.*;
|
||||
|
||||
import org.zlibrary.ui.swing.util.ZLSwingIconUtil;
|
||||
|
||||
class ZLSwingSelectionDialog {
|
||||
private JDialog myJDialog;
|
||||
|
||||
ZLSwingSelectionDialog(JFrame frame) {
|
||||
myJDialog = new JDialog(frame, true);
|
||||
}
|
||||
|
||||
private static class CellRenderer extends JLabel implements ListCellRenderer {
|
||||
final static ImageIcon icon = ZLSwingIconUtil.getIcon("icons/filetree/unknown.png");
|
||||
final static ImageIcon upicon = ZLSwingIconUtil.getIcon("icons/filetree/upfolder.png");
|
||||
|
||||
public Component getListCellRendererComponent(
|
||||
JList list,
|
||||
Object value, // value to display
|
||||
int index, // cell index
|
||||
boolean isSelected, // is the cell selected
|
||||
boolean cellHasFocus) // the list and the cell have the focus
|
||||
{
|
||||
String s = value.toString();
|
||||
setText(s);
|
||||
setIcon(s.equals("..") ? upicon : icon);
|
||||
if (isSelected) {
|
||||
setBackground(list.getSelectionBackground());
|
||||
setForeground(list.getSelectionForeground());
|
||||
} else {
|
||||
setBackground(list.getBackground());
|
||||
setForeground(list.getForeground());
|
||||
}
|
||||
setEnabled(list.isEnabled());
|
||||
setFont(list.getFont());
|
||||
setOpaque(true);
|
||||
return this;
|
||||
}
|
||||
}
|
||||
|
||||
void run() {
|
||||
myJDialog.setLayout(new BorderLayout());
|
||||
|
||||
JTextField textLine = new JTextField();
|
||||
textLine.setText("directory name");
|
||||
textLine.setEditable(false);
|
||||
myJDialog.add(textLine, BorderLayout.NORTH);
|
||||
|
||||
String[] books = new String[] { "..", "Book 0", "Book 1", "Book 2", "Book 3", "Book 4", "Book 5" };
|
||||
JList list = new JList(books);
|
||||
list.setCellRenderer(new CellRenderer());
|
||||
JScrollPane scrollPane = new JScrollPane(list);
|
||||
scrollPane.setBorder(BorderFactory.createLoweredBevelBorder());
|
||||
myJDialog.add(scrollPane, BorderLayout.CENTER);
|
||||
|
||||
JPanel buttonPanel = new JPanel();
|
||||
buttonPanel.setLayout(new FlowLayout(FlowLayout.RIGHT));
|
||||
JButton button1 = ZLSwingDialogManager.createButton(ZLSwingDialogManager.OK_BUTTON);
|
||||
buttonPanel.add(button1);
|
||||
JButton button2 = ZLSwingDialogManager.createButton(ZLSwingDialogManager.CANCEL_BUTTON);
|
||||
buttonPanel.add(button2);
|
||||
myJDialog.add(buttonPanel, BorderLayout.SOUTH);
|
||||
myJDialog.pack();
|
||||
myJDialog.setSize(400, 400);
|
||||
myJDialog.setLocationRelativeTo(myJDialog.getParent());
|
||||
myJDialog.show();
|
||||
}
|
||||
}
|
|
@ -50,7 +50,8 @@ public class ZLSwingLibrary extends ZLibrary {
|
|||
shutdown();
|
||||
}
|
||||
|
||||
ZLSwingApplicationWindow mainWindow = new ZLSwingApplicationWindow(application);
|
||||
ZLSwingApplicationWindow mainWindow =
|
||||
((ZLSwingDialogManager)ZLSwingDialogManager.getInstance()).createApplicationWindow(application);
|
||||
application.initWindow();
|
||||
mainWindow.run();
|
||||
|
||||
|
|
11
src/org/zlibrary/ui/swing/util/ZLSwingIconUtil.java
Normal file
|
@ -0,0 +1,11 @@
|
|||
package org.zlibrary.ui.swing.util;
|
||||
|
||||
import java.net.URL;
|
||||
import javax.swing.ImageIcon;
|
||||
|
||||
public abstract class ZLSwingIconUtil {
|
||||
public static ImageIcon getIcon(String fileName) {
|
||||
URL iconURL = ZLSwingIconUtil.class.getClassLoader().getResource(fileName);
|
||||
return (iconURL != null) ? new ImageIcon(iconURL) : new ImageIcon(fileName);
|
||||
}
|
||||
}
|