/** Creates the error area component. */ private void initErrorArea() { SimpleAttributeSet attribs = new SimpleAttributeSet(); StyleConstants.setAlignment(attribs, StyleConstants.ALIGN_RIGHT); StyleConstants.setFontFamily(attribs, errorPane.getFont().getFamily()); StyleConstants.setForeground(attribs, Color.RED); errorPane.setParagraphAttributes(attribs, true); errorPane.setPreferredSize(new Dimension(100, 50)); errorPane.setMinimumSize(new Dimension(100, 50)); errorPane.setOpaque(false); }
@Override public void actionPerformed(ActionEvent e) { licence_text = new String( "This program is free software: you can redistribute it and/or modify\n" + "it under the terms of the GNU General Public License as published by\n" + "the Free Software Foundation, either version 3 of the License, or\n" + "(at your option) any later version.\n" + "\n" + "This program is distributed in the hope that it will be useful,\n" + "but WITHOUT ANY WARRANTY; without even the implied warranty of\n" + "MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n" + "GNU General Public License for more details.\n" + "\n" + "You should have received a copy of the GNU General Public License\n" + "along with this program. If not, see <http://www.gnu.org/licenses/>.\n" + "\n\n\n"); try { InputStream ips = new FileInputStream(getClass().getResource("COPYING").getPath()); InputStreamReader ipsr = new InputStreamReader(ips); BufferedReader br = new BufferedReader(ipsr); String line; while ((line = br.readLine()) != null) { licence_text += line + '\n'; } br.close(); } catch (Exception e1) { } Dimension dimension = new Dimension(600, 400); JDialog licence = new JDialog(memento, "Licence"); JTextPane text_pane = new JTextPane(); text_pane.setEditable(false); text_pane.setPreferredSize(dimension); text_pane.setSize(dimension); StyledDocument doc = text_pane.getStyledDocument(); Style justified = doc.addStyle( "justified", StyleContext.getDefaultStyleContext().getStyle(StyleContext.DEFAULT_STYLE)); StyleConstants.setAlignment(justified, StyleConstants.ALIGN_JUSTIFIED); try { doc.insertString(0, licence_text, justified); } catch (BadLocationException ble) { System.err.println("Couldn't insert initial text into text pane."); } Style logicalStyle = doc.getLogicalStyle(0); doc.setParagraphAttributes(0, licence_text.length(), justified, false); doc.setLogicalStyle(0, logicalStyle); JScrollPane paneScrollPane = new JScrollPane(text_pane); paneScrollPane.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS); paneScrollPane.setPreferredSize(dimension); paneScrollPane.setMinimumSize(dimension); JPanel pan = new JPanel(); LayoutManager layout = new BorderLayout(); pan.setLayout(layout); pan.add(new JScrollPane(paneScrollPane), BorderLayout.CENTER); JButton close = new JButton("Fermer"); close.addActionListener(new ButtonCloseActionListener(licence)); JPanel button_panel = new JPanel(); FlowLayout button_panel_layout = new FlowLayout(FlowLayout.RIGHT, 20, 20); button_panel.setLayout(button_panel_layout); button_panel.add(close); pan.add(button_panel, BorderLayout.SOUTH); licence.add(pan); licence.pack(); licence.setLocationRelativeTo(memento); licence.setVisible(true); }
private void jbInit() throws Exception { this.getContentPane().setLayout(gridBagLayout2); bottomPanel.setLayout(gridBagLayout1); messagePanel.setBorder(BorderFactory.createLoweredBevelBorder()); replaceButton.setToolTipText("Save the new trace replacing the old trace."); replaceButton.setText("Replace old trace"); replaceButton.addActionListener( new java.awt.event.ActionListener() { public void actionPerformed(ActionEvent e) { replaceOldTrace(); } }); buttonPanel.setBorder(BorderFactory.createLoweredBevelBorder()); discardButton.setToolTipText("Discard the new trace"); discardButton.setText("Discard new trace"); discardButton.addActionListener( new java.awt.event.ActionListener() { public void actionPerformed(ActionEvent e) { DoneReplayDialog.this.setVisible(false); } }); saveButton.setToolTipText("Save the new trace in a file."); saveButton.setText("Save as new file"); saveButton.addActionListener( new java.awt.event.ActionListener() { public void actionPerformed(ActionEvent e) { saveNewToFile(); } }); this.setModal(true); this.setTitle("Replay Complete"); jScrollPane1.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS); jScrollPane1.setMinimumSize(new Dimension(200, 200)); jScrollPane1.setPreferredSize(new Dimension(200, 200)); jTextPane.setMinimumSize(new Dimension(25, 80)); jTextPane.setPreferredSize(new Dimension(40, 80)); tracePanel.setLayout(borderLayout1); commentPanel.setLayout(borderLayout3); jPanel6.setLayout(borderLayout2); jScrollPane2.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS); jScrollPane2.setMinimumSize(new Dimension(200, 100)); jScrollPane2.setPreferredSize(new Dimension(200, 100)); jLabel1.setText("Comment"); jLabel2.setText("Traces (Old is Yellow, New is Pink)"); tracePanel.setBorder(BorderFactory.createEtchedBorder()); bottomPanel.setBorder(BorderFactory.createEtchedBorder()); commentPanel.setBorder(BorderFactory.createEtchedBorder()); this.getContentPane() .add( bottomPanel, new GridBagConstraints( 0, 3, 1, 1, 1.0, 1.0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(0, 5, 5, 5), 0, 0)); buttonPanel.add(saveButton, null); buttonPanel.add(replaceButton, null); buttonPanel.add(discardButton, null); bottomPanel.add( messagePanel, new GridBagConstraints( 0, 0, 1, 1, 1.0, 1.0, GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(0, 0, 0, 0), 0, 0)); messagePanel.add(messageLabel, null); this.getContentPane() .add( tracePanel, new GridBagConstraints( 0, 2, 1, 1, 1.0, 1.0, GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(0, 0, 0, 0), 0, 0)); tracePanel.add(jScrollPane1, BorderLayout.CENTER); tracePanel.add(jLabel2, BorderLayout.NORTH); this.getContentPane() .add( commentPanel, new GridBagConstraints( 0, 1, 1, 1, 1.0, 1.0, GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(0, 5, 5, 5), 0, 0)); commentPanel.add(jPanel6, BorderLayout.CENTER); jPanel6.add(jScrollPane2, BorderLayout.CENTER); commentPanel.add(jLabel1, BorderLayout.NORTH); jScrollPane2.getViewport().add(commentPane, null); jScrollPane1.getViewport().add(jTextPane, null); bottomPanel.add( buttonPanel, new GridBagConstraints( 0, 1, 2, 2, 1.0, 1.0, GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); }