List of usage examples for javax.swing SwingConstants VERTICAL
int VERTICAL
To view the source code for javax.swing SwingConstants VERTICAL.
Click Source Link
From source file:org.zaproxy.zap.extension.cmss.CMSSFrame.java
/** Create the frame. */ public CMSSFrame() { setTitle("Fingerprinting tools"); setResizable(false);/*from ww w . j a v a 2 s. com*/ setDefaultCloseOperation(JFrame.HIDE_ON_CLOSE); setBounds(100, 100, 756, 372); contentPane = new JPanel(); contentPane.setBorder(new EmptyBorder(5, 5, 5, 5)); contentPane.setLayout(new BorderLayout(0, 0)); setContentPane(contentPane); JLayeredPane layeredPane = new JLayeredPane(); contentPane.add(layeredPane, BorderLayout.CENTER); JTabbedPane tabbedPane = new JTabbedPane(JTabbedPane.TOP); tabbedPane.setBounds(0, 0, 725, 323); layeredPane.add(tabbedPane); JLayeredPane layeredPane_1 = new JLayeredPane(); tabbedPane.addTab("Fingerprint", null, layeredPane_1, null); JLabel label = new JLabel("App name:"); label.setBounds(35, 188, 76, 14); layeredPane_1.add(label); JLabel label_1 = new JLabel("Version:"); label_1.setBounds(35, 230, 76, 14); layeredPane_1.add(label_1); textField = new JTextField(); textField.setColumns(10); textField.setBounds(121, 188, 109, 29); layeredPane_1.add(textField); textField_1 = new JTextField(); textField_1.setColumns(10); textField_1.setBounds(121, 223, 109, 29); layeredPane_1.add(textField_1); JSeparator separator = new JSeparator(); separator.setBounds(35, 72, 665, 2); layeredPane_1.add(separator); JSeparator separator_1 = new JSeparator(); separator_1.setBounds(196, 11, 1, 201); layeredPane_1.add(separator_1); JSeparator separator_2 = new JSeparator(); separator_2.setOrientation(SwingConstants.VERTICAL); separator_2.setBounds(260, 81, 1, 201); layeredPane_1.add(separator_2); final JCheckBox chckbxGetVersion = new JCheckBox("Get version"); chckbxGetVersion.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { if (textField_1.isEnabled() && !chckbxGetVersion.isSelected()) textField_1.setEnabled(false); if (!textField_1.isEnabled() && chckbxGetVersion.isSelected()) textField_1.setEnabled(true); } }); chckbxGetVersion.setBounds(35, 81, 195, 23); layeredPane_1.add(chckbxGetVersion); final JCheckBox chckbxPassiveFingerprinting = new JCheckBox("Passive"); chckbxPassiveFingerprinting.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { } }); chckbxPassiveFingerprinting.setBounds(35, 107, 195, 23); chckbxPassiveFingerprinting.setSelected(true); // layeredPane_1.add(chckbxPassiveFingerprinting); final JCheckBox chckbxAgressive = new JCheckBox("Agressive"); chckbxAgressive.setBounds(35, 133, 195, 23); layeredPane_1.add(chckbxAgressive); JLabel lblWhatToFingerprint = new JLabel("What to fingerprint ?"); lblWhatToFingerprint.setBounds(287, 81, 109, 14); layeredPane_1.add(lblWhatToFingerprint); JCheckBox chckbxCms = new JCheckBox("cms"); chckbxCms.setBounds(280, 102, 134, 23); layeredPane_1.add(chckbxCms); JCheckBox chckbxMessageboards = new JCheckBox("message-boards"); chckbxMessageboards.setBounds(280, 128, 134, 23); layeredPane_1.add(chckbxMessageboards); JCheckBox chckbxJavascriptframeworks = new JCheckBox("javascript-frameworks"); chckbxJavascriptframeworks.setBounds(281, 154, 133, 23); layeredPane_1.add(chckbxJavascriptframeworks); JCheckBox chckbxWebframeworks = new JCheckBox("web-frameworks"); chckbxWebframeworks.setBounds(281, 178, 133, 23); layeredPane_1.add(chckbxWebframeworks); JCheckBox chckbxWebservers = new JCheckBox("web-servers"); chckbxWebservers.setBounds(281, 204, 133, 23); layeredPane_1.add(chckbxWebservers); JSeparator separator_4 = new JSeparator(); separator_4.setOrientation(SwingConstants.VERTICAL); separator_4.setBounds(435, 81, 1, 201); layeredPane_1.add(separator_4); JCheckBox chckbxDatabases = new JCheckBox("databases"); chckbxDatabases.setBounds(281, 228, 133, 23); layeredPane_1.add(chckbxDatabases); JButton btnMore = new JButton("More"); btnMore.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { wtfpFrame = new WhatToFingerPrintFrame(); wtfpFrame.setLocationRelativeTo(null); wtfpFrame.setVisible(true); } }); btnMore.setBounds(291, 261, 123, 23); layeredPane_1.add(btnMore); JLabel lblFingerprintingTimeAnd = new JLabel("Fingerprinting time and occuracy settings:"); lblFingerprintingTimeAnd.setBounds(490, 81, 210, 14); layeredPane_1.add(lblFingerprintingTimeAnd); JButton btnFingerprint = new JButton("Fingerprint"); btnFingerprint.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { if (!chckbxPassiveFingerprinting.isSelected() && !chckbxAgressive.isSelected()) chckbxPassiveFingerprinting.setSelected(true); if (chckbxPassiveFingerprinting.isSelected() && !chckbxAgressive.isSelected()) POrAOption = 1; else if (!chckbxPassiveFingerprinting.isSelected() && chckbxAgressive.isSelected()) POrAOption = 2; else if (chckbxPassiveFingerprinting.isSelected() && chckbxAgressive.isSelected()) POrAOption = 3; try { targetUrl = new URL(txtHttp.getText()); } catch (MalformedURLException e2) { // TODO Auto-generated catch block e2.printStackTrace(); } System.out.println("POrAOption : " + POrAOption); // we concatenate the two ArrayLists ArrayList<String> wtfpList = getWhatToFingerprint(); for (String wtfp : wtfpFrame.getWhatToFingerprint()) { wtfpList.add(wtfp); } // we call FastFingerprinter.filterResults on the global whatToFingerPrint // List fpThread = new FingerPrintingThread(targetUrl, wtfpList, POrAOption); fpThread.start(); while (fpThread.isAlive()) { // waiting; } ArrayList<String> resultList = fpThread.getFingerPrintingResult(); for (String app : resultList) { textField.setText(textField.getText() + app + " , "); } if (chckbxGetVersion.isSelected()) { System.out.println("wiw"); ArrayList<String> versions = new ArrayList<String>(); if (resultList.contains("wordpress")) { textField_1.setText(textField_1.getText() + "wordpress :"); for (String version : FastFingerprinter.WordpressFastFingerprint(targetUrl)) { textField_1.setText(textField_1.getText() + version + " ; "); } } if (resultList.contains("joomla")) { textField_1.setText(textField_1.getText() + "joomla :"); for (String version : FastFingerprinter.JoomlaFastFingerprint(targetUrl)) { textField_1.setText(textField_1.getText() + version + " ; "); } } // blindelephant for (String app : resultList) { System.out.println("---->" + app); try { versions = WebAppGuesser.fingerPrintFile(app); textField_1.setText(textField_1.getText() + app + " : "); for (String version : versions) { textField_1.setText(textField_1.getText() + version + " ; "); } } catch (NoSuchAlgorithmException | IOException | DecoderException e1) { e1.printStackTrace(); } } } } }); btnFingerprint.setBounds(35, 154, 195, 23); layeredPane_1.add(btnFingerprint); JButton btnDetailedView = new JButton("Detailed view "); btnDetailedView.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { } }); btnDetailedView.setBounds(35, 259, 195, 23); layeredPane_1.add(btnDetailedView); this.checkBoxesList.add(chckbxCms); this.checkBoxesList.add(chckbxJavascriptframeworks); this.checkBoxesList.add(chckbxWebframeworks); this.checkBoxesList.add(chckbxWebservers); this.checkBoxesList.add(chckbxDatabases); this.checkBoxesList.add(chckbxMessageboards); txtHttp = new JTextField(); txtHttp.setText("http://"); txtHttp.setBounds(128, 22, 568, 29); layeredPane_1.add(txtHttp); txtHttp.setColumns(10); JLabel lblTarget = new JLabel("Target : "); lblTarget.setBounds(51, 29, 46, 14); layeredPane_1.add(lblTarget); JLayeredPane layeredPane_2 = new JLayeredPane(); tabbedPane.addTab("Details", null, layeredPane_2, null); JTabbedPane tabbedPane_1 = new JTabbedPane(JTabbedPane.TOP); tabbedPane_1.setBounds(0, 0, 720, 223); layeredPane_2.add(tabbedPane_1); JLayeredPane layeredPane_4 = new JLayeredPane(); tabbedPane_1.addTab("Detailed result", null, layeredPane_4, null); JLayeredPane layeredPane_3 = new JLayeredPane(); tabbedPane_1.addTab("Passive fingerprint", null, layeredPane_3, null); JTabbedPane tabbedPane_2 = new JTabbedPane(JTabbedPane.TOP); tabbedPane_1.addTab("Agressive fingerprint", null, tabbedPane_2, null); }
From source file:pl.otros.logview.gui.message.editor.MessageColorizerBrowser.java
public MessageColorizerBrowser(OtrosApplication otrosApplication) { super(new BorderLayout()); this.container = otrosApplication.getAllPluginables().getMessageColorizers(); this.otrosApplication = otrosApplication; toolBar = new JToolBar(); editor = new MessageColorizerEditor(container, otrosApplication.getStatusObserver()); JLabel noEditable = new JLabel("Selected MessageColorizer is not editable.", SwingConstants.CENTER); JLabel nothingSelected = new JLabel("Nothing selected", SwingConstants.CENTER); listModel = new PluginableElementListModel<MessageColorizer>(container); jList = new JList(listModel); jList.setCellRenderer(new PluginableElementNameListRenderer()); cardLayout = new CardLayout(); contentPanel = new JPanel(cardLayout); contentPanel.add(editor, CARD_LAYOUT_EDITOR); contentPanel.add(noEditable, CARD_LAYOUT_NOT_EDITABLE); contentPanel.add(nothingSelected, CARD_LAYOUT_NO_SELECTED); cardLayout.show(contentPanel, CARD_LAYOUT_NOT_EDITABLE); JSplitPane mainSplitPane = new JSplitPane(SwingConstants.VERTICAL, new JScrollPane(jList), contentPanel); mainSplitPane.setDividerLocation(220); jList.getSelectionModel().addListSelectionListener(new ListSelectionListener() { @Override//from www .j a va 2 s .co m public void valueChanged(ListSelectionEvent e) { showSelected(); enableDisableButtonsForSelectedColorizer(); } }); jList.addKeyListener(new KeyAdapter() { @Override public void keyPressed(KeyEvent e) { int keyCode = e.getKeyCode(); if (keyCode == KeyEvent.VK_DELETE) { ActionEvent actionEvent = new ActionEvent(e.getSource(), ActionEvent.ACTION_PERFORMED, ""); deleteAction.actionPerformed(actionEvent); } } }); JButton createNew = new JButton("Create new", Icons.ADD); createNew.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { saveAsButton.setEnabled(false); createNew(); } }); saveButton = new JButton("Save and use", Icons.DISK); saveButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { try { PropertyPatternMessageColorizer mc = editor.createMessageColorizer(); File selectedFile = null; String f = mc.getFile(); if (StringUtils.isNotBlank(f)) { selectedFile = new File(mc.getFile()); } else { int response = chooser.showSaveDialog(MessageColorizerBrowser.this); if (response != JFileChooser.APPROVE_OPTION) { return; } selectedFile = chooser.getSelectedFile(); if (!selectedFile.getName().endsWith(".pattern")) { selectedFile = new File(selectedFile.getParentFile(), selectedFile.getName() + ".pattern"); } } removeMessageColorizerWithNullFile(); applyMessageColorizer(selectedFile); saveMessageColorizer(selectedFile); jList.setSelectedValue(mc, true); } catch (ConfigurationException e1) { String errorMessage = String.format("Can't save message colorizer: %s", e1.getMessage()); LOGGER.severe(errorMessage); MessageColorizerBrowser.this.otrosApplication.getStatusObserver().updateStatus(errorMessage, StatusObserver.LEVEL_ERROR); } } }); saveAsButton = new JButton("Save as", Icons.DISK_PLUS); saveAsButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { try { int response = chooser.showSaveDialog(MessageColorizerBrowser.this); if (response != JFileChooser.APPROVE_OPTION) { return; } File selectedFile = chooser.getSelectedFile(); selectedFile = chooser.getSelectedFile(); if (!selectedFile.getName().endsWith(".pattern")) { selectedFile = new File(selectedFile.getParentFile(), selectedFile.getName() + ".pattern"); } removeMessageColorizerWithNullFile(); applyMessageColorizer(selectedFile); saveMessageColorizer(selectedFile); jList.setSelectedValue(editor.createMessageColorizer(), true); } catch (ConfigurationException e1) { String errorMessage = String.format("Can't save message colorizer: %s", e1.getMessage()); LOGGER.severe(errorMessage); MessageColorizerBrowser.this.otrosApplication.getStatusObserver().updateStatus(errorMessage, StatusObserver.LEVEL_ERROR); } } }); useButton = new JButton("Use without saving"); useButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent arg0) { try { removeMessageColorizerWithNullFile(); applyMessageColorizer(File.createTempFile("messageColorizer", "pattern")); } catch (Exception e) { LOGGER.severe("Cannot create message colorizer: " + e.getMessage()); } } }); deleteAction = new DeleteSelected(otrosApplication); deleteButton = new JButton(deleteAction); toolBar.setFloatable(false); toolBar.add(createNew); toolBar.add(saveButton); toolBar.add(saveAsButton); toolBar.add(useButton); toolBar.add(deleteButton); enableDisableButtonsForSelectedColorizer(); initFileChooser(); this.add(mainSplitPane); this.add(toolBar, BorderLayout.SOUTH); }
From source file:test.uk.co.modularaudio.util.swing.lwtc.TestShowLWTCSliderComparison.java
public TestShowLWTCSliderComparison() { final LWTCSliderPainter painter = new LWTCSliderPainter(LWTCControlConstants.STD_SLIDER_NOMARK_COLOURS); horizontalKnobContainer = new KnobContainer(painter, SwingConstants.HORIZONTAL); verticalKnobContainer = new KnobContainer(painter, SwingConstants.VERTICAL); }
From source file:test.uk.co.modularaudio.util.swing.lwtc.TestShowLWTCSliderComparison.java
public void go(final int orientation) throws Exception { final JSlider testSwingJSlider = new JSlider(orientation); testSwingJSlider.setOpaque(false);// ww w.j a va2 s . c o m final BoundedRangeModel defaultSwingSliderModel = testSwingJSlider.getModel(); log.debug("Default swing slider model is " + defaultSwingSliderModel.toString()); final JFrame f = new JFrame(); f.getContentPane().setBackground(Color.decode("#3a5555")); final MigLayoutStringHelper msg = new MigLayoutStringHelper(); // msg.addLayoutConstraint( "debug" ); msg.addLayoutConstraint("fill"); msg.addLayoutConstraint("insets 0"); msg.addLayoutConstraint("gap 0"); if (orientation == SwingConstants.VERTICAL) { msg.addColumnConstraint("[][grow][grow][]"); msg.addRowConstraint("[][grow][]"); } else { msg.addColumnConstraint("[][grow][]"); msg.addRowConstraint("[][grow][grow][]"); } f.setLayout(msg.createMigLayout()); f.add(new JLabel("o"), "center"); f.add(new JLabel("o"), "center"); if (orientation == SwingConstants.VERTICAL) { f.add(new JLabel("o"), "center"); } f.add(new JLabel("o"), "center,wrap"); f.add(new JLabel("o"), "center"); if (orientation == SwingConstants.VERTICAL) { f.add(verticalKnobContainer, "center, grow"); f.add(testSwingJSlider, "center, grow"); } else { f.add(horizontalKnobContainer, "center, grow"); } f.add(new JLabel("o"), "center,wrap"); if (orientation == SwingConstants.HORIZONTAL) { f.add(new JLabel("o"), "center"); f.add(testSwingJSlider, "center, grow"); f.add(new JLabel("o"), "center, wrap"); } f.add(new JLabel("o"), "center"); if (orientation == SwingConstants.VERTICAL) { f.add(new JLabel("o"), "center"); } f.add(new JLabel("o"), "center"); f.add(new JLabel("o"), "center"); f.pack(); f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); SwingUtilities.invokeLater(new Runnable() { @Override public void run() { f.setVisible(true); } }); }
From source file:test.uk.co.modularaudio.util.swing.lwtc.TestShowLWTCSliderComparison.java
public static void main(final String[] args) throws Exception { if (LWTCCtrlTestingConstants.USE_LAF) { UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName()); UIManager.put("Slider.paintValue", Boolean.FALSE); }/*from w ww.jav a 2s . c o m*/ final TestShowLWTCSliderComparison vt = new TestShowLWTCSliderComparison(); vt.go(SwingConstants.VERTICAL); final TestShowLWTCSliderComparison ht = new TestShowLWTCSliderComparison(); ht.go(SwingConstants.HORIZONTAL); }
From source file:uk.nhs.cfh.dsp.srth.desktop.modules.simulator.viewcomponent.DataGenerationPanel.java
/** * Inits the components.//from w ww . j av a2 s . c om */ public synchronized void initComponents() { while (activeFrame == null) { if (applicationService != null && applicationService.getFrameView() != null) { activeFrame = applicationService.getFrameView().getActiveFrame(); } } JPanel runPanel = new JPanel(); runPanel.setLayout(new BoxLayout(runPanel, BoxLayout.LINE_AXIS)); runPanel.setBorder(BorderFactory.createEmptyBorder(paddingSize, paddingSize, paddingSize, paddingSize)); JXLabel label = new JXLabel(); label.setLineWrap(true); label.setText( "<html>This panel allows the creation of clinically plausible data based on a query specification. " + "Please note that you <b>must</b> always specify a data generation source. " + "The rest of the parameters can be left in their default state. When you've configured the parameters " + "click the 'Generate data' button.</html>"); runPanel.add(label); runPanel.add(new JSeparator(SwingConstants.VERTICAL)); runPanel.add(Box.createHorizontalStrut(paddingSize)); JideButton runButton = new JideButton(new GenerateDataAction(applicationService, queryService, dataGenerationEngine, propertyChangeTrackerService)); runButton.setButtonStyle(ButtonStyle.HYPERLINK_STYLE); runPanel.add(runButton); runButton.setIcon(new ImageIcon(DataGenerationPanel.class.getResource("resources/linuxconf.png"))); runPanel.add(Box.createHorizontalStrut(paddingSize)); // create radio buttons for choosing source JRadioButton queryButton = new JRadioButton("Active Query"); queryButton.setSelected(true); queryButton.addActionListener(this); queryButton.setActionCommand("activeQuery"); JRadioButton fileButton = new JRadioButton("File"); fileButton.addActionListener(this); fileButton.setActionCommand("file"); JRadioButton folderButton = new JRadioButton("Folder"); folderButton.addActionListener(this); folderButton.setActionCommand("folder"); ButtonGroup bg = new ButtonGroup(); bg.add(queryButton); bg.add(fileButton); bg.add(folderButton); JPanel buttonsPanel = new JPanel(); buttonsPanel.setLayout(new BoxLayout(buttonsPanel, BoxLayout.LINE_AXIS)); // buttonsPanel.add(new JLabel("Select data generation source")); buttonsPanel.setBorder(BorderFactory.createTitledBorder("Select data generation source")); buttonsPanel.add(Box.createHorizontalStrut(paddingSize)); buttonsPanel.add(queryButton); buttonsPanel.add(Box.createHorizontalStrut(paddingSize)); buttonsPanel.add(fileButton); buttonsPanel.add(Box.createHorizontalStrut(paddingSize)); buttonsPanel.add(folderButton); locationField = new JTextField(100); JButton loadQueryButton = new JButton("Browse"); loadQueryButton.addActionListener(this); loadQueryButton.setActionCommand("load"); locationPanel = new JPanel(); locationPanel.setLayout(new BoxLayout(locationPanel, BoxLayout.LINE_AXIS)); locationPanel.add(new JLabel("Load file from")); locationPanel.add(Box.createHorizontalStrut(paddingSize)); locationPanel.add(locationField); locationPanel.add(Box.createHorizontalStrut(paddingSize)); locationPanel.add(loadQueryButton); JPanel lhsPanel = new JPanel(new GridLayout(0, 2)); JPanel rhsPanel = new JPanel(new GridLayout(0, 2)); lhsPanel.add(new JLabel("Max number of patients to generate")); SpinnerNumberModel model = new SpinnerNumberModel(initialPatientsNumber, 1, 1000000, 1); ptNumberSpinner = new JSpinner(model); ptNumberSpinner.addChangeListener(new ChangeListener() { public void stateChanged(ChangeEvent event) { // get value currently selected in spinner and set in engine dataGenerationEngine.setMaxPatientNumber(Long.parseLong(ptNumberSpinner.getValue().toString())); // Object value = ptNumberSpinner.getValue(); // if(value instanceof Double) // { // Double d = (Double) ptNumberSpinner.getValue(); // dataGenerationEngine.setMaxPatientNumber(d.longValue()); // } // else // { // dataGenerationEngine.setMaxPatientNumber(Long.parseLong(ptNumberSpinner.getValue().toString())); // } logger.debug("ptNumberSpinner.getValue().getClass() = " + ptNumberSpinner.getValue().getClass()); logger.debug("Max pt number in engine set to : " + dataGenerationEngine.getMaxPatientNumber()); } }); lhsPanel.add(ptNumberSpinner); lhsPanel.add(new JLabel("Min age of patients to generate")); SpinnerNumberModel ageModel = new SpinnerNumberModel(initialMinimumAge, 1, 120, 1); minAgeSpinner = new JSpinner(ageModel); minAgeSpinner.addChangeListener(new ChangeListener() { public void stateChanged(ChangeEvent e) { // set min pt age to current value dataGenerationEngine.setMinPatientAgeInYears(Integer.parseInt(minAgeSpinner.getValue().toString())); logger.debug("Value of engine.getMinPatientAgeInYears() : " + dataGenerationEngine.getMinPatientAgeInYears()); } }); lhsPanel.add(minAgeSpinner); lhsPanel.add(new JLabel("Data generation strategy")); generationStrategyBox = new JComboBox(DataGenerationEngine.DataGenerationStrategy.values()); generationStrategyBox.setSelectedItem(DataGenerationEngine.DataGenerationStrategy.ADD_IF_NOT_EXISTS); generationStrategyBox.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { dataGenerationEngine.setDataGenerationStrategy( (DataGenerationEngine.DataGenerationStrategy) generationStrategyBox.getSelectedItem()); } }); lhsPanel.add(generationStrategyBox); includeExcludedTermsBox = new JCheckBox(new AbstractAction("Include Excluded terms in data") { public void actionPerformed(ActionEvent arg0) { dataGenerationEngine.setIncludeExcludedTerms(includeExcludedTermsBox.isSelected()); logger.debug("dataGenerationEngine.isIncludeExcludedTerms() = " + dataGenerationEngine.isIncludeExcludedTerms()); } }); rhsPanel.add(includeExcludedTermsBox); randomiseNumericalValuesBox = new JCheckBox(new AbstractAction("Randomise Numerical values in data") { public void actionPerformed(ActionEvent arg0) { dataGenerationEngine.setRandomiseNumericalValues(randomiseNumericalValuesBox.isSelected()); logger.debug("dataGenerationEngine.isRandomiseNumericalValues() = " + dataGenerationEngine.isRandomiseNumericalValues()); } }); rhsPanel.add(randomiseNumericalValuesBox); refineQualifiersCheckBox = new JCheckBox(new AbstractAction("Refine Qualifiers in expression") { public void actionPerformed(ActionEvent e) { dataGenerationEngine.setRefineQualifiers(refineQualifiersCheckBox.isSelected()); logger.debug( "dataGenerationEngine.isRefineQualifiers() = " + dataGenerationEngine.isRefineQualifiers()); } }); rhsPanel.add(refineQualifiersCheckBox); includePreCoordinatedDataCheckBox = new JCheckBox( new AbstractAction("Include pre-coordinated expressions") { public void actionPerformed(ActionEvent e) { dataGenerationEngine .setIncludePrecoordinatedData(includePreCoordinatedDataCheckBox.isSelected()); logger.debug("dataGenerationEngine.isIncludePrecoordinatedData() = " + dataGenerationEngine.isIncludePrecoordinatedData()); } }); rhsPanel.add(includePreCoordinatedDataCheckBox); rhsPanel.add(new JLabel(" ")); /* * create panel for parametrising engine */ JPanel parametrisationPanel = new JPanel(); parametrisationPanel.setLayout(new GridLayout(0, 2)); parametrisationPanel.setBorder(BorderFactory.createTitledBorder("Engine Parameters")); // add panels to parametrisation panel parametrisationPanel.add(lhsPanel); parametrisationPanel.add(rhsPanel); JPanel topPanel = new JPanel(); topPanel.setLayout(new BoxLayout(topPanel, BoxLayout.LINE_AXIS)); topPanel.add(runPanel); topPanel.add(new JSeparator(SwingConstants.VERTICAL)); topPanel.add(buttonsPanel); // add all panels to this component setLayout(new BorderLayout()); add(topPanel, BorderLayout.NORTH); add(parametrisationPanel, BorderLayout.CENTER); // initialise values populateFields(dataGenerationEngine); }
From source file:utybo.branchingstorytree.swing.OpenBSTGUI.java
public OpenBSTGUI() { instance = this; UIManager.put("OptionPane.errorIcon", new ImageIcon(Icons.getImage("Cancel", 48))); UIManager.put("OptionPane.informationIcon", new ImageIcon(Icons.getImage("About", 48))); UIManager.put("OptionPane.questionIcon", new ImageIcon(Icons.getImage("Rename", 48))); UIManager.put("OptionPane.warningIcon", new ImageIcon(Icons.getImage("Error", 48))); BorderLayout borderLayout = new BorderLayout(); borderLayout.setVgap(4);// w w w . j a v a 2 s . c om getContentPane().setLayout(borderLayout); setIconImage(Icons.getImage("Logo", 48)); setTitle("OpenBST " + OpenBST.VERSION); setDefaultCloseOperation(WindowConstants.DO_NOTHING_ON_CLOSE); addWindowListener(new WindowAdapter() { @Override public void windowClosing(WindowEvent e) { boolean cancelled = false; int i = 0; for (Component c : container.getComponents()) { if (c instanceof StoryPanel) { i++; } else if (c instanceof StoryEditor) { container.setSelectedComponent(c); if (((StoryEditor) c).askClose()) { continue; } else { cancelled = true; break; } } } if (!cancelled) { if (i > 0) { int j = Messagers.showConfirm(OpenBSTGUI.this, "You are about to close " + i + " file(s). Are you sure you wish to exit OpenBST?", Messagers.OPTIONS_YES_NO, Messagers.TYPE_WARNING, "Closing OpenBST"); if (j != Messagers.OPTION_YES) cancelled = true; } if (!cancelled) System.exit(0); } } }); JMenuBar jmb = new JMenuBar(); jmb.setBackground(OPENBST_BLUE); jmb.add(Box.createHorizontalGlue()); jmb.add(createShortMenu()); jmb.add(Box.createHorizontalGlue()); this.setJMenuBar(jmb); addDarkModeCallback(b -> { jmb.setBackground(b ? OPENBST_BLUE.darker().darker() : OPENBST_BLUE); }); container = new JTabbedPane(); container.setTabLayoutPolicy(JTabbedPane.SCROLL_TAB_LAYOUT); container.addMouseListener(new MouseAdapter() { @Override public void mouseClicked(final MouseEvent e) { if (SwingUtilities.isMiddleMouseButton(e)) { final int i = container.indexAtLocation(e.getX(), e.getY()); System.out.println(i); if (i > -1) { Component c = container.getComponentAt(i); if (c instanceof StoryPanel) { container.setSelectedComponent(c); ((StoryPanel) c).askClose(); } else if (c instanceof StoryEditor) { container.setSelectedComponent(c); ((StoryEditor) c).askClose(); } } } } }); getContentPane().add(container, BorderLayout.CENTER); final JBackgroundPanel welcomeContentPanel = new JBackgroundPanel(Icons.getRandomBackground(), Image.SCALE_FAST); background = welcomeContentPanel; welcomeContentPanel.setLayout(new MigLayout("hidemode 2", "[grow,center]", "[][grow][]")); container.add(welcomeContentPanel); container.setTitleAt(0, Lang.get("welcome")); bannersPanel = new JPanel(new MigLayout("hidemode 2, gap 0px, fill, wrap 1, ins 0")); bannersPanel.setBackground(new Color(0, 0, 0, 0)); welcomeContentPanel.add(bannersPanel, "cell 0 0,grow"); if (OpenBST.VERSION.endsWith("u")) { JButton btnReportBugs = new JButton(Lang.get("welcome.reportbugs")); btnReportBugs.addActionListener(e -> { VisualsUtils.browse("https://github.com/utybo/BST/issues"); }); bannersPanel.add(new JBannerPanel(new ImageIcon(Icons.getImage("Experiment", 32)), Color.YELLOW, Lang.get("welcome.ontheedge"), btnReportBugs, false), "grow"); } else if (OpenBST.VERSION.contains("SNAPSHOT")) { bannersPanel.add(new JBannerPanel(new ImageIcon(Icons.getImage("Experiment", 32)), Color.ORANGE, Lang.get("welcome.snapshot"), null, false), "grow"); } if (System.getProperty("java.specification.version").equals("9")) { bannersPanel.add(new JBannerPanel(new ImageIcon(Icons.getImage("Attention", 32)), new Color(255, 50, 50), Lang.get("welcome.java9warning"), null, false), "grow"); } if (System.getProperty("java.specification.version").equals("10")) { bannersPanel.add(new JBannerPanel(new ImageIcon(Icons.getImage("Attention", 32)), new Color(255, 50, 50), Lang.get("welcome.java10warning"), null, false), "grow"); } JButton btnJoinDiscord = new JButton(Lang.get("openbst.discordjoin")); btnJoinDiscord.addActionListener(e -> { VisualsUtils.browse("https://discord.gg/6SVDCMM"); }); bannersPanel.add(new JBannerPanel(new ImageIcon(Icons.getImage("Discord", 48)), DISCORD_COLOR, Lang.get("openbst.discord"), btnJoinDiscord, true), "grow"); JPanel panel = new JPanel(); panel.setBackground(new Color(0, 0, 0, 0)); welcomeContentPanel.add(panel, "flowx,cell 0 1,growx,aligny center"); panel.setLayout(new MigLayout("", "[40%][][][][60%,growprio 50]", "[][grow]")); final JLabel lblOpenbst = new JLabel(new ImageIcon(Icons.getImage("FullLogo", 48))); addDarkModeCallback(b -> lblOpenbst .setIcon(new ImageIcon(b ? Icons.getImage("FullLogoWhite", 48) : Icons.getImage("FullLogo", 48)))); panel.add(lblOpenbst, "flowx,cell 0 0 1 2,alignx trailing,aligny center"); JSeparator separator = new JSeparator(); separator.setOrientation(SwingConstants.VERTICAL); panel.add(separator, "cell 2 0 1 2,growy"); final JLabel lblWelcomeToOpenbst = new JLabel("<html>" + Lang.get("welcome.intro")); lblWelcomeToOpenbst.setMaximumSize(new Dimension(350, 999999)); panel.add(lblWelcomeToOpenbst, "cell 4 0"); Component horizontalStrut = Box.createHorizontalStrut(10); panel.add(horizontalStrut, "cell 1 1"); Component horizontalStrut_1 = Box.createHorizontalStrut(10); panel.add(horizontalStrut_1, "cell 3 1"); final JButton btnOpenAFile = new JButton(Lang.get("welcome.open")); panel.add(btnOpenAFile, "flowx,cell 4 1"); btnOpenAFile.setIcon(new ImageIcon(Icons.getImage("Open", 40))); btnOpenAFile.addActionListener(e -> { openStory(VisualsUtils.askForFile(this, Lang.get("file.title"))); }); final JButton btnOpenEditor = new JButton(Lang.get("welcome.openeditor")); panel.add(btnOpenEditor, "cell 4 1"); btnOpenEditor.setIcon(new ImageIcon(Icons.getImage("Edit Property", 40))); btnOpenEditor.addActionListener(e -> { openEditor(VisualsUtils.askForFile(this, Lang.get("file.title"))); }); JButton btnChangeBackground = new JButton(Lang.get("welcome.changebackground"), new ImageIcon(Icons.getImage("Change Theme", 16))); btnChangeBackground.addActionListener(e -> { BufferedImage prev = background.getImage(); BufferedImage next; do { next = Icons.getRandomBackground(); } while (prev == next); background.setImage(next); }); welcomeContentPanel.add(btnChangeBackground, "flowx,cell 0 2,alignx left"); JButton btnWelcomepixabay = new JButton(Lang.get("welcome.pixabay"), new ImageIcon(Icons.getImage("External Link", 16))); btnWelcomepixabay.addActionListener(e -> { VisualsUtils.browse("https://pixabay.com"); }); welcomeContentPanel.add(btnWelcomepixabay, "cell 0 2"); JLabel creds = new JLabel(Lang.get("welcome.credits")); creds.setEnabled(false); welcomeContentPanel.add(creds, "cell 0 2, gapbefore 10px"); setSize((int) (830 * Icons.getScale()), (int) (480 * Icons.getScale())); setLocationRelativeTo(null); }
From source file:xtrememp.XtremeMP.java
protected void createPanels() { JPanel framePanel = new JPanel(new MigLayout("fill")); mainPanel = new JPanel(new CardLayout()); playlistManager = new PlaylistManager(this); visualizationManager = new VisualizationManager(audioPlayer.getDSS()); if (Settings.getLastView().equals(Utilities.VISUALIZATION_PANEL)) { visualizationManager.setDssEnabled(true); mainPanel.add(visualizationManager, Utilities.VISUALIZATION_PANEL); mainPanel.add(playlistManager, Utilities.PLAYLIST_MANAGER); visualizationMenuItem.setSelected(true); } else {/* w w w . java 2s.co m*/ mainPanel.add(playlistManager, Utilities.PLAYLIST_MANAGER); mainPanel.add(visualizationManager, Utilities.VISUALIZATION_PANEL); playlistManagerMenuItem.setSelected(true); } framePanel.add(mainPanel, "grow"); JPanel southPanel = new JPanel(new MigLayout("fill", "[center]")); SubstanceLookAndFeel.setDecorationType(southPanel, DecorationAreaType.TOOLBAR); seekSlider = new SeekSlider(this); seekSlider.setEnabled(false); southPanel.add(seekSlider, "north, gap 4 4 1 0"); controlPanel = new JPanel(new MigLayout("gap 0, ins 0", "[center]")); controlPanel.setOpaque(false); stopButton = new StopButton(); stopButton.setEnabled(false); stopButton.addActionListener(this); controlPanel.add(stopButton); previousButton = new PreviousButton(); previousButton.setEnabled(false); previousButton.addActionListener(this); controlPanel.add(previousButton); playPauseButton = new PlayPauseButton(); playPauseButton.addActionListener(this); controlPanel.add(playPauseButton, "height pref!"); nextButton = new NextButton(); nextButton.setEnabled(false); nextButton.addActionListener(this); controlPanel.add(nextButton); volumeButton = new VolumeButton(Utilities.MIN_GAIN, Utilities.MAX_GAIN, Settings.getGain(), Settings.isMuted()); volumeButton.addMouseWheelListener((MouseWheelEvent e) -> { try { int volumeValue = volumeSlider.getValue() - 5 * e.getWheelRotation(); int volumeMin = volumeSlider.getMinimum(); int volumeMax = volumeSlider.getMaximum(); if (volumeValue < volumeMin) { volumeValue = volumeMin; } else if (volumeValue > volumeMax) { volumeValue = volumeMax; } volumeButton.setVolumeIcon(volumeValue); volumeSlider.setValue(volumeValue); audioPlayer.setGain(volumeValue / 100.0F); Settings.setGain(volumeValue); } catch (PlayerException ex) { logger.debug(ex.getMessage(), ex); } }); JPopupMenu volumePopupMenu = volumeButton.getPopupMenu(); volumeSlider = new JSlider(JSlider.VERTICAL, Utilities.MIN_GAIN, Utilities.MAX_GAIN, Settings.getGain()); volumeSlider.setMajorTickSpacing(25); volumeSlider.setMinorTickSpacing(5); volumeSlider.setPaintTicks(true); volumeSlider.setPaintLabels(true); volumeSlider.addChangeListener((ChangeEvent e) -> { if (volumeSlider.getValueIsAdjusting()) { try { int volumeValue = volumeSlider.getValue(); volumeButton.setVolumeIcon(volumeValue); audioPlayer.setGain(volumeValue / 100.0F); Settings.setGain(volumeValue); } catch (PlayerException ex) { logger.debug(ex.getMessage(), ex); } } }); volumeSlider.setEnabled(!Settings.isMuted()); JPanel volumePanel = new JPanel(new MigLayout("fill")); JLabel volumeLabel = new JLabel(tr("MainFrame.Menu.Player.Volume"), JLabel.CENTER); volumeLabel.setFont(volumeLabel.getFont().deriveFont(Font.BOLD)); volumePanel.add(volumeLabel, "north"); volumePanel.add(volumeSlider); JCheckBox muteCheckBox = new JCheckBox(tr("MainFrame.Menu.Player.Mute")); muteCheckBox.setSelected(Settings.isMuted()); muteCheckBox.addItemListener((ItemEvent e) -> { try { if (e.getStateChange() == ItemEvent.SELECTED) { volumeSlider.setEnabled(false); volumeButton.setVolumeMutedIcon(); audioPlayer.setMuted(true); Settings.setMuted(true); } else { volumeSlider.setEnabled(true); volumeButton.setVolumeIcon(Settings.getGain()); audioPlayer.setMuted(false); Settings.setMuted(false); } } catch (PlayerException ex) { logger.debug(ex.getMessage(), ex); } }); volumePanel.add(muteCheckBox, "south"); volumePopupMenu.add(volumePanel); controlPanel.add(volumeButton); southPanel.add(controlPanel, "gap 0 0 2 5"); JPanel statusBar = new JPanel(new MigLayout("ins 2 0 2 0")); SubstanceLookAndFeel.setDecorationType(statusBar, DecorationAreaType.FOOTER); timeLabel = new JLabel(Utilities.ZERO_TIMER); timeLabel.setFont(timeLabel.getFont().deriveFont(Font.BOLD)); statusBar.add(timeLabel, "gap 6 6 0 0, west"); statusBar.add(new JSeparator(SwingConstants.VERTICAL), "hmin 16"); statusLabel = new JLabel(); statusBar.add(statusLabel, "gap 0 2 0 0, wmin 0, push"); statusBar.add(new JSeparator(SwingConstants.VERTICAL), "hmin 16"); playModeLabel = new JLabel(); playModeLabel.addMouseListener(new MouseAdapter() { @Override public void mousePressed(MouseEvent e) { Playlist.PlayMode[] playModes = Playlist.PlayMode.values(); Playlist.PlayMode playMode = playlist.getPlayMode(); int ordinal = playMode.ordinal(); playlist.setPlayMode(playModes[(ordinal == playModes.length - 1) ? 0 : ordinal + 1]); } }); statusBar.add(playModeLabel, "east, gap 2 2 2 2, width 18!, height 18!"); southPanel.add(statusBar, "south"); framePanel.add(southPanel, "south"); mainFrame.setContentPane(framePanel); }