いつもお世話になっております。
現在、JavaSEとSQLを使用しています。
今回私がやりたいことは、localhost上のテーブルにあるカラム「社員番号」と「社員名」のフィールドデータを、下記画像のプルダウンに表示させたいと思っています。
【表示例】
1001 田中太郎
1002 鈴木健太
1003 東条花子
*カラムとの間にスペースを入れ、1行に2つのフィールドデータを表示させたいです。
現在のコードを転載させていただきます。
Java
1 2/** 3*UIクラス 4*/ 5 6package ui; 7 8import java.awt.EventQueue; 9import java.awt.Font; 10 11import javax.swing.JComboBox; 12import javax.swing.JFrame; 13import javax.swing.JLabel; 14 15public class TEST_UI { 16 17 private JFrame frame; 18 19 /** 20 * Launch the application. 21 */ 22 public static void main(String[] args) { 23 EventQueue.invokeLater(new Runnable() { 24 public void run() { 25 try { 26 TEST_UI window = new TEST_UI(); 27 window.frame.setVisible(true); 28 } catch (Exception e) { 29 e.printStackTrace(); 30 } 31 } 32 }); 33 } 34 35 /** 36 * Create the application. 37 */ 38 public TEST_UI() { 39 initialize(); 40 } 41 42 /** 43 * Initialize the contents of the frame. 44 */ 45 private void initialize() { 46 frame = new JFrame(); 47 frame.setBounds(100, 100, 483, 316); 48 frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); 49 frame.getContentPane().setLayout(null); 50 51 /** 52 * 以下よりプルダウン表示コード 53 */ 54 55 JComboBox comboBox = new JComboBox(); 56 comboBox.setBounds(215, 75, 149, 49); 57 frame.getContentPane().add(comboBox); 58 59 JLabel lblNewLabel = new JLabel("社員番号 社員名:"); 60 lblNewLabel.setFont(new Font("Lucida Grande", Font.PLAIN, 20)); 61 lblNewLabel.setBounds(35, 90, 200, 21); 62 frame.getContentPane().add(lblNewLabel); 63 } 64} 65
*追記
【流れ】
① UIクラス1で「検索」を押すとUIクラス2の画面へ遷移
② UIクラス2の画面(上記キャプチャ画像)のプルダウンで情報が取得されている状態を作る。
③ 終了
もし、お分りの方がいらっしゃいましたら、お力添えを頂けますと幸いです。
よろしくお願い致します。
回答3件
あなたの回答
tips
プレビュー