/** A call of this method should validate the positions of the panels components. */ @Override public void relocate() { int w = 480, h = 245; int x = (this.getWidth() - w) / 2, y = (this.getHeight() - h) / 2; diffToolLabel.setLocation(x, y); diffToolField.setLocation(x + 160, y); diffToolLogLevelComboBox.setLocation(x + 380, y); }
public EmployeeCUDialog(JFrame owner, String title) { super(owner); this.setTitle(title); this.setDefaultCloseOperation(WindowConstants.HIDE_ON_CLOSE); this.setLocation(500, 250); this.setSize(200, 300); this.setLayout(null); this.setModal(true); lblName = new JLabel("Name:"); this.add(lblName); lblName.setLocation(20, 10); lblName.setSize(100, 25); txfName = new JTextField(); this.add(txfName); txfName.setLocation(20, 35); txfName.setSize(150, 25); lblWage = new JLabel("Wage:"); this.add(lblWage); lblWage.setLocation(20, 70); lblWage.setSize(100, 25); txfWage = new JTextField(); this.add(txfWage); txfWage.setLocation(20, 95); txfWage.setSize(150, 25); lblCompany = new JLabel("Company:"); this.add(lblCompany); lblCompany.setLocation(20, 130); lblCompany.setSize(100, 25); cbxCompanies = new JComboBox<Company>(); this.add(cbxCompanies); cbxCompanies.setLocation(20, 155); cbxCompanies.setSize(150, 25); cbxCompanies.setMaximumRowCount(4); btnOk = new JButton("Ok"); this.add(btnOk); btnOk.setLocation(15, 225); btnOk.setSize(70, 25); btnOk.addActionListener(controller); btnCancel = new JButton("Cancel"); this.add(btnCancel); btnCancel.setLocation(95, 225); btnCancel.setSize(80, 25); btnCancel.addActionListener(controller); // initialise this view controller.fillCbxCompanies(); }
public JPanel createPanel() { jtMain.setText("Please enter positive integer values"); jtMain.setSize(300, 15); jtMain.setLocation(250, 120); jtMain.setBackground(Color.lightGray); jlCurv.setText("Curvature Scaling Factor"); jlCurv.setSize(200, 30); jlCurv.setLocation(200, 200); jtCurv.setSize(50, 20); jtCurv.setLocation(450, 205); jtCurv.setText(Double.toString(Prefs.getCurvatureScalingFactor())); addWindowListener( new WindowAdapter() { public void windowOpened(WindowEvent e) { jtCurv.requestFocus(); } }); jlSpeed.setText("Speed Scaling Factor"); jlSpeed.setSize(200, 30); jlSpeed.setLocation(200, 250); jtSpeed.setSize(50, 20); jtSpeed.setLocation(450, 255); jtSpeed.setText(Double.toString(Prefs.getSpeedScalingFactor())); jlSegScheme.setText("Segmentation Scheme"); jlSegScheme.setSize(200, 30); jlSegScheme.setLocation(200, 300); jcSegScheme.setSize(150, 20); jcSegScheme.setLocation(450, 305); int index = 0; int segSchemeIndex = Prefs.getSegScheme(); if (segSchemeIndex == 3) { index = 1; } else if (segSchemeIndex == 4) { index = 2; } jcSegScheme.setSelectedIndex(index); JButton jbSet = new JButton(); jbSet.setLocation(275, 450); jbSet.setText("Set Values"); jbSet.setSize(150, 30); jbSet.setActionCommand("set"); jbSet.addActionListener(this); this.setBackground(Color.WHITE); panel.add(jtMain); panel.add(jlCurv); panel.add(jlSpeed); panel.add(jtCurv); panel.add(jtSpeed); panel.add(jbSet); panel.add(jlSegScheme); panel.add(jcSegScheme); return panel; }
public static void show() { frame = new JFrame("Advanced pathfinding"); frame.setSize(800, 720); DrawPanel panel = new DrawPanel(); panel.setSize(700, 700); frame.add(panel); Integer items[] = new Integer[5]; for (int i = 1; i < 6; i++) { items[i - 1] = i; } JComboBox comboBox = new JComboBox(items); JLabel label = new JLabel("Размер объекта:"); panel.add(comboBox); panel.add(label); comboBox.setSize(40, 20); label.setSize(120, 20); comboBox.setLocation(730, 20); label.setLocation(620, 20); comboBox.setVisible(true); label.setVisible(true); ActionListener actionListener = new ActionListener() { @Override public void actionPerformed(ActionEvent e) { JComboBox box = (JComboBox) e.getSource(); Integer item = (Integer) box.getSelectedItem(); panel.size = item; panel.aim = null; } }; MouseListener mouseListener = new MouseListener() { int tick = 0; Cell aim; @Override public void mouseClicked(MouseEvent e) { if ((e.getX() > 600) || (e.getY() > 600)) { return; } aim = new Cell(e.getX() / panel.grid.cSize, e.getY() / panel.grid.cSize); panel.aim = aim; } @Override public void mousePressed(MouseEvent e) {} @Override public void mouseReleased(MouseEvent e) {} @Override public void mouseEntered(MouseEvent e) {} @Override public void mouseExited(MouseEvent e) {} }; frame.setVisible(true); frame.setDefaultCloseOperation(EXIT_ON_CLOSE); panel.addMouseListener(mouseListener); comboBox.addActionListener(actionListener); }
MovieAdd() { setTitle("Dodaj Film"); setSize(300, 355); setDefaultCloseOperation(JFrame.HIDE_ON_CLOSE); this.setResizable(false); setLayout(null); frame = this; /** ***************************************************** */ Mov = DataBase.getInstance().getMoviesDao(); Cat = DataBase.getInstance().getCategoriesDao(); CatMov = DataBase.getInstance().getCatMovDao(); Vector<String> catNamesList = DataBase.returnCategoriesList(); /** ******************************************************* */ categories = new JComboBox(catNamesList); label1.setLocation(10, 10); label1.setSize(60, 25); categories.setLocation(80, 10); categories.setSize(200, 25); label2.setLocation(10, 50); label2.setSize(60, 25); name.setLocation(80, 50); name.setSize(200, 25); label3.setLocation(10, 90); label3.setSize(60, 25); desc.setLocation(80, 90); desc.setSize(200, 150); desc.setFont(new Font("Dialog", Font.PLAIN, 12)); label4.setLocation(10, 250); label4.setSize(60, 25); fileButton.setLocation(80, 250); fileButton.setSize(200, 25); button.setLocation(220, 290); button.setSize(60, 25); add(label1); add(categories); add(label2); add(name); add(label3); add(desc); add(label4); add(fileButton); add(button); fileButton.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { int returnVal = fileChooser.showOpenDialog(frame); if (returnVal == JFileChooser.APPROVE_OPTION) { choosenFileName = fileChooser.getSelectedFile().getAbsolutePath(); } } }); button.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { Movies newMovie = new Movies(); newMovie.setName(name.getText()); newMovie.setContent(desc.getText()); newMovie.setFile(choosenFileName); newMovie.setCreated(new Date()); try { Mov.create(newMovie); } catch (SQLException ex) { System.out.println("Błąd przy zapisywaniu nowego filmu... MovieAdd " + ex); } String catName = (String) categories.getSelectedItem(); Categories category = new Categories(); try { category = Cat.queryForEq("name", catName).get(0); } catch (SQLException ex) { System.out.println("Błąd przy szukaniu kategorii... MovieAdd " + ex); } CatMovies catMovLink = new CatMovies(); catMovLink.setMovie(newMovie); catMovLink.setCategory(category); try { CatMov.create(catMovLink); } catch (SQLException ex) { System.out.println("Błąd przy zapisywaniu kategoria-film... MovieAdd " + ex); } frame.setVisible(false); } }); }
public BurtgehHuudas() { super("Бүртгэл хуудас"); Container con = getContentPane(); con.setLayout(null); // haryalagdah tenhim JLabel lbl1 = new JLabel("Харъяалагдах тэнхим:"); lbl1.setLocation(30, 30); lbl1.setSize(200, 30); con.add(lbl1); JComboBox combo1 = new JComboBox(); try { String s = "SELECT * FROM tenhim"; ResultSet rs = DatabaseTools.runQuery(s); while (rs.next()) { combo1.addItem(rs.getString(2)); } } catch (Exception e) { } combo1.setLocation(200, 30); combo1.setSize(200, 30); con.add(combo1); JLabel lb1 = new JLabel("Сонгоно уу?"); lb1.setLocation(450, 30); lb1.setSize(200, 30); con.add(lb1); // oyutanii code JLabel lbl2 = new JLabel("Код:"); lbl2.setLocation(30, 70); lbl2.setSize(200, 30); con.add(lbl2); JTextField txt1 = new JTextField(); txt1.setLocation(200, 70); txt1.setSize(200, 30); con.add(txt1); JLabel lb2 = new JLabel("Жишээ нь:SW001"); lb2.setLocation(450, 70); lb2.setSize(200, 30); con.add(lb2); // oyutanii ovog JLabel lbl3 = new JLabel("Овог:"); lbl3.setLocation(30, 110); lbl3.setSize(200, 30); con.add(lbl3); JTextField txt2 = new JTextField(); txt2.setLocation(200, 110); txt2.setSize(200, 30); con.add(txt2); JLabel lb3 = new JLabel("18 тэмдэгт"); lb3.setLocation(450, 110); lb3.setSize(200, 30); con.add(lb3); // oyutanii ner JLabel lbl4 = new JLabel("Нэр:"); lbl4.setLocation(30, 150); lbl4.setSize(200, 30); con.add(lbl4); JTextField txt3 = new JTextField(); txt3.setLocation(200, 150); txt3.setSize(200, 30); con.add(txt3); JLabel lb4 = new JLabel("18 тэмдэгт"); lb4.setLocation(450, 150); lb4.setSize(200, 30); con.add(lb4); // nuuts ug JLabel lbl5 = new JLabel("Нууц үг:"); lbl5.setLocation(30, 190); lbl5.setSize(200, 30); con.add(lbl5); JPasswordField pass1 = new JPasswordField(); pass1.setLocation(200, 190); pass1.setSize(200, 30); con.add(pass1); JLabel lb5 = new JLabel("Ихдээ 10 тэмдэгт"); lb5.setLocation(450, 190); lb5.setSize(200, 30); con.add(lb5); // nuuts ug davtalt JLabel lbl6 = new JLabel("Нууц үг давталт:"); lbl6.setLocation(30, 230); lbl6.setSize(200, 30); con.add(lbl6); JPasswordField pass2 = new JPasswordField(); pass2.setLocation(200, 230); pass2.setSize(200, 30); con.add(pass2); // huis JLabel lbl7 = new JLabel("Хүйс:"); lbl7.setLocation(30, 270); lbl7.setSize(200, 30); con.add(lbl7); JRadioButton rd1 = new JRadioButton("Эр"); rd1.setLocation(200, 270); rd1.setSize(50, 30); con.add(rd1); JRadioButton rd2 = new JRadioButton("Эм"); rd2.setLocation(260, 270); rd2.setSize(50, 30); con.add(rd2); ButtonGroup huisGroup = new ButtonGroup(); huisGroup.add(rd1); huisGroup.add(rd2); JLabel lb7 = new JLabel("Сонгодог байх"); lb7.setLocation(450, 270); lb7.setSize(200, 30); con.add(lb7); // elssen on JLabel lbl8 = new JLabel("Элссэн он:"); lbl8.setLocation(30, 310); lbl8.setSize(200, 30); con.add(lbl8); JTextField txt5 = new JTextField(); txt5.setLocation(200, 310); txt5.setSize(200, 30); con.add(txt5); JLabel lb8 = new JLabel("Жишээ:2011"); lb8.setLocation(450, 310); lb8.setSize(200, 30); con.add(lb8); // tsagiin/undsen JLabel lbl9 = new JLabel("Цагийн/Үндсэн:"); lbl9.setLocation(30, 350); lbl9.setSize(200, 30); con.add(lbl9); JCheckBox ch1 = new JCheckBox("Цаг"); ch1.setLocation(200, 340); ch1.setSize(50, 50); con.add(ch1); JCheckBox ch2 = new JCheckBox("Үндсэн"); ch2.setLocation(250, 340); ch2.setSize(80, 50); con.add(ch2); ButtonGroup checkgroup = new ButtonGroup(); checkgroup.add(ch1); checkgroup.add(ch2); JLabel lb9 = new JLabel("Олныг сонгож болох"); lb9.setLocation(450, 350); lb9.setSize(200, 30); con.add(lb9); // zereg JLabel lbl10 = new JLabel("Зэрэг:"); lbl10.setLocation(30, 390); lbl10.setSize(200, 30); con.add(lbl10); JComboBox combo2 = new JComboBox(); try { String s = "SELECT * FROM zereg"; ResultSet rs = DatabaseTools.runQuery(s); while (rs.next()) { combo2.addItem(rs.getString(2)); } } catch (Exception e) { } combo2.setLocation(200, 390); combo2.setSize(200, 30); con.add(combo2); // torol JLabel lbl11 = new JLabel("Төрөл:"); lbl11.setLocation(30, 430); lbl11.setSize(200, 30); con.add(lbl11); String str3[] = { "Захирал", "Бакалавр1", "Бакалавр2", "Бакалавр3", "Бакалавр4", }; JComboBox combo3 = new JComboBox(str3); combo3.setLocation(200, 430); combo3.setSize(200, 30); con.add(combo3); // geriin utas JLabel lbl12 = new JLabel("Гэрийн утас:"); lbl12.setLocation(30, 470); lbl12.setSize(200, 30); con.add(lbl12); JTextField txt6 = new JTextField(); txt6.setLocation(200, 470); txt6.setSize(200, 30); con.add(txt6); JLabel lb12 = new JLabel("Ихдээ 20 тэмдэгт"); lb12.setLocation(450, 470); lb12.setSize(200, 30); con.add(lb12); // gar utas JLabel lbl13 = new JLabel("Гар утас:"); lbl13.setLocation(30, 510); lbl13.setSize(200, 30); con.add(lbl13); JTextField txt7 = new JTextField(); txt7.setLocation(200, 510); txt7.setSize(200, 30); con.add(txt7); JLabel lb13 = new JLabel("Ихдээ 20 тэмдэгт"); lb13.setLocation(450, 510); lb13.setSize(200, 30); con.add(lb13); // geriin hayag JLabel lbl14 = new JLabel("Гэрийн хаяг:"); lbl14.setLocation(30, 550); lbl14.setSize(200, 30); con.add(lbl14); JTextArea ta1 = new JTextArea(); ta1.setLocation(200, 550); ta1.setSize(250, 90); con.add(ta1); JLabel lb14 = new JLabel("Ихдээ 200 тэмдэгт"); lb14.setLocation(500, 550); lb14.setSize(200, 30); con.add(lb14); // mail hayag JLabel lbl15 = new JLabel("Майл хаяг:"); lbl15.setLocation(30, 650); lbl15.setSize(200, 30); con.add(lbl15); JTextField txt8 = new JTextField(); txt8.setLocation(200, 650); txt8.setSize(200, 30); con.add(txt8); JLabel lb15 = new JLabel("Ихдээ 100 тэмдэгт"); lb15.setLocation(450, 650); lb15.setSize(200, 30); con.add(lb15); // torson odor JLabel lbl16 = new JLabel("Төрсөн өдөр:"); lbl16.setLocation(30, 690); lbl16.setSize(200, 30); con.add(lbl16); String year1[] = new String[116]; for (int on = 0; on < 116; on++) { year1[on] = Integer.toString(1900 + on); } JComboBox year = new JComboBox(year1); year.setMaximumRowCount(8); year.setLocation(200, 690); year.setSize(60, 30); con.add(year); JLabel lbl161 = new JLabel("Он"); lbl161.setLocation(265, 690); lbl161.setSize(30, 30); con.add(lbl161); String month1[] = new String[12]; for (int sar = 0; sar < 12; sar++) { month1[sar] = Integer.toString(1 + sar); } JComboBox month = new JComboBox(month1); month.setMaximumRowCount(8); month.setLocation(290, 690); month.setSize(60, 30); con.add(month); JLabel lbl162 = new JLabel("Сар"); lbl162.setLocation(355, 690); lbl162.setSize(30, 30); con.add(lbl162); String day1[] = new String[31]; for (int odor = 0; odor < 31; odor++) { day1[odor] = Integer.toString(1 + odor); } JComboBox day = new JComboBox(day1); day.setLocation(385, 690); day.setSize(60, 30); con.add(day); JLabel lbl163 = new JLabel("Өдөр"); lbl163.setLocation(450, 690); lbl163.setSize(50, 30); con.add(lbl163); JLabel lb16 = new JLabel("3-н combobox байх"); lb16.setForeground(Color.red); lb16.setLocation(550, 690); lb16.setSize(200, 30); con.add(lb16); // nemeh JButton bt1 = new JButton("Нэмэх"); bt1.setForeground(Color.blue); bt1.setLocation(600, 30); bt1.setSize(100, 40); bt1.addActionListener( ae -> { String stuLastName = txt2.getText(); String stuFirstName = txt3.getText(); String huis; if (rd1.isSelected()) huis = "эр"; else huis = "эм"; String elssenOn = txt5.getText(); String address = ta1.getText(); String phone = txt7.getText(); String mail = txt8.getText(); String code = txt1.getText(); String query1 = "insert into student(stu_lastname, stu_firstname,stu_sex,stu_elssenOn,stu_address,stu_phone,stu_mail,stu_code)" + "values('" + stuLastName + "','" + stuFirstName + "','" + huis + "','" + elssenOn + "','" + address + "','" + phone + "','" + mail + "','" + code + "')"; DatabaseTools.runQuery(query1); JOptionPane.showMessageDialog(null, "Амжилттай нэмэгдлээ."); this.dispose(); }); con.add(bt1); // tseverleh JButton bt4 = new JButton("Цэвэрлэх"); bt4.setForeground(Color.blue); bt4.setLocation(600, 180); bt4.setSize(100, 40); con.add(bt4); setLocation(800, 350); setSize(750, 800); setVisible(true); setResizable(false); }
/** * Constructs the dialog window * * @param p Parent GUI */ public RegionEditorDialog(MapEditorGUI p) { parent = p; setLayout(null); /* * Initialize naming field */ JLabel l = new JLabel("Name"); l.setSize(l.getPreferredSize()); l.setLocation(10, 10); nameField = new JTextField("plains"); nameField.setSize(200, 24); nameField.setLocation(10, 32); add(l); add(nameField); /* * Initialize encounter spinner */ l = new JLabel("Encounter rate"); l.setSize(l.getPreferredSize()); l.setLocation(10, 64); eRateSpinner = new JSpinner(new SpinnerNumberModel(1, 1, 20, 1)); eRateSpinner.setSize(eRateSpinner.getPreferredSize()); eRateSpinner.setLocation(210 - eRateSpinner.getWidth(), 62); add(l); add(eRateSpinner); /* * Initialize Terrain selector */ l = new JLabel("Terrain"); l.setSize(l.getPreferredSize()); l.setLocation(10, 96); terrain = new JComboBox(ToolKit.terrains); terrain.setSize(200, 24); terrain.setLocation(10, 120); add(l); add(terrain); /* * Initialize formation list */ l = new JLabel("Formations"); l.setSize(l.getPreferredSize()); l.setLocation(10, 156); fList = new JList(formations); fPane = new JScrollPane(fList); fPane.setSize(200, 160); fPane.setLocation(10, 172); add(l); add(fPane); /* * Initialize buttons */ okButton = new JButton("OK"); okButton.setSize(80, 24); okButton.setLocation(20, 380); okButton.addActionListener(this); cancelButton = new JButton("Cancel"); cancelButton.setSize(80, 24); cancelButton.setLocation(120, 380); cancelButton.addActionListener(this); add(okButton); add(cancelButton); fRemButton = new JButton("-"); fRemButton.setSize(fRemButton.getPreferredSize()); fRemButton.setLocation(210 - fRemButton.getWidth(), 335); fAddButton = new JButton("+"); fAddButton.setSize(fAddButton.getPreferredSize()); fAddButton.setLocation(fRemButton.getX() - fAddButton.getWidth(), 335); fEdtButton = new JButton("Edit"); fEdtButton.setSize(100, 24); fEdtButton.setLocation(10, 335); fAddButton.addActionListener(this); fRemButton.addActionListener(this); fEdtButton.addActionListener(this); add(fAddButton); add(fRemButton); add(fEdtButton); /* * Initialize dialog window */ setSize(230, 450); setVisible(true); setModal(true); setResizable(false); setTitle("Region Editor"); setLocationRelativeTo(parent); }
private void showSettingsMenu() { JCheckBox snd = new JCheckBox("Музыка"); snd.setSize(310, 75); snd.setSelected(Commons.PLAY_MUSIC); snd.setLocation(Commons.WIDTH / 2 - 310 / 2, 230); snd.setForeground(Color.GREEN); snd.setFont(new Font("arial", 0, 40)); snd.setBorderPainted(false); snd.setFocusPainted(false); snd.setContentAreaFilled(false); snd.addActionListener( new ActionListener() { @Override public void actionPerformed(ActionEvent e) { Commons.PLAY_MUSIC = snd.isSelected(); } }); String[] items = {"Легкая", "Средняя", "Сложная", "Невозможная"}; JComboBox<String> list = new JComboBox<String>(items); switch (Commons.DIFFICULTY) { case Commons.EASY_DIFFICULTY_CLOUDS_CNT: list.setSelectedIndex(0); break; case Commons.MEDIUM_DIFFICULTY_CLOUDS_CNT: list.setSelectedIndex(1); break; case Commons.HARD_DIFFICULTY_CLOUDS_CNT: list.setSelectedIndex(2); break; case Commons.IMPOSSIBLE_DIFFICULTY_CLOUDS_CNT: list.setSelectedIndex(3); break; } list.setSize(310, 40); list.setLocation(Commons.WIDTH / 2 - 310 / 2, 430); list.addActionListener( new ActionListener() { @Override public void actionPerformed(ActionEvent e) { int st = list.getSelectedIndex(); switch (st) { case 0: Commons.DIFFICULTY = Commons.EASY_DIFFICULTY_CLOUDS_CNT; break; case 1: Commons.DIFFICULTY = Commons.MEDIUM_DIFFICULTY_CLOUDS_CNT; break; case 2: Commons.DIFFICULTY = Commons.HARD_DIFFICULTY_CLOUDS_CNT; break; case 3: Commons.DIFFICULTY = Commons.IMPOSSIBLE_DIFFICULTY_CLOUDS_CNT; break; } } }); add(list); JLabel diff_lbl = new JLabel(); diff_lbl.setText("Сложность:"); diff_lbl.setFont(new Font("serif", 0, 40)); diff_lbl.setForeground(Color.GREEN); diff_lbl.setSize(300, 75); diff_lbl.setLocation(list.getLocation().x, list.getLocation().y - 100); add(diff_lbl); JButton back = new JButton("Назад"); back.setSize(190, 75); back.setLocation(Commons.WIDTH / 2 - 190 / 2, Commons.HEIGHT - 150); back.setForeground(Color.GREEN); back.setBorderPainted(false); back.setFocusPainted(false); back.setContentAreaFilled(false); back.setFont(new Font("serif", 0, 40)); back.addActionListener(ev -> showMainMenu()); add(back); add(snd); }