/** Create and add Clippy's output text */ public void addClippyTxt() { clippyTxt.setLineWrap(true); clippyTxt.setWrapStyleWord(true); clippyTxt.setEditable(false); clippyTxt.setFont(txtFont); clippyTxt.setAlignmentX(JTextArea.CENTER_ALIGNMENT); clippyTxt.setAlignmentY(JTextArea.CENTER_ALIGNMENT); clippyTxt.setBorder(null); clippyTxt.setSize(105, 35); clippyTxt.setLocation(25, 45); clippyTxt.setOpaque(false); lpane.add(clippyTxt, new Integer(1), 0); }
public GraphicsUI() { questionPool = new QuestionPool(); setTitle("Question Pool"); setSize(WIDTH, HEIGHT); fileL = new JLabel("Location of Question Pool File:"); fileTF = new JTextField(10); checkB = new JButton("Check File"); log = new JTextArea(6, 30); Container pane = getContentPane(); pane.setLayout(null); // set locations and sizes for the elements fileL.setLocation(90, 15); fileL.setSize(ELEMENT_WIDTH, 30); fileTF.setLocation(90, 65); fileTF.setSize(ELEMENT_WIDTH, 30); checkB.setLocation(90, 105); checkB.setSize(300, 35); log.setLocation(90, 145); log.setSize(300, 30); // add listener to button CheckButtonHandler cbHandler = new CheckButtonHandler(); checkB.addActionListener(cbHandler); fileTF.addActionListener(cbHandler); // add elements to pane pane.add(fileL); pane.add(fileTF); pane.add(checkB); pane.add(log); setLocation(100, 60); setVisible(true); setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE); }
private void initialize() { panel = new JPanel(); frame = new JFrame(); can.addMouseListener( new MouseAdapter() { @Override public void mouseClicked(MouseEvent e) { PointerInfo a = MouseInfo.getPointerInfo(); Point b = a.getLocation(); double x = b.getX(); double y = b.getY(); System.out.println("Entered x: " + x); System.out.println("Entered y: " + y); if (x == 950) { x = 0; } else if (x < 950) { x = (x / 950) - 1; } else if (x > 950) { x = (x / 950) - 1; } if (y == 563) { y = 0; } else if (y < 563) { y = 1 - (y / 563); } else if (y > 563) { y = 1 - (y / 563); } System.out.println("NEW NEW NEW NEW x: " + x); System.out.println("NEW NEW NEW NEW y: " + y); double inc = -2; var = new ArrayList<Double>(); for (int i = -200; i < 200; i++) { var.add(new Equation(x, y).setEquationReturn(inc)); inc = inc + .01; } double paintInc = -2; for (int dx = 0; dx < 200; dx++) { double dy = var.get(dx); theG.add(new Ellipse2D.Double(0 + paintInc, 540 - dy, 10, 10)); paintInc = paintInc + 10; } /*This is to display the Y values for testing purposes Iterator<Double> it = var.iterator(); while (it.hasNext()){ System.out.println(it.next()); }*/ can.repaint(); } }); JLabel xL = new JLabel(); JLabel yL = new JLabel(); JTextArea a = new JTextArea(); a.setLocation(540, 540); a.setText("FFFFFFFFFFFUCK"); a.setBackground(Color.white); yL.setText("Y"); xL.setText("X"); yL.setLocation(930, 10); yL.setSize(10, 10); yL.setBackground(Color.black); xL.setLocation(1900, 550); xL.setSize(10, 10); xL.setBackground(Color.black); xL.setOpaque(true); yL.setOpaque(true); panel.setBackground(Color.darkGray); can.setBackground(Color.black); can.setForeground(Color.black); frame.getContentPane().add(can); panel.setLayout(new GridLayout(1, 0, 0, 0)); frame.add(xL); frame.add(yL); frame.add(can); frame.setBounds(0, 0, 1920, 1080); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); }
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); } }); }