@@ -543,7 +543,7 @@ public void actionPerformed(ActionEvent e) {
543
543
}
544
544
545
545
public void createViewWindow () {
546
- final String [] types = {"" };
546
+ final String [] types = {"" , "" };
547
547
Object [][] data ;
548
548
JDialog jDialogGetWhich = new JDialog (this , "select" , true );
549
549
jDialogGetWhich .setBounds (0 , 0 , 300 , 500 );
@@ -553,6 +553,19 @@ public void createViewWindow() {
553
553
Insets insets = new Insets (10 , 10 , 10 , 10 );
554
554
gbc .fill = GridBagConstraints .BOTH ;
555
555
gbc .insets = insets ;
556
+ JComboBox comboBoxPlace = new JComboBox ();
557
+ String [] selections1 = {"梧州" , "苍梧石桥" , "蒙山" };
558
+ for (String item : selections1 ) {
559
+ comboBoxPlace .addItem (item );
560
+ }
561
+ comboBoxPlace .setSize (100 , 50 );
562
+ gbc .gridx = 0 ;
563
+ gbc .gridy = 0 ;
564
+ gbc .gridwidth = 1 ; // 横占一个单元格
565
+ gbc .gridheight = 1 ; // 列占一个单元格
566
+ gbc .weightx = 0.0 ; // 当窗口放大时,长度不变
567
+ gbc .weighty = 0.0 ; // 当窗口放大时,高度不变
568
+ jDialogGetWhich .add (comboBoxPlace , gbc );
556
569
JComboBox comboBox = new JComboBox ();
557
570
String [] selections = {"A" , "B" , "C" , "D" , "E" , "F" , "G" , "H" , "I" , "J" , "K" , "L" , "M" , "N" , "O" , "P" , "Q" , "R" , "S" , "T" , "U" , "V" , "W" , "X" , "Y" , "Z" , "All" };
558
571
for (String item : selections ) {
@@ -561,15 +574,15 @@ public void createViewWindow() {
561
574
comboBox .setSelectedItem ("All" );
562
575
comboBox .setSize (100 , 50 );
563
576
gbc .gridx = 0 ;
564
- gbc .gridy = 0 ;
577
+ gbc .gridy = 1 ;
565
578
gbc .gridwidth = 1 ; // 横占一个单元格
566
579
gbc .gridheight = 1 ; // 列占一个单元格
567
580
gbc .weightx = 0.0 ; // 当窗口放大时,长度不变
568
581
gbc .weighty = 0.0 ; // 当窗口放大时,高度不变
569
582
jDialogGetWhich .add (comboBox , gbc );
570
583
JButton jButtonSubmit = new JButton ("Submit" );
571
584
gbc .gridx = 0 ;
572
- gbc .gridy = 1 ;
585
+ gbc .gridy = 2 ;
573
586
gbc .gridwidth = 1 ; // 横占一个单元格
574
587
gbc .gridheight = 1 ; // 列占一个单元格
575
588
gbc .weightx = 0.0 ; // 当窗口放大时,长度不变
@@ -578,6 +591,7 @@ public void createViewWindow() {
578
591
@ Override
579
592
public void actionPerformed (ActionEvent e ) {
580
593
types [0 ] = comboBox .getSelectedItem ().toString ();
594
+ types [1 ] = comboBoxPlace .getSelectedItem ().toString ();
581
595
jDialogGetWhich .dispose ();
582
596
}
583
597
});
@@ -590,8 +604,12 @@ public void actionPerformed(ActionEvent e) {
590
604
String [] columnNames = {"id" , "简体字" , "繁体字" , "梧州读音" , "苍梧石桥读音" , "蒙山读音" };
591
605
List <Object []> l = new ArrayList <>();
592
606
ResultSet res ;
607
+ String place = null ;
608
+ if (types [1 ].matches ("梧州" )) {
609
+ place = "Wuzhou" ;
610
+ }
593
611
if (types [0 ].matches ("A" ))
594
- res = sql .runSQL ("SELECT * FROM entry.aPart ORDER BY id" );
612
+ res = sql .runSQL ("SELECT * FROM entry.main WHERE Pronunciation_of_" + place + " LIKE 'a%' ORDER BY id" );
595
613
else if (types [0 ].matches ("B" ))
596
614
res = sql .runSQL ("SELECT * FROM entry.bPart ORDER BY id" );
597
615
else if (types [0 ].matches ("C" ))
@@ -647,12 +665,16 @@ else if(types[0].matches("All"))
647
665
else
648
666
res = sql .runSQL ("SELECT * FROM entry.viewAll ORDER BY id" );
649
667
try {
650
- while (res .next ()) {
651
- l .add (new Object []{res .getString ("id" ), res .getString ("simplified_Chinese_character" ), res .getString ("traditional_Chinese_character" ), res .getString ("Pronunciation_of_Wuzhou" ), res .getString ("Pronunciation_of_Cangwu_Shiqiao" ), res .getString ("Pronunciation_of_Mengshan" )});
652
- }
653
- data = new Object [l .size ()][6 ];
654
- for (int i = 0 ; i < l .size (); i ++) {
655
- data [i ] = l .get (i );
668
+ if (res != null ) {
669
+ while (res .next ()) {
670
+ l .add (new Object []{res .getString ("id" ), res .getString ("simplified_Chinese_character" ), res .getString ("traditional_Chinese_character" ), res .getString ("Pronunciation_of_Wuzhou" ), res .getString ("Pronunciation_of_Cangwu_Shiqiao" ), res .getString ("Pronunciation_of_Mengshan" )});
671
+ }
672
+ data = new Object [l .size ()][6 ];
673
+ for (int i = 0 ; i < l .size (); i ++) {
674
+ data [i ] = l .get (i );
675
+ }
676
+ } else {
677
+ data = new Object [0 ][6 ];
656
678
}
657
679
} catch (SQLException e ) {
658
680
data = new Object [0 ][6 ];
0 commit comments