全部の部品をつけるとソースが長くなるので
とりあえずこんな雰囲気でしょうか?
import java.awt.Color;
import java.awt.event.*;
import javax.swing.*;
import javax.swing.border.*;
public class Test extends JFrame implements ActionListener{
private JMenuItem menuItemQuit;
public Test(String title){
super(title);
// ウィンドウサイズ
this.setSize(800, 600);
// レイアウト
this.setLayout(null);
// ウィンドウクローズ時の処理
this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
// メニューバー作成
JMenuBar menuBar = new JMenuBar();
JMenu menuFile = new JMenu("ファイル");
menuItemQuit = new JMenuItem("終了");
menuItemQuit.addActionListener(this);
JMenu menuEdit = new JMenu("編集");
JMenu menuWindow = new JMenu("ウィンドウ");
JMenu menuTool = new JMenu("ツール");
JMenu menuHelp = new JMenu("ヘルプ");
menuFile.add(menuItemQuit);
menuBar.add(menuFile);
menuBar.add(menuEdit);
menuBar.add(menuWindow);
menuBar.add(menuTool);
menuBar.add(menuHelp);
this.setJMenuBar(menuBar);
// "検索条件"ボーダー
LineBorder lineBorder = new LineBorder(Color.BLACK, 1);
TitledBorder titledBorder = new TitledBorder(lineBorder, "検索条件");
JPanel panel = new JPanel();
panel.setLayout(null);
JLabel labelBusiness = new JLabel("事業部");
labelBusiness.setLocation(10, 20);
labelBusiness.setSize(54, 18);
panel.add(labelBusiness);
JComboBox comboBoxBusiness = new JComboBox();
String stringBusinessAll = new String("全て");
comboBoxBusiness.addItem(stringBusinessAll);
comboBoxBusiness.setLocation(90, 20);
comboBoxBusiness.setSize(55, 18);
panel.add(comboBoxBusiness);
JLabel labelOrderType = new JLabel("受注タイプ");
labelOrderType.setLocation(170, 20);
labelOrderType.setSize(72, 18);
panel.add(labelOrderType);
JComboBox comboBoxOrderType = new JComboBox();
String stringOrderTypeAll = new String("全て");
comboBoxOrderType.addItem(stringOrderTypeAll);
comboBoxOrderType.setLocation(270, 20);
comboBoxOrderType.setSize(55, 18);
panel.add(comboBoxOrderType);
JLabel labelProductSection = new JLabel("生産部門");
labelProductSection.setLocation(350, 20);
labelProductSection.setSize(72, 18);
panel.add(labelProductSection);
JComboBox comboBoxProductSection = new JComboBox();
String stringProductSectionAll = new String("全て");
comboBoxProductSection.addItem(stringProductSectionAll);
comboBoxProductSection.setLocation(450, 20);
comboBoxProductSection.setSize(55, 18);
panel.add(comboBoxProductSection);
JLabel labelTrade = new JLabel("取引先");
labelTrade.setLocation(10, 60);
labelTrade.setSize(54, 18);
panel.add(labelTrade);
JTextField textFieldTrade = new JTextField();
textFieldTrade.setLocation(90, 60);
textFieldTrade.setSize(100, 18);
panel.add(textFieldTrade);
panel.setBounds(10, 10, 770, 200);
panel.setBorder(titledBorder);
this.add(panel);
// ウィンドウの表示
this.setVisible(true);
}
public void actionPerformed(ActionEvent e){
if(e.getSource() == menuItemQuit){
System.exit(0);
}
}
public static void main(String[] args) {
new Test("Test");
}
}
お礼
お忙しいところご回答頂きありがとうございます。 やはり、各コンポーネットを一つずつ位置の指定と サイズの指定を行う方法なんですね。 それともうひとつお願いなのですがデータの一覧 表示をしている部分(エクセルの表みたいな部分) があると思うのですがそれは、どのように プログラミングしているのでしょうか。 もし、お時間があるようでしたらご回答いただけると ありがたいのですが。