public void setOutputPanel() { BoxLayout box = new BoxLayout(output, BoxLayout.Y_AXIS); output.setLayout(box); Color c1 = new Color(166, 209, 241); Color c2 = new Color(204, 210, 211); JLabel label3 = new JLabel("Messaggi interni:"); output.add(label3); outp.setBackground(c1); outp.setAutoscrolls(true); outp.setEditable(false); intmsg.setBackground(c2); intmsg.setAutoscrolls(true); intmsg.setEditable(false); output.add(scrollPaneM); JLabel label4 = new JLabel("Output:"); output.add(label4); output.add(scrollPaneO); output.setBorder(BorderFactory.createEtchedBorder()); }
public ScrapeView() { this.setMaximumSize(new Dimension(Integer.MAX_VALUE, Integer.MAX_VALUE)); GridBagLayout layout = new GridBagLayout(); this.setLayout(layout); GridBagConstraints constraint = new GridBagConstraints(); constraint.insets = new Insets(3, 3, 3, 3); constraint.weightx = 1; constraint.weighty = 0; constraint.gridwidth = 1; constraint.anchor = GridBagConstraints.CENTER; { websiteDataUrlLabel = new JLabel("Website data URL:"); constraint.weightx = 0; constraint.weighty = 0; constraint.gridx = 0; constraint.gridy = 0; constraint.gridwidth = 1; constraint.gridheight = 1; constraint.fill = GridBagConstraints.BOTH; this.add(websiteDataUrlLabel, constraint); } { websiteDataUrlTextField = new JTextField(""); websiteDataUrlTextField .getDocument() .addDocumentListener( new DocumentListener() { @Override public void insertUpdate(DocumentEvent e) { try { String str = e.getDocument().getText(0, e.getDocument().getLength()); if (str.contains("motel6.com")) { parserComboBox.setSelectedIndex(0); } else if (str.contains("redroof.com")) { parserComboBox.setSelectedIndex(1); } else if (str.contains("redlion.com")) { parserComboBox.setSelectedIndex(2); } } catch (BadLocationException exception) { logger.error(exception); } } @Override public void removeUpdate(DocumentEvent e) {} @Override public void changedUpdate(DocumentEvent e) {} }); constraint.weightx = 1; constraint.weighty = 0; constraint.gridx = 1; constraint.gridy = 0; constraint.gridwidth = 1; constraint.gridheight = 1; constraint.fill = GridBagConstraints.BOTH; this.add(websiteDataUrlTextField, constraint); } { browserEngineLabel = new JLabel("Browser engine:"); constraint.weightx = 0; constraint.weighty = 0; constraint.gridx = 0; constraint.gridy = 1; constraint.gridwidth = 1; constraint.gridheight = 1; constraint.fill = GridBagConstraints.BOTH; this.add(browserEngineLabel, constraint); } { String[] values = new String[] {"HtmlUnit", "Ui4j", "JxBrowser"}; browserEngineComboBox = new JComboBox<>(values); browserEngineComboBox.setSelectedIndex(2); constraint.weightx = 1; constraint.weighty = 0; constraint.gridx = 1; constraint.gridy = 1; constraint.gridwidth = 1; constraint.gridheight = 1; constraint.fill = GridBagConstraints.BOTH; this.add(browserEngineComboBox, constraint); } { parserLabel = new JLabel("Website parser:"); constraint.weightx = 0; constraint.weighty = 0; constraint.gridx = 0; constraint.gridy = 2; constraint.gridwidth = 1; constraint.gridheight = 1; constraint.fill = GridBagConstraints.BOTH; this.add(parserLabel, constraint); } { String[] values = new String[] {"Motel6", "RedRoof", "RedLion"}; parserComboBox = new JComboBox<>(values); parserComboBox.setSelectedIndex(0); constraint.weightx = 1; constraint.weighty = 0; constraint.gridx = 1; constraint.gridy = 2; constraint.gridwidth = 1; constraint.gridheight = 1; constraint.fill = GridBagConstraints.BOTH; this.add(parserComboBox, constraint); } { scrapeButton = new JButton("Scrape website"); constraint.weightx = 1; constraint.weighty = 0; constraint.gridx = 0; constraint.gridy = 3; constraint.gridwidth = 2; constraint.gridheight = 1; constraint.fill = GridBagConstraints.BOTH; this.add(scrapeButton, constraint); } { outputTextArea = new JTextArea(); outputTextArea.setEditable(false); outputTextArea.setWrapStyleWord(false); outputTextArea.setAutoscrolls(true); JScrollPane scrollPane = new JScrollPane(outputTextArea); scrollPane.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED); scrollPane.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED); scrollPane.setMaximumSize(new Dimension(Integer.MAX_VALUE, Integer.MAX_VALUE)); constraint.weightx = 1; constraint.weighty = 1; constraint.gridx = 0; constraint.gridy = 4; constraint.gridwidth = 2; constraint.gridheight = 1; constraint.fill = GridBagConstraints.BOTH; this.add(scrollPane, constraint); } { progressBar = new JProgressBar(); progressBar.setString(progressBarTextPrefix); progressBar.setStringPainted(true); progressBar.setIndeterminate(true); progressBar.setVisible(false); constraint.weightx = 1; constraint.weighty = 0; constraint.gridx = 0; constraint.gridy = 5; constraint.gridwidth = 2; constraint.gridheight = 1; constraint.fill = GridBagConstraints.BOTH; this.add(progressBar, constraint); } }
public JChat() { this.setSize(500, 600); this.setResizable(false); this.setLayout(new BorderLayout()); JPanel topPanel = new JPanel(); topPanel.setLayout(new GridLayout(2, 1)); // set up buttons openChat = new JButton("Open to chat"); openChat.addActionListener(new OpenChat()); chatWith = new JButton("Chat with"); chatWith.addActionListener(new ChatWith()); send = new JButton("send"); send.addActionListener(new Send()); send.setEnabled(false); InputMap inputMap = send.getInputMap(JButton.WHEN_IN_FOCUSED_WINDOW); KeyStroke enter = KeyStroke.getKeyStroke(KeyEvent.VK_ENTER, 0); inputMap.put(enter, "ENTER"); send.getActionMap().put("ENTER", new ClickAction(send)); // set up labels pickPort = new JLabel(); pickPort.setText("Pick your port number:"); desPort = new JLabel(); desPort.setText("Or enter a destinaltion port number:"); // set up text fields pickText = new JTextField(); pickText.setPreferredSize(new Dimension(150, 30)); desText = new JTextField(); desText.setPreferredSize(new Dimension(150, 30)); chatText = new JTextField(); chatText.setPreferredSize(new Dimension(400, 30)); chatText.setEnabled(false); JPanel top1 = new JPanel(); top1.add(pickPort); top1.add(pickText); top1.add(openChat); JPanel top2 = new JPanel(); top2.add(desPort); top2.add(desText); top2.add(chatWith); topPanel.add(top1); topPanel.add(top2); chatField = new JTextArea(); chatField.setAutoscrolls(true); chatField.setDragEnabled(true); chatField.setEditable(false); chatField.setAlignmentY(TOP_ALIGNMENT); JPanel bottomPanel = new JPanel(); bottomPanel.add(chatText); bottomPanel.add(send); this.add(topPanel, BorderLayout.NORTH); this.add(chatField, BorderLayout.CENTER); this.add(bottomPanel, BorderLayout.SOUTH); this.setVisible(true); this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); }
public void initComponents() { setDefaultCloseOperation(JFrame.HIDE_ON_CLOSE); setBounds(100, 100, 902, 597); contentPane = new JPanel(); contentPane.setBorder(new EmptyBorder(5, 5, 5, 5)); setContentPane(contentPane); contentPane.setLayout(null); panel_4 = new JPanel(); panel_4.setBorder( new TitledBorder( new LineBorder(new Color(0, 0, 0)), "Geral", TitledBorder.LEFT, TitledBorder.TOP, null, null)); panel_4.setBounds(10, 11, 426, 236); contentPane.add(panel_4); panel_4.setLayout(null); lblModeloDoAutomato = new JLabel("Defini\u00E7\u00E3o do Automato:"); lblModeloDoAutomato.setBounds(10, 47, 125, 14); panel_4.add(lblModeloDoAutomato); JScrollPane scrollPane_2 = new JScrollPane(); scrollPane_2.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_ALWAYS); scrollPane_2.setBounds(10, 72, 406, 124); panel_4.add(scrollPane_2); textArea = new JTextArea(); textArea.setColumns(100); scrollPane_2.setColumnHeaderView(textArea); textArea.setAutoscrolls(true); textArea.setRows(9); JButton btnMinimizar = new JButton("Minimizar"); btnMinimizar.addActionListener( new ActionListener() { @Override public void actionPerformed(ActionEvent arg0) { minimizarAutomato(); } }); btnMinimizar.setBounds(10, 207, 104, 23); panel_4.add(btnMinimizar); JPanel panel = new JPanel(); panel.setBounds(10, 15, 250, 25); panel_4.add(panel); panel.setBorder(null); panel.setLayout(null); JLabel lblNome = new JLabel("Criar estado:"); lblNome.setBounds(10, 5, 82, 14); panel.add(lblNome); lblNome.setHorizontalAlignment(SwingConstants.CENTER); isfinal = new JCheckBox("Final"); isfinal.setBounds(98, 1, 56, 23); panel.add(isfinal); btnNovo = new JButton("Novo"); btnNovo.setBounds(160, 1, 73, 23); panel.add(btnNovo); btnNovo.addActionListener( new ActionListener() { @Override public void actionPerformed(ActionEvent e) { novoEstado(); } }); JPanel panel_5 = new JPanel(); panel_5.setBorder( new TitledBorder( new LineBorder(new Color(0, 0, 0)), "Visualiza\u00E7\u00E3o", TitledBorder.LEADING, TitledBorder.TOP, null, null)); panel_5.setBounds(10, 258, 1310, 390); contentPane.add(panel_5); panel_5.setLayout(null); painelView = new JPanelVisualizacao(this); painelView.setBounds(10, 22, 1290, 357); panel_5.add(painelView); JPanel panel_2 = new JPanel(); panel_2.setBounds(558, 11, 314, 251); contentPane.add(panel_2); panel_2.setLayout(null); lblNewLabel = new JLabel("Detalhes de "); lblNewLabel.setBounds(10, 11, 152, 14); panel_2.add(lblNewLabel); cbisFinal = new JCheckBox("Final"); cbisFinal.addMouseListener( new MouseAdapter() { @Override public void mouseClicked(MouseEvent arg0) { turnFinal(); } }); cbisFinal.setBounds(168, 7, 60, 23); panel_2.add(cbisFinal); btnExcluir = new JButton("Excluir"); btnExcluir.addActionListener( new ActionListener() { @Override public void actionPerformed(ActionEvent e) { excluirEstado(); } }); btnExcluir.setBounds(231, 7, 73, 23); panel_2.add(btnExcluir); panel_3 = new JPanel(); panel_3.setBorder( new TitledBorder( new LineBorder(new Color(0, 0, 0)), "Transi\u00E7\u00F5es", TitledBorder.LEADING, TitledBorder.TOP, null, null)); panel_3.setBounds(10, 36, 294, 204); panel_2.add(panel_3); panel_3.setLayout(null); JLabel lblSimbolo = new JLabel("Simbolo:"); lblSimbolo.setBounds(10, 29, 96, 14); panel_3.add(lblSimbolo); cbAlfabeto = new JComboBox(); cbAlfabeto.setBounds(122, 26, 49, 20); panel_3.add(cbAlfabeto); JLabel lblEstadosDestinos = new JLabel("Estados Destinos:"); lblEstadosDestinos.setBounds(10, 57, 96, 14); panel_3.add(lblEstadosDestinos); cbEstadosDestinos = new JComboBox(); cbEstadosDestinos.setBounds(122, 54, 49, 20); panel_3.add(cbEstadosDestinos); JScrollPane scrollPane_1 = new JScrollPane(); scrollPane_1.setBounds(10, 82, 274, 111); panel_3.add(scrollPane_1); tblTrans = new JTable(); scrollPane_1.setViewportView(tblTrans); btnNova = new JButton("Nova"); btnNova.addActionListener( new ActionListener() { @Override public void actionPerformed(ActionEvent e) { novaTransicao(); } }); btnNova.setBounds(181, 25, 89, 23); panel_3.add(btnNova); btnRemover = new JButton("Remover"); btnRemover.addActionListener( new ActionListener() { @Override public void actionPerformed(ActionEvent e) { removerTransicao(); } }); btnRemover.setBounds(181, 53, 89, 23); panel_3.add(btnRemover); JPanel panel_1 = new JPanel(); panel_1.setBorder( new TitledBorder( new LineBorder(new Color(0, 0, 0)), "Estados", TitledBorder.LEADING, TitledBorder.TOP, null, null)); panel_1.setBounds(446, 11, 102, 236); contentPane.add(panel_1); panel_1.setLayout(null); JScrollPane scrollPane = new JScrollPane(); scrollPane.setBounds(10, 26, 82, 199); panel_1.add(scrollPane); tblEstados = new JTable(); scrollPane.setViewportView(tblEstados); tblEstados.addMouseListener( new MouseAdapter() { @Override public void mouseClicked(MouseEvent arg0) { selecionaEstadoAtual(a.getEstados().get(tblEstados.getSelectedRow())); } }); tblEstados.setAutoscrolls(true); tblEstados.add(new Scrollbar()); }
private void initializeComponents() { this.setTitle("Synchro - Kopierassistent"); this.setBounds(0, 0, 550, 600); this.setResizable(true); this.setLayout(null); this.setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE); this.addWindowListener(this); mainPanel = new JPanel(); mainPanel.setBounds(0, 0, this.getWidth() - 20, 25); // fcPanel.setBorder(BorderFactory.createLineBorder(Color.BLACK)); mainPanel.setLayout(null); btnBackup = new JButton("Backup"); btnBackup.setBounds(this.getWidth() / 2, 0, this.getWidth() / 2 - 20, mainPanel.getHeight()); btnBackup.addActionListener(this); mainPanel.add(btnBackup); this.add(mainPanel); fcPanel = new JPanel(); fcPanel.setBounds(10, 40, this.getWidth(), 260); // fcPanel.setBorder(BorderFactory.createLineBorder(Color.BLACK)); fcPanel.setLayout(null); quellLabel = new JLabel("Bitte Quellverzeichnis auswählen"); quellLabel.setBounds(10, 5, 320, 20); fcPanel.add(quellLabel); quellListModel = new DefaultListModel<>(); quellJList = new JList<ListItem>(quellListModel); quellJList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); quellJList.setLayoutOrientation(JList.VERTICAL); quellJList.addListSelectionListener(this); listBoxScroller = new JScrollPane(quellJList); listBoxScroller.setBounds(0, 30, 315, 100); fcPanel.add(listBoxScroller); btnQAuswahl = new JButton("Quellverz. hinzufügen"); btnQAuswahl.setBounds(320, 30, 200, 25); btnQAuswahl.addActionListener(this); fcPanel.add(btnQAuswahl); btnQEntfernen = new JButton("Quellverz. entfernen"); btnQEntfernen.setBounds(320, 60, 200, 25); btnQEntfernen.addActionListener(this); fcPanel.add(btnQEntfernen); zielLabel = new JLabel("Bitte Zielverzeichnis auswählen"); zielLabel.setBounds(10, 135, 320, 20); fcPanel.add(zielLabel); zielListModel = new DefaultListModel<>(); zielJList = new JList<ListItem>(zielListModel); zielJList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); zielJList.setLayoutOrientation(JList.VERTICAL); zielJList.addListSelectionListener(this); listBoxScroller2 = new JScrollPane(zielJList); listBoxScroller2.setBounds(0, 160, 315, 100); fcPanel.add(listBoxScroller2); btnZAuswahl = new JButton("Zielverz. hinzufügen"); btnZAuswahl.setBounds(320, 160, 200, 25); btnZAuswahl.addActionListener(this); fcPanel.add(btnZAuswahl); btnZEntfernen = new JButton("Zielverz. entfernen"); btnZEntfernen.setBounds(320, 190, 200, 25); btnZEntfernen.addActionListener(this); fcPanel.add(btnZEntfernen); this.add(fcPanel); ButtonGroup bGrp = new ButtonGroup(); optionPanel = new JPanel(); optionPanel.setBounds(10, 300 + 10, this.getWidth() - 40, 90); optionPanel.setPreferredSize(new Dimension(this.getWidth() - 40, 90)); // optionPanel.setBorder(BorderFactory.createLineBorder(Color.BLACK)); optionPanel.setLayout(new GridLayout(3, 1)); nUebSchr = new JRadioButton("Keine Dateien überschreiben"); nUebSchr.addItemListener(this); bGrp.add(nUebSchr); optionPanel.add(nUebSchr); ueSchr = new JRadioButton("Neuere Dateien überschreiben"); ueSchr.addItemListener(this); bGrp.add(ueSchr); optionPanel.add(ueSchr); aUeSchr = new JRadioButton("Alle Dateien überschreiben"); aUeSchr.addItemListener(this); bGrp.add(aUeSchr); optionPanel.add(aUeSchr); this.add(optionPanel); syncPanel = new JPanel(); syncPanel.setBounds( 10, optionPanel.getY() + optionPanel.getHeight() + 10, this.getWidth() - 30, 25); // syncPanel.setBorder(BorderFactory.createLineBorder(Color.BLACK)); syncPanel.setLayout(new BorderLayout()); btnSync = new JButton("Sync it!"); btnSync.setBounds(0, 0, 150, (syncPanel.getHeight() / 3)); btnSync.addActionListener(this); btnSync.setPreferredSize(new Dimension(150, (syncPanel.getHeight() / 3))); btnSync.setMaximumSize(new Dimension(150, (syncPanel.getHeight() / 3))); syncPanel.add(btnSync, BorderLayout.LINE_START); btnAbbruch = new JButton("Abbrechen"); btnAbbruch.setBounds(0, 0, 150, (syncPanel.getHeight() / 3)); btnAbbruch.addActionListener(this); btnAbbruch.setPreferredSize(new Dimension(150, (syncPanel.getHeight() / 3))); btnAbbruch.setMaximumSize(new Dimension(150, (syncPanel.getHeight() / 3))); btnAbbruch.setVisible(false); syncPanel.add(btnAbbruch, BorderLayout.LINE_END); progressBar = new JProgressBar(JProgressBar.HORIZONTAL); progressBar.setBorderPainted(true); progressBar.setPreferredSize(new Dimension(300, (syncPanel.getHeight() / 3))); progressBar.setForeground(Color.RED); progressBar.setStringPainted(true); progressBar.setVisible(true); syncPanel.add(progressBar, BorderLayout.CENTER); this.add(syncPanel); logPanel = new JPanel(); logPanel.setBounds( 10, syncPanel.getY() + syncPanel.getHeight() + 10, this.getWidth() - 30, 105); logPanel.setLayout(new BorderLayout()); textArea = new JTextArea(); textArea.setMargin(new Insets(3, 3, 3, 3)); textArea.setBackground(Color.black); textArea.setForeground(Color.LIGHT_GRAY); textArea.setAutoscrolls(true); textArea.setFocusable(false); textAreaScroller = new JScrollPane(textArea); DefaultCaret caret = (DefaultCaret) textArea.getCaret(); caret.setUpdatePolicy(DefaultCaret.ALWAYS_UPDATE); textAreaScroller.setBounds(0, 0, syncPanel.getWidth(), 50); logPanel.add(textAreaScroller, BorderLayout.CENTER); this.add(logPanel, BorderLayout.SOUTH); }
public void setInputPanel() throws IOException { final String newline = "\n"; final JTextArea log = new JTextArea(2, 28); GridBagLayout gridbag = new GridBagLayout(); GridBagConstraints c = new GridBagConstraints(); input.setLayout(gridbag); // Create the log first, because the action listeners // need to refer to it. log.setMargin(new Insets(1, 1, 1, 1)); log.setEditable(false); JScrollPane logScrollPane = new JScrollPane(log); // Create a file chooser final JFileChooser fc = new JFileChooser(); // Create the open button ImageIcon openIcon = new ImageIcon("Images/open.gif"); JButton openButton = new JButton("Open a File...", openIcon); openButton.addActionListener( new ActionListener() { @Override public void actionPerformed(ActionEvent e) { int returnVal = fc.showOpenDialog(prologApplet.this); if (returnVal == JFileChooser.APPROVE_OPTION) { File file = fc.getSelectedFile(); String name = file.getName(); String path = file.getAbsolutePath(); try { FileInputStream inps = new FileInputStream(path); ch = 0; ss = ""; while (ch != -1) { ch = inps.read(); ss = ss + (char) ch; } inps.close(); } catch (Exception exc) { System.out.println("" + e); } code.selectAll(); code.cut(); code.append(ss); log.append("Opening: " + name + "." + newline); } else { log.append("Open command cancelled by user." + newline); } } }); // Create the save button ImageIcon saveIcon = new ImageIcon("Images/save.gif"); JButton saveButton = new JButton("Save a File...", saveIcon); saveButton.addActionListener( new ActionListener() { @Override public void actionPerformed(ActionEvent e) { int returnVal = fc.showSaveDialog(prologApplet.this); if (returnVal == JFileChooser.APPROVE_OPTION) { File file = fc.getSelectedFile(); // this is where a real application would save the file. log.append("Saving: " + file.getName() + "." + newline); } else { log.append("Save command cancelled by user." + newline); } } }); // For layout purposes, put the buttons in a separate panel JPanel buttonPanel = new JPanel(); buttonPanel.add(openButton); buttonPanel.add(saveButton); // Explicitly set the focus sequence. // rimossi poichè deprecati // openButton.setNextFocusableComponent(saveButton); // saveButton.setNextFocusableComponent(openButton); // Add the buttons and the log to the frame // Container contentPane = getContentPane(); // contentPane.add(buttonPanel, BorderLayout.NORTH); // contentPane.add(logScrollPane, BorderLayout.CENTER); c.gridx = 0; c.gridy = 0; c.gridwidth = 3; c.fill = GridBagConstraints.NONE; gridbag.setConstraints(buttonPanel, c); input.add(buttonPanel); c.gridx = 0; c.gridy = 1; c.gridwidth = 3; c.fill = GridBagConstraints.NONE; gridbag.setConstraints(logScrollPane, c); input.add(logScrollPane); JLabel label1 = new JLabel("Codice:"); c.gridx = 0; c.gridy = 2; c.gridwidth = 3; c.fill = GridBagConstraints.NONE; gridbag.setConstraints(label1, c); input.add(label1); c.gridx = 0; c.gridy = 3; c.gridwidth = 3; c.fill = GridBagConstraints.HORIZONTAL; gridbag.setConstraints(scrollPaneC, c); input.add(scrollPaneC); JLabel label2 = new JLabel("GOAL clause:"); c.gridx = 0; c.gridy = 4; // c.weightx=1; c.gridwidth = 3; c.fill = GridBagConstraints.NONE; gridbag.setConstraints(label2, c); input.add(label2); c.gridx = 0; c.gridy = 5; c.gridwidth = 3; c.fill = GridBagConstraints.HORIZONTAL; gridbag.setConstraints(gl, c); input.add(gl); c.gridx = 0; c.gridy = 6; c.weightx = 0.3; c.gridwidth = 1; gridbag.setConstraints(compile, c); input.add(compile); compile.addActionListener(this); c.gridx = 1; c.gridy = 6; c.weightx = 0.3; c.gridwidth = 1; gridbag.setConstraints(compileG, c); input.add(compileG); compileG.addActionListener(this); c.gridx = 2; c.gridy = 6; c.weightx = 0.3; c.gridwidth = 1; gridbag.setConstraints(run, c); input.add(run); run.addActionListener(this); Color c1 = new Color(166, 209, 241); code.setBackground(c1); code.setAutoscrolls(true); code.setEditable(true); /* mb1 input.add(load); input.add(scrollPaneC); input.add(gl); */ input.setBorder(BorderFactory.createEtchedBorder()); }