示例#1
0
 public void getDescriptionsByWord(String sWord) throws SQLException, SAXException, IOException {
   String sSql = "SELECT description FROM hydc9 " + "WHERE ci = ?";
   PreparedStatement statement = connection.prepareStatement(sSql);
   statement.setString(1, sWord);
   ResultSet resultSet = statement.executeQuery();
   while (resultSet.next()) {
     controller.setDescriptionByWord(resultSet.getClob("description"));
   }
   resultSet.close();
   statement.close();
 }
示例#2
0
 public void getDescriptionsByCharacter(String sCharacter)
     throws SQLException, SAXException, IOException {
   String sSql =
       "SELECT hydc2.description FROM hydc2 AS hydc2, hydc3 AS hydc3 "
           + "WHERE hydc2.gbk = hydc3.gbk AND hydc3.unicode = ?";
   PreparedStatement statement = connection.prepareStatement(sSql);
   statement.setInt(1, sCharacter.codePointAt(0));
   ResultSet resultSet = statement.executeQuery();
   while (resultSet.next()) {
     controller.setDescriptionByCharacter(resultSet.getClob("description"));
   }
   resultSet.close();
   statement.close();
 }
示例#3
0
 /**
  * constructor
  *
  * @param controller is the parent object
  * @throws Exception
  */
 public PseudoHYDC3View(PseudoHYDC3 controller) throws Exception {
   this.controller = controller;
   {
     String sFontName = "DFKai-SB2" /*"PMingLiU"*/;
     if (System.getProperty("hydc3.fontName") != null) {
       sFontName = System.getProperty("hydc3.fontName");
     }
     UIManager.put(
         "TextPane.font",
         new Font(
             sFontName,
             UIManager.getFont("TextPane.font").getStyle(),
             UIManager.getFont("TextPane.font").getSize()));
     UIManager.put(
         "List.font",
         new Font(
             sFontName,
             UIManager.getFont("List.font").getStyle(),
             UIManager.getFont("List.font").getSize()));
     UIManager.put(
         "TextField.font",
         new Font(
             sFontName,
             UIManager.getFont("TextField.font").getStyle(),
             UIManager.getFont("TextField.font").getSize()));
   }
   frame = new JFrame("漢語大詞典もどき");
   frame.setPreferredSize(new Dimension(800, 600));
   {
     JMenuBar menuBar = new JMenuBar();
     {
       JMenu menu = new JMenu("File");
       {
         JMenuItem menuItem = new JMenuItem("Exit");
         menuItem.addActionListener(
             new ActionListener() {
               @Override
               public void actionPerformed(ActionEvent event) {
                 System.exit(0);
               }
             });
         menu.add(menuItem);
       }
       menuBar.add(menu);
     }
     {
       JMenu menu = new JMenu("Help");
       {
         JMenuItem menuItem = new JMenuItem("About...");
         menuItem.addActionListener(
             new ActionListener() {
               @Override
               public void actionPerformed(ActionEvent event) {
                 JOptionPane.showMessageDialog(
                     frame,
                     "漢語大詞典もどき  version 0.1  by Beu",
                     "about",
                     JOptionPane.INFORMATION_MESSAGE);
               }
             });
         menu.add(menuItem);
       }
       menuBar.add(menu);
     }
     frame.setJMenuBar(menuBar);
     JPanel rootPanel = new JPanel(new BorderLayout());
     {
       JSplitPane splitPane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT);
       {
         JSplitPane splitPane2 = new JSplitPane(JSplitPane.VERTICAL_SPLIT);
         {
           JTabbedPane tabbedPane = new JTabbedPane();
           {
             JPanel panel = new JPanel();
             BoxLayout layout = new BoxLayout(panel, BoxLayout.Y_AXIS);
             panel.setLayout(layout);
             {
               JPanel panel2 = new JPanel();
               {
                 inputTextField = new JTextField(8);
                 Font font = inputTextField.getFont();
                 font = font.deriveFont(font.getSize2D() * 3);
                 inputTextField.setFont(font);
                 panel2.add(inputTextField);
               }
               panel.add(panel2);
             }
             {
               JPanel panel2 = new JPanel();
               {
                 JButton button = new JButton("字");
                 button.setActionCommand("searchWithCharacter");
                 button.addActionListener(controller);
                 panel2.add(button);
               }
               {
                 JButton button = new JButton("詞");
                 button.setActionCommand("searchWithWord");
                 button.addActionListener(controller);
                 panel2.add(button);
               }
               {
                 JButton button = new JButton("音");
                 button.setActionCommand("searchWithReading");
                 button.addActionListener(controller);
                 panel2.add(button);
               }
               {
                 JButton button = new JButton("碼");
                 button.setActionCommand("searchWithCode");
                 button.addActionListener(controller);
                 panel2.add(button);
               }
               panel.add(panel2);
             }
             tabbedPane.addTab("輸入", panel);
           }
           {
             DefaultMutableTreeNode root = controller.getRadicalTree();
             JTree tree = new JTree(root);
             Font font = tree.getFont();
             font = font.deriveFont(font.getSize2D() * 1.5F);
             tree.setFont(font);
             tree.addTreeSelectionListener(controller);
             JScrollPane scrollPane =
                 new JScrollPane(
                     tree,
                     JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED,
                     JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
             tabbedPane.addTab("部首", scrollPane);
           }
           {
             JPanel panel = new JPanel();
             BoxLayout layout = new BoxLayout(panel, BoxLayout.Y_AXIS);
             panel.setLayout(layout);
             {
               JPanel panel2 = new JPanel();
               panel2.add(new JLabel("從"));
               {
                 fromStrokesTextField = new JTextField("1", 2);
                 Font font = fromStrokesTextField.getFont();
                 font = font.deriveFont(font.getSize2D() * 2);
                 fromStrokesTextField.setFont(font);
                 fromStrokesTextField.setHorizontalAlignment(JTextField.RIGHT);
                 panel2.add(fromStrokesTextField);
               }
               panel2.add(new JLabel("到"));
               {
                 toStrokesTextField = new JTextField("10", 2);
                 Font font = toStrokesTextField.getFont();
                 font = font.deriveFont(font.getSize2D() * 2);
                 toStrokesTextField.setFont(font);
                 toStrokesTextField.setHorizontalAlignment(JTextField.RIGHT);
                 panel2.add(toStrokesTextField);
               }
               panel.add(panel2);
             }
             {
               JPanel panel2 = new JPanel();
               {
                 JButton button = new JButton("査");
                 button.setActionCommand("searchWithStrokes");
                 button.addActionListener(controller);
                 panel2.add(button);
               }
               panel.add(panel2);
             }
             tabbedPane.addTab("畫數", panel);
           }
           splitPane2.add(tabbedPane, JSplitPane.TOP);
         }
         {
           selectingList = new JList();
           Font font = selectingList.getFont();
           font = font.deriveFont(font.getSize2D() * 2);
           selectingList.setFont(font);
           selectingList.addMouseListener(controller);
           JScrollPane scrollPane =
               new JScrollPane(
                   selectingList,
                   JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED,
                   JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
           scrollPane.setBorder(new TitledBorder("候補"));
           splitPane2.add(scrollPane, JSplitPane.BOTTOM);
         }
         splitPane.add(splitPane2, JSplitPane.LEFT);
       }
       {
         descriptionTextPane = new JTextPane();
         Font font = descriptionTextPane.getFont();
         font = font.deriveFont(font.getSize2D() * 1.5F);
         descriptionTextPane.setFont(font);
         descriptionTextPane.addMouseListener(controller);
         descriptionTextPane.addMouseMotionListener(controller);
         JScrollPane scrollPane =
             new JScrollPane(
                 descriptionTextPane,
                 JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED,
                 JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
         splitPane.add(scrollPane, JSplitPane.RIGHT);
       }
       rootPanel.add(splitPane, BorderLayout.CENTER);
     }
     {
       JPanel panel = new JPanel(new BorderLayout());
       {
         JLabel label = new JLabel("status");
         panel.add(label, BorderLayout.WEST);
       }
       rootPanel.add(panel, BorderLayout.SOUTH);
     }
     frame.setContentPane(rootPanel);
   }
   frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
   frame.pack();
   frame.setVisible(true);
 }