List of usage examples for javax.swing Box createHorizontalStrut
public static Component createHorizontalStrut(int width)
From source file:uk.nhs.cfh.dsp.srth.desktop.modules.simulator.viewcomponent.DataGenerationPanel.java
/** * Inits the components.//www . j a v a 2 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:uk.nhs.cfh.dsp.srth.desktop.uiframework.app.impl.ModularDockingApplicationView.java
/** * Creates the status bar./*from w w w . j ava 2s . c o m*/ */ protected synchronized void createStatusBar() { // create and add status bar to view jxStatusBar = new JXStatusBar(); jxStatusBar.setName("jxStatusBar"); jxStatusBar.add(Box.createHorizontalStrut(buffer), new JXStatusBar.Constraint(buffer)); JXStatusBar.Constraint c1 = new JXStatusBar.Constraint(JXStatusBar.Constraint.ResizeBehavior.FILL); jxStatusBar.add(statusMessageLabel, c1); JXStatusBar.Constraint c2 = new JXStatusBar.Constraint(25); jxStatusBar.add(progressBar, new JXStatusBar.Constraint(150)); jxStatusBar.add(busyLabel, c2); // create cancel current task button cancelCurrentTaskButton = new JideButton(actionMap.get("cancelCurrentTask")); cancelCurrentTaskButton.setText(""); cancelCurrentTaskButton.setName("cancelCurrentTaskButton"); jxStatusBar.add(cancelCurrentTaskButton, new JXStatusBar.Constraint(25)); }
From source file:uk.nhs.cfh.dsp.srth.desktop.uiframework.utils.ActionComponentManager.java
/** * Check and add toolbar button.//from w ww. j ava 2 s .c o m * * @param toolBar the tool bar * @param button the button * @param toolBarIndex the tool bar index */ private synchronized void checkAndAddToolbarButton(JToolBar toolBar, JideButton button, int toolBarIndex) { // check component count of toolBar before adding button at toolBarIndex int componentCount = toolBar.getComponentCount(); if (componentCount > toolBarIndex) { // add horizontal space if component count > 0 if (componentCount > 0) { toolBar.add(Box.createHorizontalStrut(5)); } toolBar.add(button, toolBarIndex); } else { toolBar.add(button, componentCount); } }
From source file:uk.nhs.cfh.dsp.yasb.searchpanel.SearchPanel.java
/** * Creates the control panel.//w w w . ja va2s . c o m */ private synchronized void createControlPanel() { // set controls for rendering concept ids and labels in a collapsible pane controlsPane = new JXCollapsiblePane(new GridLayout(0, 1)); controlsPane.setName("controlsPane"); final JComboBox conceptTypeBox = new JComboBox(ConceptType.values()); // set default value to UNKNOWN, which will return all types conceptTypeBox.setSelectedItem(ConceptType.UNKNOWN); conceptTypeBox.setAction(new AbstractAction() { public void actionPerformed(ActionEvent e) { // get selected value Object selection = conceptTypeBox.getSelectedItem(); if (selection instanceof ConceptType) { selectedConceptType = (ConceptType) conceptTypeBox.getSelectedItem(); doSearch(); } } }); JPanel panel1 = new JPanel(); panel1.setLayout(new BoxLayout(panel1, BoxLayout.LINE_AXIS)); panel1.add(new JLabel("Concept Type")); panel1.add(Box.createHorizontalStrut(10)); panel1.add(conceptTypeBox); final JComboBox statusBox = new JComboBox(ComponentStatus.values()); statusBox.setSelectedItem(ComponentStatus.CURRENT); statusBox.setAction(new AbstractAction() { public void actionPerformed(ActionEvent arg0) { Object selection = statusBox.getSelectedItem(); if (selection instanceof ComponentStatus) { selectedConceptStatus = (ComponentStatus) statusBox.getSelectedItem(); doSearch(); } } }); JPanel panel2 = new JPanel(); panel2.setLayout(new BoxLayout(panel2, BoxLayout.LINE_AXIS)); panel2.add(new JLabel("Concept Status")); panel2.add(Box.createHorizontalStrut(10)); panel2.add(statusBox); // create stemming enabling checkbox final JCheckBox enableStemmingCheckBox = new JCheckBox(); enableStemmingCheckBox.setAction(new AbstractAction("Enable Stemming") { public void actionPerformed(ActionEvent arg0) { if (enableStemmingCheckBox.isSelected()) { // change analyser selectedAnalyzer = new SnowballAnalyzer("English"); logger.debug("Enabled Stemming"); doSearch(); } else { selectedAnalyzer = new StandardAnalyzer(); logger.debug("Disabled Stemming"); doSearch(); } } }); renderConceptIdsBox = new JCheckBox(new AbstractAction("Render Concept IDs") { public void actionPerformed(ActionEvent e) { // toggle status in tree cell renderer renderer.setRenderConceptId(renderConceptIdsBox.isSelected()); // refresh tree SwingUtilities.updateComponentTreeUI(resultsList); } }); renderConceptIdsBox.setName("preferFSNOverPTJCheckBox"); preferFSNOverPTJCheckBox = new JCheckBox(new AbstractAction("Prefer FSN over PT") { public void actionPerformed(ActionEvent e) { // toggle preference in renderer renderer.setPreferFSNOverPT(preferFSNOverPTJCheckBox.isSelected()); // refresh tree SwingUtilities.updateComponentTreeUI(resultsList); } }); preferFSNOverPTJCheckBox.setName("preferFSNOverPTJCheckBox"); // add panels to controlsPane controlsPane.add(panel1); controlsPane.add(panel2); controlsPane.add(enableStemmingCheckBox); controlsPane.add(renderConceptIdsBox); controlsPane.add(preferFSNOverPTJCheckBox); controlsPane.setCollapsed(true); }
From source file:uk.nhs.cfh.dsp.yasb.searchpanel.SearchPanel.java
/** * Creates the button panel.//ww w . j a v a2s .c o m */ private void createButtonPanel() { buttonsPanel = new JPanel(); buttonsPanel.setLayout(new BoxLayout(buttonsPanel, BoxLayout.PAGE_AXIS)); JPanel fieldsPanel = new JPanel(); fieldsPanel.add(new JLabel("Search using ")); fieldsPanel.add(Box.createHorizontalStrut(5)); fieldsPanel.setLayout(new BoxLayout(fieldsPanel, BoxLayout.LINE_AXIS)); // create button group for term selection JRadioButton allRadioButton = new JRadioButton(new AbstractAction("Term") { public void actionPerformed(ActionEvent event) { // set search on term searchConceptId = false; doSearch(); } }); JRadioButton idRadioButton = new JRadioButton(new AbstractAction("ID") { public void actionPerformed(ActionEvent event) { // set search on id searchConceptId = true; doSearch(); } }); ButtonGroup buttonGroup = new ButtonGroup(); buttonGroup.add(allRadioButton); buttonGroup.add(idRadioButton); buttonGroup.setSelected(allRadioButton.getModel(), true); // add search field terms to fields panel fieldsPanel.add(allRadioButton); fieldsPanel.add(idRadioButton); fieldsPanel.add(Box.createHorizontalGlue()); // create panel that contains button that toggles display of controlsPane JideButton controlsButton = new JideButton(new AbstractAction() { public void actionPerformed(ActionEvent e) { if (controlsPane.isCollapsed()) { controlsPane.setCollapsed(false); } else { controlsPane.setCollapsed(true); } } }); controlsButton.setIcon(new ImageIcon(SearchPanel.class.getResource("resources/configure.png"))); controlsButton.setToolTipText("Click to display or hide configuration panel"); JPanel panel4 = new JPanel(); panel4.setLayout(new BoxLayout(panel4, BoxLayout.LINE_AXIS)); panel4.add(Box.createHorizontalGlue()); panel4.add(new JLabel("Change search and display preferences ")); panel4.add(controlsButton); // add panels to button panel buttonsPanel.add(fieldsPanel); buttonsPanel.add(panel4); }
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);/*from www. j a v a2 s .c o m*/ 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:verdandi.ui.settings.DefaultSettingsPanel.java
private JPanel getTimeFormatSettingsPanel() { JPanel res = new JPanel(); res.setLayout(new BoxLayout(res, BoxLayout.LINE_AXIS)); radioFormatHHMM = new JRadioButton("01:45"); radioFormatHHQuarters = new JRadioButton("1,75"); ButtonGroup grp = new ButtonGroup(); grp.add(radioFormatHHMM);/* ww w . j av a2 s. co m*/ grp.add(radioFormatHHQuarters); res.add(radioFormatHHMM); res.add(Box.createHorizontalStrut(5)); res.add(radioFormatHHQuarters); res.setBorder(BorderFactory.createTitledBorder(RC.getString("settingseditor.timeformat.title"))); return res; }
From source file:verdandi.ui.settings.DefaultSettingsPanel.java
private JPanel getAnnotatedWorkRecordViewPrefs() { JPanel res = new JPanel(); res.setBorder(BorderFactory.createTitledBorder(RC.getString("settingseditor.annotatedworkview.title"))); res.setLayout(new BoxLayout(res, BoxLayout.LINE_AXIS)); initAnnotatedWorkRecordsOnStartup = new JCheckBox( RC.getString("settingseditor.annotatedworkview.doinitonstartup")); boolean selected = conf.getString(AnnotatedWorkRecordView.PREF_RESTORE_ON_INIT, "false") .equalsIgnoreCase("true"); initAnnotatedWorkRecordsOnStartup.setSelected(selected); res.add(Box.createHorizontalStrut(5)); res.add(initAnnotatedWorkRecordsOnStartup); res.add(Box.createHorizontalGlue()); return res;/*from w w w . j a v a2 s .c o m*/ }
From source file:VGL.SummaryChartUI.java
private void setupTraitSelectionPanel() { JPanel traitSelectionPanel = new JPanel(); traitSelectionPanel.setLayout(new BoxLayout(traitSelectionPanel, BoxLayout.X_AXIS)); traitSelectionPanel.setBorder(/*from w w w . j a va 2 s .co m*/ BorderFactory.createTitledBorder(Messages.getInstance().getString("VGLII.SortOffspringBy") + ":")); Trait[] traits = manager.getTraitSet(); traitCheckBoxes = new JCheckBox[traits.length]; traitCheckBoxLabels = new JLabel[traits.length]; //make the check boxes and labels for (int i = 0; i < traits.length; i++) { traitCheckBoxes[i] = new JCheckBox(); traitCheckBoxes[i].addActionListener(this); traitCheckBoxes[i].setSelected(true); traitCheckBoxLabels[i] = new JLabel(Messages.getInstance().getTranslatedCharacterName(traits[i])); } //put them in GUI in randomized order for (int i = 0; i < traits.length; i++) { traitSelectionPanel.add(traitCheckBoxLabels[scrambledTraitOrder[i]]); traitSelectionPanel.add(traitCheckBoxes[scrambledTraitOrder[i]]); traitSelectionPanel.add(Box.createHorizontalStrut(15)); } // add sex check box sexCheckBox = new JCheckBox(); sexCheckBox.addActionListener(this); sexCheckBox.setSelected(true); traitSelectionPanel.add(new JLabel(Messages.getInstance().getString("VGLII.Sex"))); traitSelectionPanel.add(sexCheckBox); traitSelectionPanel.add(Box.createHorizontalStrut(15)); add(traitSelectionPanel, BorderLayout.NORTH); add(resultPanel, BorderLayout.CENTER); chiSquaredLabel = new JLabel(CHI_SQUARE_DEFAULT); add(chiSquaredLabel, BorderLayout.SOUTH); }
From source file:xtrememp.PlaylistManager.java
private void initComponents() { JToolBar toolBar = new JToolBar(); toolBar.setFloatable(false);//www .java 2 s . c o m openPlaylistButton = new JButton(Utilities.DOCUMENT_OPEN_ICON); openPlaylistButton.setToolTipText(tr("MainFrame.PlaylistManager.OpenPlaylist")); openPlaylistButton.addActionListener(this); toolBar.add(openPlaylistButton); savePlaylistButton = new JButton(Utilities.DOCUMENT_SAVE_ICON); savePlaylistButton.setToolTipText(tr("MainFrame.PlaylistManager.SavePlaylist")); savePlaylistButton.addActionListener(this); toolBar.add(savePlaylistButton); toolBar.addSeparator(); addToPlaylistButton = new JButton(Utilities.LIST_ADD_ICON); addToPlaylistButton.setToolTipText(tr("MainFrame.PlaylistManager.AddToPlaylist")); addToPlaylistButton.addActionListener(this); toolBar.add(addToPlaylistButton); remFromPlaylistButton = new JButton(Utilities.LIST_REMOVE_ICON); remFromPlaylistButton.setToolTipText(tr("MainFrame.PlaylistManager.RemoveFromPlaylist")); remFromPlaylistButton.addActionListener(this); remFromPlaylistButton.setEnabled(false); toolBar.add(remFromPlaylistButton); clearPlaylistButton = new JButton(Utilities.EDIT_CLEAR_ICON); clearPlaylistButton.setToolTipText(tr("MainFrame.PlaylistManager.ClearPlaylist")); clearPlaylistButton.addActionListener(this); clearPlaylistButton.setEnabled(false); toolBar.add(clearPlaylistButton); toolBar.addSeparator(); moveUpButton = new JButton(Utilities.GO_UP_ICON); moveUpButton.setToolTipText(tr("MainFrame.PlaylistManager.MoveUp")); moveUpButton.addActionListener(this); moveUpButton.setEnabled(false); toolBar.add(moveUpButton); moveDownButton = new JButton(Utilities.GO_DOWN_ICON); moveDownButton.setToolTipText(tr("MainFrame.PlaylistManager.MoveDown")); moveDownButton.addActionListener(this); moveDownButton.setEnabled(false); toolBar.add(moveDownButton); toolBar.addSeparator(); mediaInfoButton = new JButton(Utilities.MEDIA_INFO_ICON); mediaInfoButton.setToolTipText(tr("MainFrame.PlaylistManager.MediaInfo")); mediaInfoButton.addActionListener(this); mediaInfoButton.setEnabled(false); toolBar.add(mediaInfoButton); toolBar.add(Box.createHorizontalGlue()); searchTextField = new SearchTextField(15); searchTextField.setMaximumSize(new Dimension(120, searchTextField.getPreferredSize().height)); searchTextField.getTextField().getDocument().addDocumentListener(new SearchFilterListener()); toolBar.add(searchTextField); toolBar.add(Box.createHorizontalStrut(6)); this.add(toolBar, BorderLayout.NORTH); playlistTable = new JTable(playlistTableModel, playlistTableColumnModel); playlistTable.setDefaultRenderer(String.class, new PlaylistCellRenderer()); playlistTable.setActionMap(null); playlistTable.getTableHeader().addMouseListener(new MouseAdapter() { @Override public void mouseClicked(MouseEvent ev) { if (SwingUtilities.isRightMouseButton(ev) || (MouseInfo.getNumberOfButtons() == 1 && ev.isControlDown())) { playlistTableColumnModel.getPopupMenu().show(playlistTable.getTableHeader(), ev.getX(), ev.getY()); return; } int clickedColumn = playlistTableColumnModel.getColumnIndexAtX(ev.getX()); PlaylistTableColumn playlistColumn = playlistTableColumnModel.getColumn(clickedColumn); playlistTableColumnModel.resetAll(playlistColumn.getModelIndex()); playlistColumn.setSortOrderUp(!playlistColumn.isSortOrderUp()); playlistTableModel.sort(playlistColumn.getComparator()); colorizeRow(); } }); playlistTable.setFillsViewportHeight(true); playlistTable.setShowGrid(false); playlistTable.setRowSelectionAllowed(true); playlistTable.setColumnSelectionAllowed(false); playlistTable.setDragEnabled(false); playlistTable.setFont(playlistTable.getFont().deriveFont(Font.BOLD)); playlistTable.setIntercellSpacing(new Dimension(0, 0)); playlistTable.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION); playlistTable.addMouseListener(new MouseAdapter() { @Override public void mouseClicked(MouseEvent ev) { int selectedRow = playlistTable.rowAtPoint(ev.getPoint()); if (SwingUtilities.isLeftMouseButton(ev) && ev.getClickCount() == 2) { if (selectedRow != -1) { playlist.setCursorPosition(selectedRow); controlListener.acOpenAndPlay(); } } } }); playlistTable.getSelectionModel().addListSelectionListener(this); playlistTable.getColumnModel().getSelectionModel().addListSelectionListener(this); playlistTable.addKeyListener(new KeyAdapter() { @Override public void keyPressed(KeyEvent e) { // View Media Info if (e.getKeyCode() == KeyEvent.VK_I && e.getModifiers() == KeyEvent.CTRL_MASK) { viewMediaInfo(); } // Select all else if (e.getKeyCode() == KeyEvent.VK_A && e.getModifiers() == KeyEvent.CTRL_MASK) { playlistTable.selectAll(); } else if (e.getKeyCode() == KeyEvent.VK_UP) { // Move selected track(s) up if (e.getModifiers() == KeyEvent.ALT_MASK) { moveUp(); } // Select previous track else { if (playlistTable.getSelectedRow() > 0) { int previousRowIndex = playlistTable.getSelectedRow() - 1; playlistTable.clearSelection(); playlistTable.addRowSelectionInterval(previousRowIndex, previousRowIndex); makeRowVisible(previousRowIndex); } } } else if (e.getKeyCode() == KeyEvent.VK_DOWN) { // Move selected track(s) down if (e.getModifiers() == KeyEvent.ALT_MASK) { moveDown(); } // Select next track else { if (playlistTable.getSelectedRow() < playlistTable.getRowCount() - 1) { int nextRowIndex = playlistTable.getSelectedRow() + 1; playlistTable.clearSelection(); playlistTable.addRowSelectionInterval(nextRowIndex, nextRowIndex); makeRowVisible(nextRowIndex); } } } // Play selected track else if (e.getKeyCode() == KeyEvent.VK_ENTER) { int selectedRow = playlistTable.getSelectedRow(); if (selectedRow != -1) { playlist.setCursorPosition(selectedRow); controlListener.acOpenAndPlay(); } } // Add new tracks else if (e.getKeyCode() == KeyEvent.VK_INSERT) { addFilesDialog(false); } // Delete selected tracks else if (e.getKeyCode() == KeyEvent.VK_DELETE) { remove(); } } }); XtremeMP.getInstance().getMainFrame().setDropTarget(new DropTarget(playlistTable, this)); JScrollPane ptScrollPane = new JScrollPane(playlistTable); ptScrollPane.setActionMap(null); this.add(ptScrollPane, BorderLayout.CENTER); }