List of usage examples for javax.swing JCheckBox JCheckBox
public JCheckBox(Action a)
From source file:gtu._work.ui.RegexDirReplacer.java
private void initGUI() { try {/*from w w w . j a v a 2s . co m*/ { } BorderLayout thisLayout = new BorderLayout(); getContentPane().setLayout(thisLayout); this.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE); { jTabbedPane1 = new JTabbedPane(); getContentPane().add(jTabbedPane1, BorderLayout.CENTER); { jPanel1 = new JPanel(); BorderLayout jPanel1Layout = new BorderLayout(); jPanel1.setLayout(jPanel1Layout); jTabbedPane1.addTab("source", null, jPanel1, null); { jScrollPane1 = new JScrollPane(); jPanel1.add(jScrollPane1, BorderLayout.CENTER); { ListModel srcListModel = new DefaultListModel(); srcList = new JList(); jScrollPane1.setViewportView(srcList); srcList.setModel(srcListModel); { panel = new JPanel(); jScrollPane1.setRowHeaderView(panel); panel.setLayout(new FormLayout( new ColumnSpec[] { ColumnSpec.decode("default:grow"), }, new RowSpec[] { FormFactory.DEFAULT_ROWSPEC, FormFactory.DEFAULT_ROWSPEC, FormFactory.DEFAULT_ROWSPEC, FormFactory.RELATED_GAP_ROWSPEC, FormFactory.DEFAULT_ROWSPEC, })); { childrenDirChkbox = new JCheckBox("??"); childrenDirChkbox.setSelected(true); panel.add(childrenDirChkbox, "1, 1"); } { subFileNameText = new JTextField(); panel.add(subFileNameText, "1, 2, fill, default"); subFileNameText.setColumns(10); subFileNameText.setText("(txt|java)"); } { replaceOldFileChkbox = new JCheckBox(""); replaceOldFileChkbox.setSelected(true); panel.add(replaceOldFileChkbox, "1, 3"); } { charsetText = new JTextField(); panel.add(charsetText, "1, 5, fill, default"); charsetText.setColumns(10); charsetText.setText("UTF8"); } } srcList.addMouseListener(new MouseAdapter() { public void mouseClicked(MouseEvent evt) { JListUtil.newInstance(srcList).defaultMouseClickOpenFile(evt); JPopupMenuUtil.newInstance(srcList).applyEvent(evt)// .addJMenuItem("load files from clipboard", new ActionListener() { public void actionPerformed(ActionEvent arg0) { String content = ClipboardUtil.getInstance().getContents(); DefaultListModel model = (DefaultListModel) srcList.getModel(); StringTokenizer tok = new StringTokenizer(content, "\t\n\r\f", false); for (; tok.hasMoreElements();) { String val = ((String) tok.nextElement()).trim(); model.addElement(new File(val)); } } }).show(); } }); srcList.addKeyListener(new KeyAdapter() { public void keyPressed(KeyEvent evt) { JListUtil.newInstance(srcList).defaultJListKeyPressed(evt); } }); } } { addDirFiles = new JButton(); jPanel1.add(addDirFiles, BorderLayout.NORTH); addDirFiles.setText("add dir files"); addDirFiles.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { File file = JFileChooserUtil.newInstance().selectDirectoryOnly().showOpenDialog() .getApproveSelectedFile(); if (file == null || !file.isDirectory()) { return; } List<File> fileLst = new ArrayList<File>(); String subName = StringUtils.trimToEmpty(subFileNameText.getText()); if (StringUtils.isBlank(subName)) { subName = ".*"; } String patternStr = ".*\\." + subName; if (childrenDirChkbox.isSelected()) { FileUtil.searchFileMatchs(file, patternStr, fileLst); } else { for (File f : file.listFiles()) { if (f.isFile() && f.getName().matches(patternStr)) { fileLst.add(f); } } } DefaultListModel model = new DefaultListModel(); for (File f : fileLst) { model.addElement(f); } srcList.setModel(model); } }); } } { jPanel2 = new JPanel(); BorderLayout jPanel2Layout = new BorderLayout(); jPanel2.setLayout(jPanel2Layout); jTabbedPane1.addTab("param", null, jPanel2, null); { exeucte = new JButton(); jPanel2.add(exeucte, BorderLayout.SOUTH); exeucte.setText("exeucte"); exeucte.setPreferredSize(new java.awt.Dimension(491, 125)); exeucte.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { exeucteActionPerformed(evt); } }); } { jPanel3 = new JPanel(); GroupLayout jPanel3Layout = new GroupLayout((JComponent) jPanel3); jPanel3.setLayout(jPanel3Layout); jPanel2.add(jPanel3, BorderLayout.CENTER); { repFromText = new JTextField(); } { repToText = new JTextField(); } jPanel3Layout.setHorizontalGroup(jPanel3Layout.createSequentialGroup() .addContainerGap(25, 25) .addGroup(jPanel3Layout.createParallelGroup() .addGroup(jPanel3Layout.createSequentialGroup().addComponent(repFromText, GroupLayout.PREFERRED_SIZE, 446, GroupLayout.PREFERRED_SIZE)) .addGroup(jPanel3Layout.createSequentialGroup().addComponent(repToText, GroupLayout.PREFERRED_SIZE, 446, GroupLayout.PREFERRED_SIZE))) .addContainerGap(20, Short.MAX_VALUE)); jPanel3Layout.setVerticalGroup(jPanel3Layout.createSequentialGroup().addContainerGap() .addComponent(repFromText, GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE) .addPreferredGap(LayoutStyle.ComponentPlacement.UNRELATED) .addComponent(repToText, GroupLayout.PREFERRED_SIZE, 24, GroupLayout.PREFERRED_SIZE) .addContainerGap(GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)); } { addToTemplate = new JButton(); jPanel2.add(addToTemplate, BorderLayout.NORTH); addToTemplate.setText("add to template"); addToTemplate.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { prop.put(repFromText.getText(), repToText.getText()); reloadTemplateList(); } }); } } { jPanel4 = new JPanel(); BorderLayout jPanel4Layout = new BorderLayout(); jPanel4.setLayout(jPanel4Layout); jTabbedPane1.addTab("result", null, jPanel4, null); { jScrollPane2 = new JScrollPane(); jPanel4.add(jScrollPane2, BorderLayout.CENTER); { ListModel newRepListModel = new DefaultListModel(); newRepList = new JList(); jScrollPane2.setViewportView(newRepList); newRepList.setModel(newRepListModel); newRepList.addMouseListener(new MouseAdapter() { static final String tortoiseMergeExe = "TortoiseMerge.exe"; static final String commandFormat = "cmd /c call \"%s\" /base:\"%s\" /theirs:\"%s\""; public void mouseClicked(MouseEvent evt) { if (!JListUtil.newInstance(newRepList).isCorrectMouseClick(evt)) { return; } OldNewFile oldNewFile = (OldNewFile) JListUtil .getLeadSelectionObject(newRepList); String base = oldNewFile.newFile.getAbsolutePath(); String theirs = oldNewFile.oldFile.getAbsolutePath(); String command = String.format(commandFormat, tortoiseMergeExe, base, theirs); System.out.println(command); try { Runtime.getRuntime().exec(command); } catch (IOException e) { JCommonUtil.handleException(e); } } }); newRepList.addKeyListener(new KeyAdapter() { public void keyPressed(KeyEvent evt) { Object[] objects = (Object[]) newRepList.getSelectedValues(); if (objects == null || objects.length == 0) { return; } DefaultListModel model = (DefaultListModel) newRepList.getModel(); int lastIndex = model.getSize() - 1; Object swap = null; StringBuilder dsb = new StringBuilder(); for (Object current : objects) { int index = model.indexOf(current); switch (evt.getKeyCode()) { case 38:// up if (index != 0) { swap = model.getElementAt(index - 1); model.setElementAt(swap, index); model.setElementAt(current, index - 1); } break; case 40:// down if (index != lastIndex) { swap = model.getElementAt(index + 1); model.setElementAt(swap, index); model.setElementAt(current, index + 1); } break; case 127:// del OldNewFile current_ = (OldNewFile) current; dsb.append(current_.newFile.getName() + "\t" + (current_.newFile.delete() ? "T" : "F") + "\n"); current_.newFile.delete(); model.removeElement(current); } } if (dsb.length() > 0) { JOptionPaneUtil.newInstance().iconInformationMessage() .showMessageDialog("del result!\n" + dsb, "DELETE"); } } }); } } { replaceOrignFile = new JButton(); jPanel4.add(replaceOrignFile, BorderLayout.SOUTH); replaceOrignFile.setText("replace orign file"); replaceOrignFile.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { DefaultListModel model = (DefaultListModel) newRepList.getModel(); StringBuilder sb = new StringBuilder(); for (int ii = 0; ii < model.size(); ii++) { OldNewFile file = (OldNewFile) model.getElementAt(ii); boolean delSuccess = false; boolean renameSuccess = false; if (delSuccess = file.oldFile.delete()) { renameSuccess = file.newFile.renameTo(file.oldFile); } sb.append(file.oldFile.getName() + " del:" + (delSuccess ? "T" : "F") + " rename:" + (renameSuccess ? "T" : "F") + "\n"); } JOptionPaneUtil.newInstance().iconInformationMessage().showMessageDialog(sb, getTitle()); } }); } } { jPanel5 = new JPanel(); BorderLayout jPanel5Layout = new BorderLayout(); jPanel5.setLayout(jPanel5Layout); jTabbedPane1.addTab("template", null, jPanel5, null); { jScrollPane3 = new JScrollPane(); jPanel5.add(jScrollPane3, BorderLayout.CENTER); { templateList = new JList(); reloadTemplateList(); jScrollPane3.setViewportView(templateList); templateList.addMouseListener(new MouseAdapter() { public void mouseClicked(MouseEvent evt) { if (templateList.getLeadSelectionIndex() == -1) { return; } Entry<Object, Object> entry = (Entry<Object, Object>) JListUtil .getLeadSelectionObject(templateList); repFromText.setText((String) entry.getKey()); repToText.setText((String) entry.getValue()); } }); templateList.addKeyListener(new KeyAdapter() { public void keyPressed(KeyEvent evt) { JListUtil.newInstance(templateList).defaultJListKeyPressed(evt); } }); } } { scheduleExecute = new JButton(); jPanel5.add(scheduleExecute, BorderLayout.SOUTH); scheduleExecute.setText("schedule execute"); scheduleExecute.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { scheduleExecuteActionPerformed(evt); } }); } } } this.setSize(512, 350); JCommonUtil.setFontAll(this.getRootPane()); JCommonUtil.frameCloseDo(this, new WindowAdapter() { public void windowClosing(WindowEvent paramWindowEvent) { if (StringUtils.isNotBlank(repFromText.getText())) { prop.put(repFromText.getText(), repToText.getText()); } try { prop.store(new FileOutputStream(propFile), "regexText"); } catch (Exception e) { JCommonUtil.handleException("properties store error!", e); } setVisible(false); dispose(); } }); } catch (Exception e) { e.printStackTrace(); } }
From source file:com.egangotri.transliteratorAsSwing.TransliteratorJFrame.java
public TransliteratorJFrame() { super("eGangotri Indic Transliterator"); PrintWriter pw = new PrintWriter(System.out, true); setSize(650, 650);/*from w ww .j a v a 2s .c o m*/ // menubar menubar = new JMenuBar(); // menus file = new JMenu("File"); help = new JMenu("Help"); // JMenuItem save_1 = new JMenuItem("Save Input"); save_1.setActionCommand("save_1"); save_1.addActionListener(this); save_2 = new JMenuItem("Save Output-1"); save_2.setActionCommand("save_2"); save_2.addActionListener(this); save_3 = new JMenuItem("Save Output-2"); save_3.setActionCommand("save_3"); save_3.addActionListener(this); open_1 = new JMenuItem("Open File for Input"); open_1.setActionCommand("open_1"); open_1.addActionListener(this); exitItem = new JMenuItem("Exit"); exitItem.setActionCommand("Exit"); exitItem.addActionListener(this); aboutItem = new JMenuItem("About"); aboutItem.setActionCommand("about_item"); aboutItem.addActionListener(this); itransItem = new JMenuItem("ITRANS " + Constants.ENCODING_SCHEME); itransItem.setActionCommand("itrans_encoding"); itransItem.addActionListener(this); slpItem = new JMenuItem("SLP " + Constants.ENCODING_SCHEME); slpItem.setActionCommand("slp_encoding"); slpItem.addActionListener(this); hkItem = new JMenuItem("Harvard Kyoto " + Constants.ENCODING_SCHEME); hkItem.setActionCommand("hk_encoding"); hkItem.addActionListener(this); velthuisItem = new JMenuItem("Velthuis " + Constants.ENCODING_SCHEME); velthuisItem.setActionCommand("velthuis_encoding"); velthuisItem.addActionListener(this); dvnItem = new JMenuItem("Devanagari " + Constants.ENCODING_SCHEME); dvnItem.setActionCommand("devanagari_encoding"); dvnItem.addActionListener(this); iastItem = new JMenuItem("IAST " + Constants.ENCODING_SCHEME); iastItem.setActionCommand("iast_encoding"); iastItem.addActionListener(this); // add menuitems to menu file.add(open_1); file.add(save_1); file.add(save_2); file.add(save_3); file.add(exitItem); help.add(aboutItem); help.add(itransItem); help.add(slpItem); help.add(hkItem); help.add(velthuisItem); help.add(dvnItem); help.add(iastItem); // add menus to menubar menubar.add(file); menubar.add(help); // menus end // JPanel Initilization p1 = new JPanel(new FlowLayout(FlowLayout.LEFT)); p1a = new JPanel(new BorderLayout()); p2 = new JPanel(); p3 = new JPanel(new FlowLayout(FlowLayout.LEFT)); p3a = new JPanel(new BorderLayout()); p4 = new JPanel(); p5 = new JPanel(new FlowLayout(FlowLayout.LEFT)); p5a = new JPanel(new BorderLayout()); p6 = new JPanel(); p6a = new JPanel(); p7 = new JPanel(); // JLabel Initialization label1 = new JLabel("Input:"); label2 = new JLabel("Output-1"); label3 = new JLabel("Output-2"); capitalize = new JCheckBox("Capitalize Extended Latin"); capitalize.setSelected(capitalizeIAST); capitalize.setActionCommand("capitalize"); capitalize.addActionListener(this); // Buttons clearButton = new JButton("Clear"); clearButton.setActionCommand("clear"); clearButton.setToolTipText("Clear all Fields"); refreshButton = new JButton("Refresh"); refreshButton.setActionCommand("refresh"); refreshButton.setToolTipText("Refesh the View"); exitButton = new JButton("Exit"); exitButton.setActionCommand("Exit"); exitButton.setToolTipText("Quit the Application."); clipboardButton1 = new JButton("Clipboard"); clipboardButton1.setActionCommand("clipboard-1"); clipboardButton1.setToolTipText("Clipboard Input"); clipboardButton2 = new JButton("Clipboard"); clipboardButton2.setActionCommand("clipboard-2"); clipboardButton2.setToolTipText("Clipboard Output-1"); clipboardButton3 = new JButton("Clipboard"); clipboardButton3.setActionCommand("clipboard-3"); clipboardButton3.setToolTipText("Clipboard Output-2"); clearButton.addActionListener(this); refreshButton.addActionListener(this); exitButton.addActionListener(this); clipboardButton1.addActionListener(this); clipboardButton2.addActionListener(this); clipboardButton3.addActionListener(this); Container contentPane = getContentPane(); // JTextBox tb1 = new JTextArea(new PlainDocument(), null, 6, 45); tb1.setLineWrap(true); tb1.setWrapStyleWord(true); tb1.addKeyListener(this); tb2 = new JTextArea(new PlainDocument(), null, 6, 45); tb2.setLineWrap(true); tb2.setWrapStyleWord(true); tb2.addKeyListener(this); tb3 = new JTextArea(new PlainDocument(), null, 6, 45); tb3.setLineWrap(true); tb3.setWrapStyleWord(true); tb3.addKeyListener(this); // Setting Fonts Font unicodeFont = new Font(Constants.ARIAL_UNICODE_MS, Font.PLAIN, Constants.FONT_SIZE); tb1.setFont(unicodeFont); tb2.setFont(unicodeFont); tb3.setFont(unicodeFont); comboBox1 = new JComboBox(Constants.ENCODINGS.toArray()); comboBox1.setActionCommand("comboBox1"); comboBox1.setSelectedItem(Constants.ITRANS); comboBox1.addActionListener(this); comboBox2 = new JComboBox(Constants.ENCODINGS.toArray()); comboBox2.setActionCommand("comboBox2"); comboBox2.setSelectedItem(Constants.UNICODE_DVN); comboBox2.addActionListener(this); comboBox3 = new JComboBox(Constants.ENCODINGS.toArray()); comboBox3.setActionCommand("comboBox3"); comboBox3.setSelectedItem(Constants.IAST); comboBox3.addActionListener(this); /** *EXPERIMENT*** */ textPane = new JTextPane(); RTFEditorKit rtfkit = new RTFEditorKit(); // HTMLEditorKit htmlkit = new HTMLEditorKit(); textPane.setEditorKit(rtfkit); // set Kit which will read RTF Doc // textPane.setEditorKit(htmlkit); textPane.setEditable(false); // make uneditable textPane.setPreferredSize(new Dimension(200, 200)); textPane.setText(""); // set p1.add(label1); p1a.add(comboBox1, BorderLayout.LINE_END); p1a.add(clipboardButton1, BorderLayout.LINE_START); p2.add(new JScrollPane(tb1)); p3.add(label2); p3a.add(comboBox2, BorderLayout.LINE_END); p3a.add(clipboardButton2, BorderLayout.LINE_START); p4.add(new JScrollPane(tb2)); p5.add(label3); p5a.add(comboBox3, BorderLayout.LINE_END); p5a.add(clipboardButton3, BorderLayout.LINE_START); p6.add(new JScrollPane(tb3)); p6a.add(capitalize); p7.add(clearButton); p7.add(refreshButton); p7.add(exitButton); this.setJMenuBar(menubar); contentPane.setLayout(new BoxLayout(contentPane, BoxLayout.Y_AXIS)); contentPane.add(p1); contentPane.add(p1a); contentPane.add(p2); contentPane.add(p3); contentPane.add(p3a); contentPane.add(p4); contentPane.add(p5); contentPane.add(p5a); contentPane.add(p6); contentPane.add(p6a); contentPane.add(p7); }
From source file:net.itransformers.topologyviewer.dialogs.snmpDiscovery.DiscoveryManagerDialogV2.java
public DiscoveryManagerDialogV2(JFrame frame, File projectDir) { this.frame = frame; this.projectDir = projectDir; setTitle("Discovery Manager"); setBounds(100, 100, 960, 364);//from w w w .j a v a2 s .c o m getContentPane().setLayout(new BorderLayout()); { JPanel buttonPane = new JPanel(); getContentPane().add(buttonPane, BorderLayout.NORTH); { buttonPane.setLayout(new BorderLayout(0, 0)); { JPanel panel = new JPanel(); buttonPane.add(panel); panel.setLayout(null); { depthComboBox = new JComboBox(); depthComboBox.setModel( new DefaultComboBoxModel(new Integer[] { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 })); depthComboBox.setBounds(46, 11, 70, 20); panel.add(depthComboBox); } JLabel lblMode = new JLabel("Depth:"); lblMode.setBounds(6, 14, 46, 14); panel.add(lblMode); JLabel lblAddress = new JLabel("Address:"); lblAddress.setBounds(172, 14, 56, 14); panel.add(lblAddress); addressTextField = new JTextField(); addressTextField.setBounds(230, 11, 113, 20); panel.add(addressTextField); addressTextField.setColumns(10); JLabel lblLabel = new JLabel("Label:"); lblLabel.setBounds(360, 14, 56, 14); panel.add(lblLabel); labelTextField = new JTextField(); labelTextField.setBounds(400, 11, 113, 20); panel.add(labelTextField); labelTextField.setColumns(10); autoLabelCheckBox = new JCheckBox("auto-label"); autoLabelCheckBox.setBounds(520, 11, 113, 20); autoLabelCheckBox.setSelected(true); panel.add(autoLabelCheckBox); postDiscoveryCheckBox = new JCheckBox("Post Discovery"); postDiscoveryCheckBox.setBounds(620, 11, 153, 20); postDiscoveryCheckBox.setSelected(true); panel.add(postDiscoveryCheckBox); } } { JPanel panel = new JPanel(); buttonPane.add(panel, BorderLayout.EAST); final JButton stopStartButton = new JButton("Start"); panel.add(stopStartButton); stopStartButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent arg0) { if ("Start".equals(stopStartButton.getText())) { onStartDiscoveryPre(stopStartButton); onStartDiscovery(); onStartDiscoveryPost(stopStartButton); } else { onStopDiscoveryPre(stopStartButton); onStopDiscovery(); onStopDiscoveryPost(stopStartButton); } } }); stopStartButton.setActionCommand("Start"); getRootPane().setDefaultButton(stopStartButton); { pauseResumeButton.setEnabled(false); panel.add(pauseResumeButton); pauseResumeButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { if ("Pause".equals(pauseResumeButton.getText())) { pauseResumeButton.setEnabled(false); onPauseDiscovery(); pauseResumeButton.setText("Resume"); pauseResumeButton.setEnabled(true); } else { pauseResumeButton.setEnabled(false); onResumeDiscovery(); pauseResumeButton.setText("Pause"); pauseResumeButton.setEnabled(true); } } }); } } } { lblDiscoveredDevices = new JTextArea(); JScrollPane scrolltxt = new JScrollPane(lblDiscoveredDevices); lblDiscoveredDevices.append("Discovery process output"); getContentPane().add(scrolltxt, BorderLayout.CENTER); } { JPanel statusPanel = new JPanel(); getContentPane().add(statusPanel, BorderLayout.SOUTH); statusPanel.setLayout(new BorderLayout(0, 0)); { JPanel panel = new JPanel(); statusPanel.add(panel); panel.setLayout(new BorderLayout(0, 0)); //panel.setSize(100:100); { loggerConsole = new JTextArea(); JScrollPane scrolltxt = new JScrollPane(loggerConsole); loggerConsole.append("Discovery logger console"); panel.add(scrolltxt, BorderLayout.CENTER); } } } { Logger logger = Logger.getRootLogger(); logger.setLevel(Level.INFO); logger.addAppender(new AppenderSkeleton() { @Override protected void append(final LoggingEvent loggingEvent) { SwingUtilities.invokeLater(new Runnable() { public void run() { loggerConsole.append(loggingEvent.getMessage().toString()); loggerConsole.append("\n"); } }); } @Override public void close() { } @Override public boolean requiresLayout() { return false; } }); } }
From source file:org.jfree.chart.demo.XYStepAreaChartDemo.java
/** * Creates a new demo.// w w w.j ava 2 s.c om * * @param title the frame title. */ public XYStepAreaChartDemo(final String title) { super(title); this.xySeries = new XYSeries("Some data"); for (int i = 0; i < TEST_DATA.length; i++) { this.xySeries.add((Integer) TEST_DATA[i][0], (Integer) TEST_DATA[i][1]); } final XYSeriesCollection dataset = new XYSeriesCollection(this.xySeries); final JFreeChart chart = createChart(dataset); this.chartPanel = new ChartPanel(chart); // allow zooming // this.chartPanel.setHorizontalZoom(true); // this.chartPanel.setVerticalZoom(true); // size this.chartPanel.setPreferredSize(new java.awt.Dimension(500, 270)); // make stroke more striking final Plot plot = this.chartPanel.getChart().getPlot(); plot.setOutlineStroke(new BasicStroke(2)); plot.setOutlinePaint(Color.magenta); // add some components to make options changable final JPanel main = new JPanel(new BorderLayout()); final JPanel optionsPanel = new JPanel(); final String[] options = { ORIENT_VERT, ORIENT_HORIZ }; this.orientationComboBox = new JComboBox(options); this.orientationComboBox.addActionListener(this); optionsPanel.add(this.orientationComboBox); this.outlineCheckBox = new JCheckBox("Outline"); this.outlineCheckBox.addActionListener(this); optionsPanel.add(this.outlineCheckBox); optionsPanel.add(new JLabel("Base")); this.rangeBaseTextField = new JTextField("0", 5); this.rangeBaseTextField.addActionListener(this); optionsPanel.add(this.rangeBaseTextField); this.nullValuesCheckBox = new JCheckBox("NULL values"); this.nullValuesCheckBox.addActionListener(this); optionsPanel.add(this.nullValuesCheckBox); main.add(optionsPanel, BorderLayout.SOUTH); main.add(this.chartPanel); setContentPane(main); }
From source file:com.intuit.tank.tools.script.ScriptFilterRunner.java
/** * @return/*w w w. j a v a 2s .c o m*/ */ private Component createContentPanel() { JSplitPane pane = new JSplitPane(JSplitPane.VERTICAL_SPLIT, true); scriptEditorTA = new RSyntaxTextArea(); setSyntaxStyle(); RTextScrollPane sp = new RTextScrollPane(scriptEditorTA); pane.setTopComponent(sp); JScrollPane scrollPane = new JScrollPane(JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED, JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED); JPanel panel = new JPanel(new BorderLayout()); output = new TextAreaOutputLogger(scrollPane, INITIAL_OUTPUT_CONTENT); output.setEditable(false); output.setAutoscrolls(true); output.setScrollContent(true); output.setWrapStyleWord(true); scrollPane.setViewportView(output); JToolBar toolBar = new JToolBar(); JButton clearBT = new JButton("Clear"); clearBT.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { output.setText(INITIAL_OUTPUT_CONTENT); } }); final JCheckBox scrollCB = new JCheckBox("Auto Scroll Content"); scrollCB.setSelected(true); scrollCB.addChangeListener(new ChangeListener() { public void stateChanged(ChangeEvent e) { output.setScrollContent(scrollCB.isSelected()); } }); toolBar.add(clearBT); toolBar.add(scrollCB); panel.add(toolBar, BorderLayout.NORTH); panel.add(scrollPane, BorderLayout.CENTER); pane.setBottomComponent(panel); pane.setDividerLocation(300); return pane; }
From source file:e3fraud.gui.MainWindow.java
public MainWindow() { super(new BorderLayout(5, 5)); extended = false;/*from w ww. j a v a 2 s . c o m*/ //Create the log first, because the action listeners //need to refer to it. log = new JTextArea(10, 50); log.setMargin(new Insets(5, 5, 5, 5)); log.setEditable(false); logScrollPane = new JScrollPane(log); DefaultCaret caret = (DefaultCaret) log.getCaret(); caret.setUpdatePolicy(DefaultCaret.ALWAYS_UPDATE); // create the progress bar progressBar = new JProgressBar(0, 100); progressBar.setValue(progressBar.getMinimum()); progressBar.setVisible(false); progressBar.setStringPainted(true); //Create the settings pane generationSettingLabel = new JLabel("Generate:"); SpinnerModel collusionsSpinnerModel = new SpinnerNumberModel(1, 0, 3, 1); collusionSettingsPanel = new JPanel(new FlowLayout()) { @Override public Dimension getMaximumSize() { return getPreferredSize(); } }; // collusionSettingsPanel.setLayout(new BoxLayout(collusionSettingsPanel, BoxLayout.X_AXIS)); collusionsButton = new JSpinner(collusionsSpinnerModel); collusionsLabel = new JLabel("collusion(s)"); collusionSettingsPanel.add(collusionsButton); collusionSettingsPanel.add(collusionsLabel); rankingSettingLabel = new JLabel("Rank by:"); lossButton = new JRadioButton("loss"); lossButton.setToolTipText("Sort sub-ideal models based on loss for Target of Assessment (high -> low)"); gainButton = new JRadioButton("gain"); gainButton.setToolTipText( "Sort sub-ideal models based on gain of any actor except Target of Assessment (high -> low)"); lossGainButton = new JRadioButton("loss + gain"); lossGainButton.setToolTipText( "Sort sub-ideal models based on loss for Target of Assessment and, if equal, on gain of any actor except Target of Assessment"); //gainLossButton = new JRadioButton("gain + loss"); lossGainButton.setSelected(true); rankingGroup = new ButtonGroup(); rankingGroup.add(lossButton); rankingGroup.add(gainButton); rankingGroup.add(lossGainButton); //rankingGroup.add(gainLossButton); groupingSettingLabel = new JLabel("Group by:"); groupingButton = new JCheckBox("collusion"); groupingButton.setToolTipText( "Groups sub-ideal models based on the pair of actors colluding before ranking them"); groupingButton.setSelected(false); refreshButton = new JButton("Refresh"); refreshButton.addActionListener(this); settingsPanel = new JPanel(); settingsPanel.setLayout(new BoxLayout(settingsPanel, BoxLayout.PAGE_AXIS)); settingsPanel.add(Box.createRigidArea(new Dimension(0, 5))); settingsPanel.add(generationSettingLabel); collusionSettingsPanel.setAlignmentX(LEFT_ALIGNMENT); settingsPanel.add(Box.createRigidArea(new Dimension(0, 5))); settingsPanel.add(collusionSettingsPanel); settingsPanel.add(Box.createRigidArea(new Dimension(0, 5))); rankingSettingLabel.setAlignmentY(TOP_ALIGNMENT); settingsPanel.add(rankingSettingLabel); settingsPanel.add(lossButton); settingsPanel.add(gainButton); settingsPanel.add(lossGainButton); //settingsPanel.add(gainLossButton); settingsPanel.add(Box.createRigidArea(new Dimension(0, 5))); settingsPanel.add(groupingSettingLabel); settingsPanel.add(groupingButton); settingsPanel.add(Box.createRigidArea(new Dimension(0, 5))); settingsPanel.add(refreshButton); settingsPanel.add(Box.createRigidArea(new Dimension(0, 20))); progressBar.setPreferredSize( new Dimension(settingsPanel.getSize().width, progressBar.getPreferredSize().height)); settingsPanel.add(progressBar); //Create the result tree root = new DefaultMutableTreeNode("No models to display"); treeModel = new DefaultTreeModel(root); tree = new JTree(treeModel); //tree.setUI(new CustomTreeUI()); tree.setCellRenderer(new CustomTreeCellRenderer(tree)); tree.getSelectionModel().setSelectionMode(TreeSelectionModel.SINGLE_TREE_SELECTION); tree.setLargeModel(true); resultScrollPane = new JScrollPane(tree); tree.addTreeSelectionListener(treeSelectionListener); //tree.setShowsRootHandles(true); //Create a file chooser for saving sfc = new JFileChooser(); FileFilter jpegFilter = new FileNameExtensionFilter("JPEG image", new String[] { "jpg", "jpeg" }); sfc.addChoosableFileFilter(jpegFilter); sfc.setFileFilter(jpegFilter); //Create a file chooser for loading fc = new JFileChooser(); FileFilter rdfFilter = new FileNameExtensionFilter("RDF file", "RDF"); fc.addChoosableFileFilter(rdfFilter); fc.setFileFilter(rdfFilter); //Create the open button. openButton = new JButton("Load model", createImageIcon("images/Open24.png")); openButton.addActionListener(this); openButton.setToolTipText("Load a e3value model"); //Create the ideal graph button. idealGraphButton = new JButton("Show ideal graph", createImageIcon("images/Plot.png")); idealGraphButton.setToolTipText("Display ideal profitability graph"); idealGraphButton.addActionListener(this); Dimension thinButtonDimension = new Dimension(15, 420); //Create the expand subideal graph button. expandButton = new JButton(">"); expandButton.setPreferredSize(thinButtonDimension); expandButton.setMargin(new Insets(0, 0, 0, 0)); expandButton.setToolTipText("Expand to show non-ideal profitability graph for selected model"); expandButton.addActionListener(this); //Create the collapse sub-ideal graph button. collapseButton = new JButton("<"); collapseButton.setPreferredSize(thinButtonDimension); collapseButton.setMargin(new Insets(0, 0, 0, 0)); collapseButton.setToolTipText("Collapse non-ideal profitability graph for selected model"); collapseButton.addActionListener(this); //Create the generation button. generateButton = new JButton("Generate sub-ideal models", createImageIcon("images/generate.png")); generateButton.addActionListener(this); generateButton.setToolTipText("Generate sub-ideal models for the e3value model currently loaded"); //Create the chart panel chartPane = new JPanel(); chartPane.setLayout(new FlowLayout(FlowLayout.LEFT)); chartPane.add(expandButton); //For layout purposes, put the buttons in a separate panel JPanel buttonPanel = new JPanel(); buttonPanel.setLayout(new BoxLayout(buttonPanel, BoxLayout.X_AXIS)); buttonPanel.add(openButton); buttonPanel.add(Box.createRigidArea(new Dimension(20, 0))); buttonPanel.add(generateButton); buttonPanel.add(Box.createRigidArea(new Dimension(10, 0))); buttonPanel.add(idealGraphButton); //Add the buttons, the ranking options, the result list and the log to this panel. add(buttonPanel, BorderLayout.PAGE_START); add(settingsPanel, BorderLayout.LINE_START); add(resultScrollPane, BorderLayout.CENTER); add(logScrollPane, BorderLayout.PAGE_END); add(chartPane, BorderLayout.LINE_END); //and make a nice border around it setBorder(BorderFactory.createEmptyBorder(5, 10, 10, 10)); }
From source file:marytts.tools.voiceimport.DatabaseImportMain.java
protected void setupGUI() { // A scroll pane containing one labelled checkbox per component, // and a "run selected components" button below. GridBagLayout gridBagLayout = new GridBagLayout(); GridBagConstraints gridC = new GridBagConstraints(); getContentPane().setLayout(gridBagLayout); JPanel checkboxPane = new JPanel(); checkboxPane.setLayout(new BoxLayout(checkboxPane, BoxLayout.Y_AXIS)); //checkboxPane.setPreferredSize(new Dimension(300, 300)); int compIndex = 0; for (int j = 0; j < groups2Comps.length; j++) { String[] nextGroup = groups2Comps[j]; JPanel groupPane = new JPanel(); groupPane.setLayout(new BoxLayout(groupPane, BoxLayout.Y_AXIS)); groupPane.setBorder(BorderFactory.createCompoundBorder(BorderFactory.createTitledBorder(nextGroup[0]), BorderFactory.createEmptyBorder(1, 1, 1, 1))); for (int i = 1; i < nextGroup.length; i++) { JButton configButton = new JButton(); Icon configIcon = new ImageIcon(DatabaseImportMain.class.getResource("configure.png"), "Configure"); configButton.setIcon(configIcon); configButton.setPreferredSize(new Dimension(configIcon.getIconWidth(), configIcon.getIconHeight())); configButton.addActionListener(new ConfigButtonActionListener(nextGroup[i])); configButton.setBorderPainted(false); //System.out.println("Adding checkbox for "+components[i].getClass().getName()); checkboxes[compIndex] = new JCheckBox(nextGroup[i]); checkboxes[compIndex].setFocusable(true); //checkboxes[i].setPreferredSize(new Dimension(200, 30)); JPanel line = new JPanel(); line.setLayout(new BorderLayout(5, 0)); line.add(configButton, BorderLayout.WEST); line.add(checkboxes[compIndex], BorderLayout.CENTER); groupPane.add(line);/*from w w w .ja v a 2 s . c o m*/ compIndex++; } checkboxPane.add(groupPane); } gridC.gridx = 0; gridC.gridy = 0; gridC.fill = GridBagConstraints.BOTH; JScrollPane scrollPane = new JScrollPane(checkboxPane); scrollPane.setPreferredSize(new Dimension(450, 300)); gridBagLayout.setConstraints(scrollPane, gridC); getContentPane().add(scrollPane); JButton helpButton = new JButton("Help"); helpButton.setMnemonic(KeyEvent.VK_H); helpButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent ae) { displayHelpGUI(); } }); JButton settingsButton = new JButton("Settings"); settingsButton.setMnemonic(KeyEvent.VK_S); settingsButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent ae) { currentComponent = "Global properties"; displaySettingsGUI(); } }); runButton = new JButton("Run"); runButton.setMnemonic(KeyEvent.VK_R); runButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent ae) { runSelectedComponents(); } }); JButton quitAndSaveButton = new JButton("Quit"); quitAndSaveButton.setMnemonic(KeyEvent.VK_Q); quitAndSaveButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent ae) { try { askIfSave(); } catch (IOException ioe) { ioe.printStackTrace(); } System.exit(0); } }); gridC.gridy = 1; JPanel buttonPanel = new JPanel(); buttonPanel.setLayout(new FlowLayout()); //buttonPanel.setLayout(new BoxLayout(buttonPanel,BoxLayout.X_AXIS)); //runButton.setAlignmentX(JButton.LEFT_ALIGNMENT); buttonPanel.add(runButton); //helpButton.setAlignmentX(JButton.LEFT_ALIGNMENT); buttonPanel.add(helpButton); //settingsButton.setAlignmentX(JButton.LEFT_ALIGNMENT); buttonPanel.add(settingsButton); //buttonPanel.add(Box.createHorizontalGlue()); //quitAndSaveButton.setAlignmentX(JButton.RIGHT_ALIGNMENT); buttonPanel.add(quitAndSaveButton); gridBagLayout.setConstraints(buttonPanel, gridC); getContentPane().add(buttonPanel); //getContentPane().setPreferredSize(new Dimension(300, 300)); // End program when closing window: addWindowListener(new WindowAdapter() { public void windowClosing(WindowEvent evt) { try { askIfSave(); } catch (IOException ioe) { ioe.printStackTrace(); } System.exit(0); } }); }
From source file:com.orange.atk.graphAnalyser.RealtimeGraph.java
public void addUrlMarkerCheckBox() { urlMarkersCheckBox = new JCheckBox("Display Url markers"); urlMarkersCheckBox.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { boolean selected = ((JCheckBox) e.getSource()).isSelected(); JaTKCharts.displayUrlMarkers(selected); }//from ww w . j a v a2 s . c o m }); toolPane.add(urlMarkersCheckBox); urlMarkersCheckBox.setSelected(true); toolPane.invalidate(); }
From source file:com.unionpay.upmp.jmeterplugin.gui.UPMPDefaultsGui.java
private void init() { setLayout(new BorderLayout(0, 5)); setBorder(makeBorder());//from w ww. j av a 2 s . c o m add(makeTitlePanel(), BorderLayout.NORTH); urlConfig = new UPMPUrlConfigGui(false, true, false); add(urlConfig, BorderLayout.CENTER); // OPTIONAL TASKS final JPanel optionalTasksPanel = new VerticalPanel(); optionalTasksPanel.setBorder(BorderFactory.createTitledBorder(BorderFactory.createEtchedBorder(), JMeterUtils.getResString("optional_tasks"))); // $NON-NLS-1$ final JPanel checkBoxPanel = new HorizontalPanel(); imageParser = new JCheckBox(JMeterUtils.getResString("web_testing_retrieve_images")); // $NON-NLS-1$ checkBoxPanel.add(imageParser); imageParser.addItemListener(new ItemListener() { @Override public void itemStateChanged(final ItemEvent e) { if (e.getStateChange() == ItemEvent.SELECTED) { enableConcurrentDwn(true); } else { enableConcurrentDwn(false); } } }); // Concurrent resources download concurrentDwn = new JCheckBox(JMeterUtils.getResString("web_testing_concurrent_download")); // $NON-NLS-1$ concurrentDwn.addItemListener(new ItemListener() { @Override public void itemStateChanged(final ItemEvent e) { if (imageParser.isSelected() && e.getStateChange() == ItemEvent.SELECTED) { concurrentPool.setEnabled(true); } else { concurrentPool.setEnabled(false); } } }); concurrentPool = new JTextField(2); // 2 columns size concurrentPool.setMaximumSize(new Dimension(30, 20)); checkBoxPanel.add(concurrentDwn); checkBoxPanel.add(concurrentPool); optionalTasksPanel.add(checkBoxPanel); // Embedded URL match regex embeddedRE = new JLabeledTextField(JMeterUtils.getResString("web_testing_embedded_url_pattern"), 30); // $NON-NLS-1$ optionalTasksPanel.add(embeddedRE); add(optionalTasksPanel, BorderLayout.SOUTH); }
From source file:net.sf.taverna.t2.workbench.ui.credentialmanager.WarnUserAboutJCEPolicyDialog.java
private void initComponents() { // Base font for all components on the form Font baseFont = new JLabel("base font").getFont().deriveFont(11f); // Message saying that updates are available JPanel messagePanel = new JPanel(new BorderLayout()); messagePanel.setBorder(new CompoundBorder(new EmptyBorder(10, 10, 10, 10), new EtchedBorder(LOWERED))); JEditorPane message = new JEditorPane(); message.setEditable(false);//from w w w.j av a 2 s .c om message.setBackground(this.getBackground()); message.setFocusable(false); HTMLEditorKit kit = new HTMLEditorKit(); message.setEditorKit(kit); StyleSheet styleSheet = kit.getStyleSheet(); //styleSheet.addRule("body {font-family:"+baseFont.getFamily()+"; font-size:"+baseFont.getSize()+";}"); // base font looks bigger when rendered as HTML styleSheet.addRule("body {font-family:" + baseFont.getFamily() + "; font-size:10px;}"); Document doc = kit.createDefaultDocument(); message.setDocument(doc); message.setText( "<html><body>In order for Taverna's security features to function properly - you need to install<br>" + "'Java Cryptography Extension (JCE) Unlimited Strength Jurisdiction Policy'. <br><br>" + "If you do not already have it, for <b>Java 6</b> you can get it from:<br>" + "<a href=\"http://www.oracle.com/technetwork/java/javase/downloads/index.html\">http://www.oracle.com/technetwork/java/javase/downloads/index.html</a><br<br>" + "Installation instructions are contained in the bundle you download." + "</body><html>"); message.addHyperlinkListener(new HyperlinkListener() { @Override public void hyperlinkUpdate(HyperlinkEvent he) { HyperlinkEvent.EventType type = he.getEventType(); if (type == ACTIVATED) // Open a Web browser try { getDesktop().browse(he.getURL().toURI()); // BrowserLauncher launcher = new BrowserLauncher(); // launcher.openURLinBrowser(he.getURL().toString()); } catch (Exception ex) { logger.error("Failed to launch browser to fetch JCE " + he.getURL()); } } }); message.setBorder(new EmptyBorder(5, 5, 5, 5)); messagePanel.add(message, CENTER); doNotWarnMeAgainCheckBox = new JCheckBox("Do not warn me again"); doNotWarnMeAgainCheckBox.setFont(baseFont.deriveFont(12f)); messagePanel.add(doNotWarnMeAgainCheckBox, SOUTH); // Buttons JPanel buttonsPanel = new JPanel(new FlowLayout(FlowLayout.CENTER)); JButton okButton = new JButton("OK"); okButton.setFont(baseFont); okButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { okPressed(); } }); buttonsPanel.add(okButton); getContentPane().setLayout(new BorderLayout()); getContentPane().add(messagePanel, CENTER); getContentPane().add(buttonsPanel, SOUTH); pack(); setResizable(false); // Center the dialog on the screen (we do not have the parent) Dimension dimension = getToolkit().getScreenSize(); Rectangle abounds = getBounds(); setLocation((dimension.width - abounds.width) / 2, (dimension.height - abounds.height) / 2); setSize(getPreferredSize()); }