List of usage examples for javax.swing SwingConstants LEFT
int LEFT
To view the source code for javax.swing SwingConstants LEFT.
Click Source Link
From source file:org.interreg.docexplore.GeneralConfigPanel.java
public GeneralConfigPanel(final File config) throws Exception { this.configFile = config; final String xml = config.exists() ? StringUtils.readFile(config) : "<config></config>"; setLayout(new LooseGridLayout(0, 1, 5, 5, true, true, SwingConstants.LEFT, SwingConstants.TOP)); // JPanel ac = new JPanel(new LooseGridLayout(0, 1, 5, 5, false, true, SwingConstants.LEFT, SwingConstants.TOP)); // ac.setBorder(BorderFactory.createTitledBorder(XMLResourceBundle.getBundledString("cfgACLabel"))); // ac.add(useAutoConnect = new JCheckBox(XMLResourceBundle.getBundledString("cfgUseACLabel"))); // JPanel typePanel = new JPanel(new FlowLayout(FlowLayout.LEFT)); // typePanel.add(new JLabel(XMLResourceBundle.getBundledString("cfgTypeLabel"))); // typePanel.add(autoConnectType = new JComboBox(new Object [] {XMLResourceBundle.getBundledString("cfgFileLabel"), XMLResourceBundle.getBundledString("cfgMysqlLabel")})); // ac.add(typePanel); // ac.add(autoConnectSubPanel = new JPanel(new BorderLayout())); // /*from w w w.j a v a2 s . c om*/ // fsSubPanel = new JPanel(new LooseGridLayout(0, 2, 5, 5, false, true, SwingConstants.LEFT, SwingConstants.TOP)); // fsSubPanel.add(new JLabel(XMLResourceBundle.getBundledString("cfgPathLabel"))); fsSubPanel.add(acFSPath = new JTextField(40)); // // dbSubPanel = new JPanel(new LooseGridLayout(0, 2, 5, 5, false, true, SwingConstants.LEFT, SwingConstants.TOP)); // dbSubPanel.add(new JLabel(XMLResourceBundle.getBundledString("cfgPathLabel"))); dbSubPanel.add(acDBPath = new JTextField(40)); // dbSubPanel.add(new JLabel(XMLResourceBundle.getBundledString("cfgHostLabel"))); dbSubPanel.add(acDBHost = new JTextField(40)); // dbSubPanel.add(new JLabel(XMLResourceBundle.getBundledString("cfgDBLabel"))); dbSubPanel.add(acDBDatabase = new JTextField(40)); // dbSubPanel.add(new JLabel(XMLResourceBundle.getBundledString("cfgUserLabel"))); dbSubPanel.add(acDBUser = new JTextField(40)); // dbSubPanel.add(new JLabel(XMLResourceBundle.getBundledString("cfgPasswordLabel"))); dbSubPanel.add(acDBPassword = new JTextField(40)); // // Set<ConnectionHandler.PastConnection> cons = new ConnectionHandler().connections; // if (cons != null) // { // Vector<Object> recentCons = new Vector<Object>(); // for (ConnectionHandler.PastConnection con : cons) // if (con.source instanceof DataLinkMySQLSource || con.source instanceof DataLinkFS2Source) // recentCons.add(con); // // if (!recentCons.isEmpty()) // { // recentCons.insertElementAt(XMLResourceBundle.getBundledString("cfgCurrentLabel"), 0); // JPanel recentPanel = new JPanel(new FlowLayout(FlowLayout.LEFT)); // recentPanel.add(new JLabel(XMLResourceBundle.getBundledString("cfgRecentLabel"))); // JComboBox recentBox = new JComboBox(recentCons); // recentPanel.add(recentBox); // ac.add(recentPanel); // // recentBox.addItemListener(new ItemListener() {public void itemStateChanged(ItemEvent e) // { // if (e.getStateChange() != ItemEvent.SELECTED) // return; // if (e.getItem().equals(XMLResourceBundle.getBundledString("cfgCurrentLabel"))) // fillAutoConnect(xml); // else fillAutoConnect((ConnectionHandler.PastConnection)e.getItem()); // }}); // } // } JPanel display = new JPanel( new LooseGridLayout(0, 1, 5, 5, false, true, SwingConstants.LEFT, SwingConstants.TOP)); display.setBorder(BorderFactory.createTitledBorder(XMLResourceBundle.getBundledString("cfgDisplayLabel"))); JPanel displayDims = new JPanel( new LooseGridLayout(0, 2, 5, 5, false, true, SwingConstants.LEFT, SwingConstants.TOP)); displayDims.add(new JLabel(XMLResourceBundle.getBundledString("cfgWidthLabel"))); displayDims.add(displayWidth = new JTextField(5)); displayDims.add(new JLabel(XMLResourceBundle.getBundledString("cfgHeightLabel"))); displayDims.add(displayHeight = new JTextField(5)); displayDims.add(new JLabel(XMLResourceBundle.getBundledString("cfgLanguageLabel"))); displayDims.add( displayLang = new JComboBox(new Object[] { XMLResourceBundle.getBundledString("cfgEnglishLabel"), XMLResourceBundle.getBundledString("cfgFrenchLabel") })); display.add(displayHelp = new JCheckBox(XMLResourceBundle.getBundledString("cfgHelpLabel"))); display.add(displayFullscreen = new JCheckBox(XMLResourceBundle.getBundledString("cfgFullscreenLabel"))); display.add(displayNativeCursor = new JCheckBox(XMLResourceBundle.getBundledString("cfgUseCursorLabel"))); display.add(displayDims); JPanel topPluginsPanel = new JPanel( new LooseGridLayout(0, 1, 5, 5, true, true, SwingConstants.LEFT, SwingConstants.TOP)); topPluginsPanel .setBorder(BorderFactory.createTitledBorder(XMLResourceBundle.getBundledString("cfgPluginsLabel"))); pluginsPanel = new JPanel( new LooseGridLayout(0, 1, 5, 5, true, false, SwingConstants.LEFT, SwingConstants.TOP, true, false)); JScrollPane scrollPane = new JScrollPane(pluginsPanel, JScrollPane.VERTICAL_SCROLLBAR_ALWAYS, JScrollPane.HORIZONTAL_SCROLLBAR_NEVER); scrollPane.setPreferredSize(new Dimension(500, 300)); scrollPane.getVerticalScrollBar().setUnitIncrement(10); topPluginsPanel.add(scrollPane); JPanel addPanel = new JPanel(new FlowLayout(FlowLayout.LEFT)); addPanel.add(new JButton(new AbstractAction(XMLResourceBundle.getBundledString("cfgAddPluginLabel")) { public void actionPerformed(ActionEvent e) { try { JOptionPane.showMessageDialog(GeneralConfigPanel.this, XMLResourceBundle.getBundledString("cfgAddPluginMessage").replace("%pdir", DocExploreTool.getPluginDir().getAbsolutePath())); if (System.getProperty("os.name").toLowerCase().contains("win")) Runtime.getRuntime() .exec(new String[] { "explorer", DocExploreTool.getPluginDir().getAbsolutePath() }); else if (System.getProperty("os.name").toLowerCase().contains("mac")) Runtime.getRuntime() .exec(new String[] { "open", DocExploreTool.getPluginDir().getAbsolutePath() }); } catch (Exception ex) { ErrorHandler.defaultHandler.submit(ex); } // File jarFile = browsePlugins(); // if (jarFile == null) // return; // PluginPanel pluginPanel = new PluginPanel(GeneralConfigPanel.this, "yes", jarFile.getName(), ""); // pluginPanels.add(pluginPanel); // pluginsPanel.add(pluginPanel); // ((Window)getTopLevelAncestor()).pack(); } })); addPanel.add(new JButton(new AbstractAction(XMLResourceBundle.getBundledString("cfgRefreshPluginsLabel")) { public void actionPerformed(ActionEvent e) { refreshPlugins(xml); ((Window) getTopLevelAncestor()).pack(); } })); topPluginsPanel.add(addPanel); // setAutoConnectSubPanel(fsSubPanel); // add(ac); add(display); add(topPluginsPanel); add(safeMode = new JCheckBox(XMLResourceBundle.getBundledString("cfgSafeModeLabel"))); // autoConnectType.addItemListener(new ItemListener() {public void itemStateChanged(ItemEvent e) // { // if (e.getStateChange() != ItemEvent.SELECTED) // return; // if (e.getItem().equals(XMLResourceBundle.getBundledString("cfgFileLabel"))) // setAutoConnectSubPanel(fsSubPanel); // else setAutoConnectSubPanel(dbSubPanel); // Window top = (Window)getTopLevelAncestor(); // if (top != null) // top.pack(); // }}); if (xml != null) fill(xml); }
From source file:org.interreg.docexplore.ServerConfigPanel.java
public ServerConfigPanel(final File config, final File serverDir) throws Exception { super(new LooseGridLayout(0, 1, 5, 5, true, false, SwingConstants.LEFT, SwingConstants.TOP, true, false)); this.serverDir = serverDir; this.books = new Vector<Book>(); this.bookList = new JList(new DefaultListModel()); JPanel listPanel = new JPanel(new BorderLayout()); listPanel.setBorder(BorderFactory.createTitledBorder(XMLResourceBundle.getBundledString("cfgBooksLabel"))); bookList.setOpaque(false);/*from w w w . j ava 2 s . com*/ bookList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); bookList.setCellRenderer(new ListCellRenderer() { public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) { Book book = (Book) value; JLabel label = new JLabel("<html><b>" + book.name + "</b> - " + book.nPages + " pages</html>"); label.setOpaque(true); if (isSelected) { label.setBackground(TextToolbar.styleHighLightedBackground); label.setForeground(Color.white); } if (book.deleted) label.setForeground(Color.red); else if (!book.used) label.setForeground(Color.gray); return label; } }); bookList.addListSelectionListener(new ListSelectionListener() { public void valueChanged(ListSelectionEvent e) { if (e.getValueIsAdjusting()) return; setFields((Book) bookList.getSelectedValue()); } }); JScrollPane scrollPane = new JScrollPane(bookList, JScrollPane.VERTICAL_SCROLLBAR_ALWAYS, JScrollPane.HORIZONTAL_SCROLLBAR_NEVER); scrollPane.setPreferredSize(new Dimension(500, 300)); scrollPane.getVerticalScrollBar().setUnitIncrement(10); listPanel.add(scrollPane, BorderLayout.CENTER); JPanel importPanel = new JPanel(new FlowLayout(FlowLayout.CENTER)); importPanel.add(new JButton(new AbstractAction(XMLResourceBundle.getBundledString("cfgImportLabel")) { public void actionPerformed(ActionEvent e) { final File inFile = DocExploreTool.getFileDialogs().openFile(DocExploreTool.getIBookCategory()); if (inFile == null) return; try { final File tmpDir = new File(serverDir, "tmp"); tmpDir.mkdir(); GuiUtils.blockUntilComplete(new ProgressRunnable() { float[] progress = { 0 }; public void run() { try { ZipUtils.unzip(inFile, tmpDir, progress); } catch (Exception ex) { ErrorHandler.defaultHandler.submit(ex); } } public float getProgress() { return (float) progress[0]; } }, ServerConfigPanel.this); File tmpFile = new File(tmpDir, "index.tmp"); ObjectInputStream input = new ObjectInputStream(new FileInputStream(tmpFile)); String bookFile = input.readUTF(); String bookName = input.readUTF(); String bookDesc = input.readUTF(); input.close(); new PresentationImporter().doImport(ServerConfigPanel.this, bookName, bookDesc, new File(tmpDir, bookFile)); FileUtils.cleanDirectory(tmpDir); FileUtils.deleteDirectory(tmpDir); updateBooks(); } catch (Exception ex) { ErrorHandler.defaultHandler.submit(ex); } } })); listPanel.add(importPanel, BorderLayout.SOUTH); add(listPanel); JPanel setupPanel = new JPanel( new LooseGridLayout(0, 1, 5, 5, true, false, SwingConstants.LEFT, SwingConstants.TOP, true, false)); setupPanel.setBorder( BorderFactory.createTitledBorder(XMLResourceBundle.getBundledString("cfgBookInfoLabel"))); usedBox = new JCheckBox(XMLResourceBundle.getBundledString("cfgUseLabel")); usedBox.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { Book book = (Book) bookList.getSelectedValue(); if (book != null) { book.used = usedBox.isSelected(); bookList.repaint(); } } }); setupPanel.add(usedBox); JPanel fieldPanel = new JPanel(new LooseGridLayout(0, 2, 5, 5, false, false, SwingConstants.LEFT, SwingConstants.TOP, true, false)); fieldPanel.add(new JLabel(XMLResourceBundle.getBundledString("cfgTitleLabel"))); nameField = new JTextField(50); nameField.getDocument().addDocumentListener(new DocumentListener() { public void removeUpdate(DocumentEvent e) { changedUpdate(e); } public void insertUpdate(DocumentEvent e) { changedUpdate(e); } public void changedUpdate(DocumentEvent e) { Book book = (Book) bookList.getSelectedValue(); if (book == null) return; book.name = nameField.getText(); bookList.repaint(); } }); fieldPanel.add(nameField); fieldPanel.add(new JLabel(XMLResourceBundle.getBundledString("cfgDescriptionLabel"))); descField = new JTextPane(); //descField.setWrapStyleWord(true); descField.getDocument().addDocumentListener(new DocumentListener() { public void removeUpdate(DocumentEvent e) { changedUpdate(e); } public void insertUpdate(DocumentEvent e) { changedUpdate(e); } public void changedUpdate(DocumentEvent e) { Book book = (Book) bookList.getSelectedValue(); if (book == null) return; book.desc = descField.getText(); } }); scrollPane = new JScrollPane(descField, JScrollPane.VERTICAL_SCROLLBAR_ALWAYS, JScrollPane.HORIZONTAL_SCROLLBAR_NEVER); scrollPane.setPreferredSize(new Dimension(420, 50)); scrollPane.getVerticalScrollBar().setUnitIncrement(10); fieldPanel.add(scrollPane); setupPanel.add(fieldPanel); exportButton = new JButton(new AbstractAction(XMLResourceBundle.getBundledString("cfgExportLabel")) { public void actionPerformed(ActionEvent e) { File file = DocExploreTool.getFileDialogs().saveFile(DocExploreTool.getIBookCategory()); if (file == null) return; final Book book = (Book) bookList.getSelectedValue(); final File indexFile = new File(serverDir, "index.tmp"); try { final File outFile = file; ObjectOutputStream out = new ObjectOutputStream(new FileOutputStream(indexFile)); out.writeUTF(book.bookFile.getName()); out.writeUTF(book.name); out.writeUTF(book.desc); out.close(); GuiUtils.blockUntilComplete(new ProgressRunnable() { float[] progress = { 0 }; public void run() { try { ZipUtils.zip(serverDir, new File[] { indexFile, book.bookFile, book.bookDir }, outFile, progress, 0, 1, 9); } catch (Exception ex) { ErrorHandler.defaultHandler.submit(ex); } } public float getProgress() { return (float) progress[0]; } }, ServerConfigPanel.this); } catch (Exception ex) { ErrorHandler.defaultHandler.submit(ex); } if (indexFile.exists()) indexFile.delete(); } }); deleteButton = new JButton(new AbstractAction(XMLResourceBundle.getBundledString("cfgDeleteRestoreLabel")) { public void actionPerformed(ActionEvent e) { Book book = (Book) bookList.getSelectedValue(); if (book == null) return; book.deleted = !book.deleted; bookList.repaint(); } }); JPanel actionsPanel = new JPanel(new FlowLayout(FlowLayout.CENTER)); actionsPanel.add(exportButton); actionsPanel.add(deleteButton); setupPanel.add(actionsPanel); add(setupPanel); JPanel optionsPanel = new JPanel(new LooseGridLayout(0, 2, 5, 5, false, false, SwingConstants.LEFT, SwingConstants.TOP, true, false)); optionsPanel .setBorder(BorderFactory.createTitledBorder(XMLResourceBundle.getBundledString("cfgOptionsLabel"))); JPanel timeoutPanel = new JPanel(new FlowLayout(FlowLayout.LEFT)); timeoutField = new JTextField(5); timeoutPanel.add(timeoutField); timeoutPanel.add(new JLabel(XMLResourceBundle.getBundledString("cfgTimeoutLabel"))); optionsPanel.add(timeoutPanel); add(optionsPanel); updateBooks(); setFields(null); final String xml = config.exists() ? StringUtils.readFile(config) : "<config></config>"; String idle = StringUtils.getTagContent(xml, "idle"); if (idle != null) try { timeoutField.setText("" + Integer.parseInt(idle)); } catch (Throwable e) { } }
From source file:org.isatools.isacreatorconfigurator.configui.FieldInterface.java
private void instantiateFields(String initFieldName) { // OVERALL CONTAINER JPanel container = new JPanel(); container.setLayout(new BoxLayout(container, BoxLayout.PAGE_AXIS)); container.setBackground(UIHelper.BG_COLOR); JLabel fieldDefinitionLab = new JLabel(fieldDefinitionHeader, JLabel.CENTER); container.add(fieldDefinitionLab);// ww w . j a v a 2s .c o m container.add(Box.createVerticalStrut(5)); // FIELD LABEL & INPUT BOX CONTAINER JPanel fieldCont = new JPanel(new GridLayout(1, 2)); fieldCont.setBackground(UIHelper.BG_COLOR); fieldName = new RoundedJTextField(15); fieldName.setText(initFieldName); fieldName.setEditable(false); UIHelper.renderComponent(fieldName, UIHelper.VER_11_PLAIN, UIHelper.DARK_GREEN_COLOR, false); JLabel fieldNameLab = UIHelper.createLabel("Field Name: ", UIHelper.VER_11_BOLD, UIHelper.DARK_GREEN_COLOR); fieldCont.add(fieldNameLab); fieldCont.add(fieldName); container.add(fieldCont); JPanel descCont = new JPanel(new GridLayout(1, 2)); descCont.setBackground(UIHelper.BG_COLOR); description = new RoundedJTextArea(); description.setLineWrap(true); description.setWrapStyleWord(true); UIHelper.renderComponent(description, UIHelper.VER_11_PLAIN, UIHelper.DARK_GREEN_COLOR, false); JScrollPane descScroll = new JScrollPane(description, JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED, JScrollPane.HORIZONTAL_SCROLLBAR_NEVER); descScroll.setBackground(UIHelper.BG_COLOR); descScroll.setPreferredSize(new Dimension(150, 65)); descScroll.getViewport().setBackground(UIHelper.BG_COLOR); IAppWidgetFactory.makeIAppScrollPane(descScroll); JLabel descLab = UIHelper.createLabel("Description: ", UIHelper.VER_11_BOLD, UIHelper.DARK_GREEN_COLOR); descLab.setVerticalAlignment(JLabel.TOP); descCont.add(descLab); descCont.add(descScroll); container.add(descCont); // add datatype information JPanel datatypeCont = new JPanel(new GridLayout(1, 2)); datatypeCont.setBackground(UIHelper.BG_COLOR); DataTypes[] allowedDataTypes = initFieldName.equals(UNIT_STR) ? new DataTypes[] { DataTypes.ONTOLOGY_TERM } : DataTypes.values(); datatype = new JComboBox(allowedDataTypes); datatype.addActionListener(this); UIHelper.renderComponent(datatype, UIHelper.VER_11_PLAIN, UIHelper.DARK_GREEN_COLOR, UIHelper.BG_COLOR); JLabel dataTypeLab = UIHelper.createLabel("Datatype:", UIHelper.VER_11_BOLD, UIHelper.DARK_GREEN_COLOR); datatypeCont.add(dataTypeLab); datatypeCont.add(datatype); container.add(datatypeCont); defaultValContStd = new JPanel(new GridLayout(1, 2)); defaultValContStd.setBackground(UIHelper.BG_COLOR); defaultValCont = Box.createHorizontalBox(); defaultValCont.setPreferredSize(new Dimension(150, 25)); defaultValStd = new RoundedFormattedTextField(null, UIHelper.TRANSPARENT_LIGHT_GREEN_COLOR, UIHelper.DARK_GREEN_COLOR); defaultValCont.setPreferredSize(new Dimension(120, 25)); defaultValStd.setFormatterFactory(new DefaultFormatterFactory( new RegExFormatter(".*", defaultValStd, false, UIHelper.DARK_GREEN_COLOR, UIHelper.RED_COLOR, UIHelper.TRANSPARENT_LIGHT_GREEN_COLOR, UIHelper.TRANSPARENT_LIGHT_GREEN_COLOR))); defaultValStd.setForeground(UIHelper.DARK_GREEN_COLOR); defaultValStd.setFont(UIHelper.VER_11_PLAIN); defaultValCont.add(defaultValStd); defaultValLabStd = UIHelper.createLabel(DEFAULT_VAL_STR, UIHelper.VER_11_BOLD, UIHelper.DARK_GREEN_COLOR); defaultValContStd.add(defaultValLabStd); defaultValContStd.add(defaultValCont); container.add(defaultValContStd); defaultValContBool = new JPanel(new GridLayout(1, 2)); defaultValContBool.setBackground(UIHelper.BG_COLOR); defaultValContBool.setVisible(false); listDataSourceCont = new JPanel(new GridLayout(2, 1)); listDataSourceCont.setBackground(UIHelper.BG_COLOR); listDataSourceCont.setVisible(false); JLabel listValLab = UIHelper.createLabel("Please enter comma separated list of values:", UIHelper.VER_11_BOLD, UIHelper.DARK_GREEN_COLOR); listDataSourceCont.add(listValLab); listValues = new RoundedJTextArea("SampleVal1, SampleVal2, SampleVal3", 3, 5); listValues.setLineWrap(true); listValues.setWrapStyleWord(true); UIHelper.renderComponent(listValues, UIHelper.VER_11_PLAIN, UIHelper.DARK_GREEN_COLOR, false); JScrollPane listScroll = new JScrollPane(listValues, JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED, JScrollPane.HORIZONTAL_SCROLLBAR_NEVER); listScroll.setBackground(UIHelper.BG_COLOR); listScroll.getViewport().setBackground(UIHelper.BG_COLOR); listDataSourceCont.add(listScroll); container.add(listDataSourceCont); IAppWidgetFactory.makeIAppScrollPane(listScroll); sourceEntryPanel = new JPanel(new BorderLayout()); sourceEntryPanel.setSize(new Dimension(125, 190)); sourceEntryPanel.setOpaque(false); sourceEntryPanel.setVisible(false); preferredOntologySource = new JPanel(); preferredOntologySource.setLayout(new BoxLayout(preferredOntologySource, BoxLayout.PAGE_AXIS)); preferredOntologySource.setVisible(false); recommendOntologySource = new JCheckBox("Use recommended ontology source?", false); UIHelper.renderComponent(recommendOntologySource, UIHelper.VER_11_BOLD, UIHelper.DARK_GREEN_COLOR, false); recommendOntologySource.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { if (recommendOntologySource.isSelected()) { sourceEntryPanel.setVisible(true); } else { sourceEntryPanel.setVisible(false); } } }); JPanel useOntologySourceCont = new JPanel(new GridLayout(1, 1)); useOntologySourceCont.add(recommendOntologySource); preferredOntologySource.add(useOntologySourceCont); JPanel infoCont = new JPanel(new GridLayout(1, 1)); JLabel infoLab = UIHelper.createLabel( "<html>click on the <strong>configure ontologies</strong> button to open the ontology configurator to edit the list of ontologies and search areas within an ontology</html>", UIHelper.VER_11_PLAIN, UIHelper.DARK_GREEN_COLOR); infoLab.setPreferredSize(new Dimension(100, 40)); infoCont.add(infoLab); sourceEntryPanel.add(infoCont, BorderLayout.NORTH); JLabel preferredOntologiesLab = new JLabel(preferredOntologiesSidePanelIcon); preferredOntologiesLab.setVerticalAlignment(SwingConstants.TOP); sourceEntryPanel.add(preferredOntologiesLab, BorderLayout.WEST); ontologiesToUseModel = new DefaultTableModel(new String[0][2], ontologyColumnHeaders) { @Override public boolean isCellEditable(int i, int i1) { return false; } }; ontologiesToUse = new JTable(ontologiesToUseModel); ontologiesToUse.getTableHeader().setBackground(UIHelper.BG_COLOR); try { ontologiesToUse.setDefaultRenderer(Class.forName("java.lang.Object"), new CustomSpreadsheetCellRenderer()); } catch (ClassNotFoundException e) { // empty } renderTableHeader(); JScrollPane ontologiesToUseScroller = new JScrollPane(ontologiesToUse, JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED, JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED); ontologiesToUseScroller.setBorder(new EmptyBorder(0, 0, 0, 0)); ontologiesToUseScroller.setPreferredSize(new Dimension(100, 80)); ontologiesToUseScroller.setBackground(UIHelper.BG_COLOR); ontologiesToUseScroller.getViewport().setBackground(UIHelper.BG_COLOR); IAppWidgetFactory.makeIAppScrollPane(ontologiesToUseScroller); sourceEntryPanel.add(ontologiesToUseScroller); JPanel buttonCont = new JPanel(new BorderLayout()); final JLabel openConfigButton = new JLabel(ontologyConfigIcon); openConfigButton.setVerticalAlignment(SwingConstants.TOP); openConfigButton.setHorizontalAlignment(SwingConstants.RIGHT); MouseAdapter showOntologyConfigurator = new MouseAdapter() { public void mouseEntered(MouseEvent mouseEvent) { openConfigButton.setIcon(ontologyConfigIconOver); } public void mouseExited(MouseEvent mouseEvent) { openConfigButton.setIcon(ontologyConfigIcon); } public void mousePressed(MouseEvent mouseEvent) { SwingUtilities.invokeLater(new Runnable() { public void run() { if (openConfigButton.isEnabled()) { openConfigButton.setIcon(ontologyConfigIcon); ontologyConfig = new OntologyConfigUI(ontologiesToQuery, selectedOntologies); ontologyConfig.addPropertyChangeListener("ontologySelected", new PropertyChangeListener() { public void propertyChange(PropertyChangeEvent propertyChangeEvent) { selectedOntologies = (ListOrderedMap<String, RecommendedOntology>) propertyChangeEvent .getNewValue(); updateTable(); } }); showPopupInCenter(ontologyConfig); } } }); } }; openConfigButton.addMouseListener(showOntologyConfigurator); buttonCont.add(openConfigButton, BorderLayout.EAST); sourceEntryPanel.add(buttonCont, BorderLayout.SOUTH); preferredOntologySource.add(sourceEntryPanel); container.add(preferredOntologySource); String[] contents = new String[] { "true", "false" }; defaultValBool = new JComboBox(contents); UIHelper.renderComponent(defaultValBool, UIHelper.VER_12_PLAIN, UIHelper.DARK_GREEN_COLOR, UIHelper.BG_COLOR); JLabel defaultValLabBool = UIHelper.createLabel(DEFAULT_VAL_STR, UIHelper.VER_12_BOLD, UIHelper.DARK_GREEN_COLOR); defaultValContBool.add(defaultValLabBool); defaultValContBool.add(defaultValBool); container.add(defaultValContBool); // RegExp data entry isInputFormatted = new JCheckBox("Is the input formatted?", false); isInputFormatted.setComponentOrientation(ComponentOrientation.RIGHT_TO_LEFT); isInputFormatted.setHorizontalAlignment(SwingConstants.LEFT); UIHelper.renderComponent(isInputFormatted, UIHelper.VER_11_BOLD, UIHelper.DARK_GREEN_COLOR, false); isInputFormatted.addActionListener(this); container.add(UIHelper.wrapComponentInPanel(isInputFormatted)); inputFormatCont = new JPanel(); inputFormatCont.setLayout(new BoxLayout(inputFormatCont, BoxLayout.LINE_AXIS)); inputFormatCont.setVisible(false); inputFormatCont.setBackground(UIHelper.BG_COLOR); inputFormat = new RoundedJTextField(10); inputFormat.setText(".*"); inputFormat.setSize(new Dimension(150, 19)); inputFormat.setPreferredSize(new Dimension(160, 25)); inputFormat.setToolTipText("Field expects a regular expression describing the input format."); UIHelper.renderComponent(inputFormat, UIHelper.VER_11_PLAIN, UIHelper.DARK_GREEN_COLOR, false); JLabel inputFormatLab = UIHelper.createLabel("Input format:", UIHelper.VER_11_BOLD, UIHelper.DARK_GREEN_COLOR); inputFormatLab.setVerticalAlignment(SwingConstants.TOP); inputFormatCont.add(inputFormatLab); inputFormatCont.add(inputFormat); JLabel checkRegExp = new JLabel(checkRegExIcon, JLabel.RIGHT); checkRegExp.setOpaque(false); checkRegExp.addMouseListener(new MouseAdapter() { public void mousePressed(MouseEvent event) { String regexToCheck = inputFormat.getText(); final CheckRegExGUI regexChecker = new CheckRegExGUI(regexToCheck); SwingUtilities.invokeLater(new Runnable() { public void run() { regexChecker.createGUI(); } }); regexChecker.addPropertyChangeListener("close", new PropertyChangeListener() { public void propertyChange(PropertyChangeEvent evt) { main.getApplicationContainer().hideSheet(); } }); SwingUtilities.invokeLater(new Runnable() { public void run() { main.getApplicationContainer().showJDialogAsSheet(regexChecker); } }); } } ); inputFormatCont.add(checkRegExp); container.add(inputFormatCont); usesTemplateForWizard = new JCheckBox("Requires template for wizard?", false); usesTemplateForWizard.setComponentOrientation(ComponentOrientation.RIGHT_TO_LEFT); usesTemplateForWizard.setHorizontalAlignment(SwingConstants.LEFT); UIHelper.renderComponent(usesTemplateForWizard, UIHelper.VER_11_BOLD, UIHelper.DARK_GREEN_COLOR, false); usesTemplateForWizard.addActionListener(this); container.add(UIHelper.wrapComponentInPanel(usesTemplateForWizard)); wizardTemplatePanel = new JPanel(new GridLayout(1, 2)); wizardTemplatePanel.setVisible(false); wizardTemplatePanel.setBackground(UIHelper.BG_COLOR); wizardTemplate = new RoundedJTextArea(); wizardTemplate.setToolTipText("A template for the wizard to auto-create the data..."); wizardTemplate.setLineWrap(true); wizardTemplate.setWrapStyleWord(true); UIHelper.renderComponent(wizardTemplate, UIHelper.VER_11_PLAIN, UIHelper.DARK_GREEN_COLOR, false); JScrollPane wizScroll = new JScrollPane(wizardTemplate, JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED, JScrollPane.HORIZONTAL_SCROLLBAR_NEVER); wizScroll.getViewport().setBackground(UIHelper.BG_COLOR); wizScroll.setPreferredSize(new Dimension(70, 60)); IAppWidgetFactory.makeIAppScrollPane(wizScroll); JLabel wizardTemplateLab = UIHelper.createLabel("Template definition:", UIHelper.VER_11_BOLD, UIHelper.DARK_GREEN_COLOR); wizardTemplateLab.setVerticalAlignment(JLabel.TOP); wizardTemplatePanel.add(wizardTemplateLab); wizardTemplatePanel.add(wizScroll); container.add(wizardTemplatePanel); JPanel checkCont = new JPanel(new GridLayout(3, 2)); checkCont.setBackground(UIHelper.BG_COLOR); checkCont.setBorder(new TitledBorder(new RoundedBorder(UIHelper.DARK_GREEN_COLOR, 4), "Behavioural Attributes", TitledBorder.DEFAULT_JUSTIFICATION, TitledBorder.DEFAULT_POSITION, UIHelper.VER_11_BOLD, UIHelper.DARK_GREEN_COLOR)); required = new JCheckBox("Required ", true); UIHelper.renderComponent(required, UIHelper.VER_11_BOLD, UIHelper.DARK_GREEN_COLOR, false); checkCont.add(required); acceptsMultipleValues = new JCheckBox("Allow multiple instances", false); UIHelper.renderComponent(acceptsMultipleValues, UIHelper.VER_11_BOLD, UIHelper.DARK_GREEN_COLOR, false); checkCont.add(acceptsMultipleValues); acceptsFileLocations = new JCheckBox("Accepts file locations", false); acceptsFileLocations.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent actionEvent) { acceptsMultipleValues.setSelected(false); acceptsMultipleValues.setEnabled(!acceptsFileLocations.isSelected()); } }); UIHelper.renderComponent(acceptsFileLocations, UIHelper.VER_11_BOLD, UIHelper.DARK_GREEN_COLOR, false); checkCont.add(acceptsFileLocations); hidden = new JCheckBox("hidden?", false); UIHelper.renderComponent(hidden, UIHelper.VER_11_BOLD, UIHelper.DARK_GREEN_COLOR, false); checkCont.add(hidden); forceOntologySelection = new JCheckBox("Force ontology selection", false); UIHelper.renderComponent(forceOntologySelection, UIHelper.VER_11_BOLD, UIHelper.DARK_GREEN_COLOR, false); checkCont.add(forceOntologySelection); container.add(checkCont); JScrollPane contScroll = new JScrollPane(container, JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED, JScrollPane.HORIZONTAL_SCROLLBAR_NEVER); contScroll.setBorder(null); contScroll.setAutoscrolls(true); IAppWidgetFactory.makeIAppScrollPane(contScroll); add(contScroll, BorderLayout.NORTH); }
From source file:org.jcurl.demo.tactics.TacticsApp.java
public TacticsApp() { addWindowListener(new WindowAdapter() { public void windowClosing(WindowEvent e) { TacticsApp.this.cmdExit(); }// w ww.j a v a 2 s.c om }); master = new RockEditDisplay(); master.setPos(mod_locations); master.setSpeed(mod_speeds); final PositionDisplay pnl2 = new PositionDisplay(); pnl2.setPos(mod_locations); pnl2.setZoom(Zoomer.HOG2HACK); final Container con = getContentPane(); { final JPanel p = new JPanel(new BorderLayout()); p.add(new SumWaitDisplay(mod_locations), "West"); p.add(master, "Center"); p.add(new SumShotDisplay(mod_locations), "East"); con.add(p, "Center"); } // con.add(new SumWaitDisplay(mod_locations), "West"); con.add(new SumOutDisplay(mod_locations), "West"); { final Box b1 = Box.createHorizontalBox(); b1.add(Box.createRigidArea(new Dimension(0, 75))); b1.add(pnl2); con.add(b1, "South"); } final JTabbedPane t = new JTabbedPane(); con.add(t, "East"); { final Box b0 = Box.createHorizontalBox(); t.add("Rock", b0); { final JPanel b1 = new JPanel(new BorderLayout()); final Box b2 = Box.createVerticalBox(); b2.add(new JComboBox(new String[] { "Dark", "Light" })); b2.add(new JLabel("Broom", SwingConstants.LEFT)); b1.add(b2, "North"); JSlider s = new JSlider(-2000, 2000, 0); s.setOrientation(SwingConstants.VERTICAL); s.setMajorTickSpacing(1000); s.setMinorTickSpacing(100); s.setPaintLabels(true); s.setPaintTicks(true); b1.add(s, "Center"); final Box b3 = Box.createHorizontalBox(); b3.add(new JFormattedTextField()); b3.add(new JLabel("mm", SwingConstants.LEFT)); b1.add(b3, "South"); b0.add(b1); } { final JPanel b1 = new JPanel(new BorderLayout()); final Box b2 = Box.createVerticalBox(); b2.add(new JComboBox(new String[] { "1", "2", "3", "4", "5", "6", "7", "8" })); b2.add(new JLabel("Splittime", SwingConstants.LEFT)); b1.add(b2, "North"); JSlider s = new JSlider(500, 2500, 1500); s.setOrientation(SwingConstants.VERTICAL); s.setMajorTickSpacing(1000); s.setMinorTickSpacing(100); s.setPaintLabels(true); s.setPaintTicks(true); b1.add(s, "Center"); final Box b3 = Box.createHorizontalBox(); b3.add(new JSpinner()); b3.add(new JLabel("ms", SwingConstants.LEFT)); b1.add(b3, "South"); b0.add(b1); } } { final Box b0 = Box.createHorizontalBox(); t.add("Ice", b0); { final JPanel b1 = new JPanel(new BorderLayout()); b1.add(new JLabel("Curl"), "North"); JSlider s = new JSlider(0, 5000, 0); s.setOrientation(SwingConstants.VERTICAL); s.setMajorTickSpacing(1000); s.setMinorTickSpacing(100); s.setPaintLabels(true); s.setPaintTicks(true); b1.add(s, "Center"); final JSpinner s1 = new JSpinner(); b1.add(s1, "South"); b0.add(b1); } { final JPanel b1 = new JPanel(new BorderLayout()); b1.add(new JLabel("DrawToTee"), "North"); JSlider s = new JSlider(15000, 30000, 25000); s.setOrientation(SwingConstants.VERTICAL); s.setMajorTickSpacing(5000); s.setMinorTickSpacing(1000); s.setPaintLabels(true); s.setPaintTicks(true); b1.add(s, "Center"); final JSpinner s1 = new JSpinner(); b1.add(s1, "South"); b0.add(b1); } } setJMenuBar(createMenu()); refreshTitle(); this.setSize(900, 400); new SpeedController(mod_locations, mod_speeds, master); new LocationController(mod_locations, pnl2); lastSaved = mod_locations.getLastChanged(); }
From source file:org.jtrfp.trcl.gui.ConfigWindow.java
public ConfigWindow() { setTitle("Settings"); setSize(340, 540);// w w w . j a v a2 s .c om if (config == null) config = new TRConfiguration(); JTabbedPane tabbedPane = new JTabbedPane(JTabbedPane.TOP); getContentPane().add(tabbedPane, BorderLayout.CENTER); JPanel generalTab = new JPanel(); tabbedPane.addTab("General", new ImageIcon(ConfigWindow.class .getResource("/org/freedesktop/tango/22x22/mimetypes/application-x-executable.png")), generalTab, null); GridBagLayout gbl_generalTab = new GridBagLayout(); gbl_generalTab.columnWidths = new int[] { 0, 0 }; gbl_generalTab.rowHeights = new int[] { 0, 188, 222, 0 }; gbl_generalTab.columnWeights = new double[] { 1.0, Double.MIN_VALUE }; gbl_generalTab.rowWeights = new double[] { 0.0, 1.0, 0.0, Double.MIN_VALUE }; generalTab.setLayout(gbl_generalTab); JPanel settingsLoadSavePanel = new JPanel(); GridBagConstraints gbc_settingsLoadSavePanel = new GridBagConstraints(); gbc_settingsLoadSavePanel.insets = new Insets(0, 0, 5, 0); gbc_settingsLoadSavePanel.anchor = GridBagConstraints.WEST; gbc_settingsLoadSavePanel.gridx = 0; gbc_settingsLoadSavePanel.gridy = 0; generalTab.add(settingsLoadSavePanel, gbc_settingsLoadSavePanel); settingsLoadSavePanel.setBorder(new TitledBorder(new EtchedBorder(EtchedBorder.LOWERED, null, null), "Overall Settings", TitledBorder.LEADING, TitledBorder.TOP, null, null)); FlowLayout flowLayout_1 = (FlowLayout) settingsLoadSavePanel.getLayout(); flowLayout_1.setAlignment(FlowLayout.LEFT); JButton btnSave = new JButton("Export..."); btnSave.setToolTipText("Export these settings to an external file"); settingsLoadSavePanel.add(btnSave); btnSave.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent arg0) { exportSettings(); } }); JButton btnLoad = new JButton("Import..."); btnLoad.setToolTipText("Import an external settings file"); settingsLoadSavePanel.add(btnLoad); btnLoad.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent arg0) { importSettings(); } }); JButton btnConfigReset = new JButton("Reset"); btnConfigReset.setToolTipText("Reset all settings to defaults"); settingsLoadSavePanel.add(btnConfigReset); btnConfigReset.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent arg0) { defaultSettings(); } }); JPanel registeredPODsPanel = new JPanel(); registeredPODsPanel.setBorder(new TitledBorder(new EtchedBorder(EtchedBorder.LOWERED, null, null), "Registered PODs", TitledBorder.LEFT, TitledBorder.TOP, null, null)); GridBagConstraints gbc_registeredPODsPanel = new GridBagConstraints(); gbc_registeredPODsPanel.insets = new Insets(0, 0, 5, 0); gbc_registeredPODsPanel.fill = GridBagConstraints.BOTH; gbc_registeredPODsPanel.gridx = 0; gbc_registeredPODsPanel.gridy = 1; generalTab.add(registeredPODsPanel, gbc_registeredPODsPanel); GridBagLayout gbl_registeredPODsPanel = new GridBagLayout(); gbl_registeredPODsPanel.columnWidths = new int[] { 272, 0 }; gbl_registeredPODsPanel.rowHeights = new int[] { 76, 0, 0 }; gbl_registeredPODsPanel.columnWeights = new double[] { 1.0, Double.MIN_VALUE }; gbl_registeredPODsPanel.rowWeights = new double[] { 1.0, 1.0, Double.MIN_VALUE }; registeredPODsPanel.setLayout(gbl_registeredPODsPanel); JPanel podListPanel = new JPanel(); GridBagConstraints gbc_podListPanel = new GridBagConstraints(); gbc_podListPanel.insets = new Insets(0, 0, 5, 0); gbc_podListPanel.fill = GridBagConstraints.BOTH; gbc_podListPanel.gridx = 0; gbc_podListPanel.gridy = 0; registeredPODsPanel.add(podListPanel, gbc_podListPanel); podListPanel.setLayout(new BorderLayout(0, 0)); JScrollPane podListScrollPane = new JScrollPane(); podListPanel.add(podListScrollPane, BorderLayout.CENTER); podList = new JList(podLM); podList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); podListScrollPane.setViewportView(podList); JPanel podListOpButtonPanel = new JPanel(); podListOpButtonPanel.setBorder(null); GridBagConstraints gbc_podListOpButtonPanel = new GridBagConstraints(); gbc_podListOpButtonPanel.anchor = GridBagConstraints.NORTH; gbc_podListOpButtonPanel.gridx = 0; gbc_podListOpButtonPanel.gridy = 1; registeredPODsPanel.add(podListOpButtonPanel, gbc_podListOpButtonPanel); FlowLayout flowLayout = (FlowLayout) podListOpButtonPanel.getLayout(); flowLayout.setAlignment(FlowLayout.LEFT); JButton addPodButton = new JButton("Add..."); addPodButton.setIcon( new ImageIcon(ConfigWindow.class.getResource("/org/freedesktop/tango/16x16/actions/list-add.png"))); addPodButton.setToolTipText("Add a POD to the registry to be considered when running a game."); podListOpButtonPanel.add(addPodButton); addPodButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent arg0) { addPOD(); } }); JButton removePodButton = new JButton("Remove"); removePodButton.setIcon(new ImageIcon( ConfigWindow.class.getResource("/org/freedesktop/tango/16x16/actions/list-remove.png"))); removePodButton.setToolTipText("Remove a POD file from being considered when playing a game"); podListOpButtonPanel.add(removePodButton); removePodButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent arg0) { podLM.removeElement(podList.getSelectedValue()); } }); JButton podEditButton = new JButton("Edit..."); podEditButton.setIcon(null); podEditButton.setToolTipText("Edit the selected POD path"); podListOpButtonPanel.add(podEditButton); podEditButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent arg0) { editPODPath(); } }); JPanel missionPanel = new JPanel(); GridBagConstraints gbc_missionPanel = new GridBagConstraints(); gbc_missionPanel.fill = GridBagConstraints.BOTH; gbc_missionPanel.gridx = 0; gbc_missionPanel.gridy = 2; generalTab.add(missionPanel, gbc_missionPanel); missionPanel.setBorder(new TitledBorder(new EtchedBorder(EtchedBorder.LOWERED, null, null), "Missions", TitledBorder.LEADING, TitledBorder.TOP, null, null)); GridBagLayout gbl_missionPanel = new GridBagLayout(); gbl_missionPanel.columnWidths = new int[] { 0, 0 }; gbl_missionPanel.rowHeights = new int[] { 0, 0, 0 }; gbl_missionPanel.columnWeights = new double[] { 1.0, Double.MIN_VALUE }; gbl_missionPanel.rowWeights = new double[] { 1.0, 0.0, Double.MIN_VALUE }; missionPanel.setLayout(gbl_missionPanel); JScrollPane scrollPane = new JScrollPane(); GridBagConstraints gbc_scrollPane = new GridBagConstraints(); gbc_scrollPane.insets = new Insets(0, 0, 5, 0); gbc_scrollPane.fill = GridBagConstraints.BOTH; gbc_scrollPane.gridx = 0; gbc_scrollPane.gridy = 0; missionPanel.add(scrollPane, gbc_scrollPane); missionList = new JList(missionLM); missionList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); scrollPane.setViewportView(missionList); JPanel missionListOpButtonPanel = new JPanel(); GridBagConstraints gbc_missionListOpButtonPanel = new GridBagConstraints(); gbc_missionListOpButtonPanel.anchor = GridBagConstraints.NORTH; gbc_missionListOpButtonPanel.gridx = 0; gbc_missionListOpButtonPanel.gridy = 1; missionPanel.add(missionListOpButtonPanel, gbc_missionListOpButtonPanel); JButton addVOXButton = new JButton("Add..."); addVOXButton.setIcon( new ImageIcon(ConfigWindow.class.getResource("/org/freedesktop/tango/16x16/actions/list-add.png"))); addVOXButton.setToolTipText("Add an external VOX file as a mission"); missionListOpButtonPanel.add(addVOXButton); addVOXButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent arg0) { addVOX(); } }); final JButton removeVOXButton = new JButton("Remove"); removeVOXButton.setIcon(new ImageIcon( ConfigWindow.class.getResource("/org/freedesktop/tango/16x16/actions/list-remove.png"))); removeVOXButton.setToolTipText("Remove the selected mission"); missionListOpButtonPanel.add(removeVOXButton); removeVOXButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent arg0) { missionLM.remove(missionList.getSelectedIndex()); } }); final JButton editVOXButton = new JButton("Edit..."); editVOXButton.setToolTipText("Edit the selected Mission's VOX path"); missionListOpButtonPanel.add(editVOXButton); editVOXButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent arg0) { editVOXPath(); } }); missionList.addListSelectionListener(new ListSelectionListener() { @Override public void valueChanged(ListSelectionEvent evt) { final String val = (String) missionList.getSelectedValue(); if (val == null) missionList.setSelectedIndex(0); else if (isBuiltinVOX(val)) { removeVOXButton.setEnabled(false); editVOXButton.setEnabled(false); } else { removeVOXButton.setEnabled(true); editVOXButton.setEnabled(true); } } }); JPanel soundTab = new JPanel(); tabbedPane.addTab("Sound", new ImageIcon( ConfigWindow.class.getResource("/org/freedesktop/tango/22x22/devices/audio-card.png")), soundTab, null); GridBagLayout gbl_soundTab = new GridBagLayout(); gbl_soundTab.columnWidths = new int[] { 0, 0 }; gbl_soundTab.rowHeights = new int[] { 65, 51, 70, 132, 0, 0, 0 }; gbl_soundTab.columnWeights = new double[] { 1.0, Double.MIN_VALUE }; gbl_soundTab.rowWeights = new double[] { 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, Double.MIN_VALUE }; soundTab.setLayout(gbl_soundTab); JPanel checkboxPanel = new JPanel(); GridBagConstraints gbc_checkboxPanel = new GridBagConstraints(); gbc_checkboxPanel.insets = new Insets(0, 0, 5, 0); gbc_checkboxPanel.fill = GridBagConstraints.BOTH; gbc_checkboxPanel.gridx = 0; gbc_checkboxPanel.gridy = 0; soundTab.add(checkboxPanel, gbc_checkboxPanel); chckbxLinearInterpolation = new JCheckBox("Linear Filtering"); chckbxLinearInterpolation.setToolTipText("Use the GPU's TMU to smooth playback of low-rate samples."); chckbxLinearInterpolation.setHorizontalAlignment(SwingConstants.LEFT); checkboxPanel.add(chckbxLinearInterpolation); chckbxLinearInterpolation.addItemListener(new ItemListener() { @Override public void itemStateChanged(ItemEvent e) { needRestart = true; } }); chckbxBufferLag = new JCheckBox("Buffer Lag"); chckbxBufferLag.setToolTipText("Improves efficiency, doubles latency."); checkboxPanel.add(chckbxBufferLag); JPanel modStereoWidthPanel = new JPanel(); FlowLayout flowLayout_2 = (FlowLayout) modStereoWidthPanel.getLayout(); flowLayout_2.setAlignment(FlowLayout.LEFT); modStereoWidthPanel.setBorder(new TitledBorder(new EtchedBorder(EtchedBorder.LOWERED, null, null), "MOD Stereo Width", TitledBorder.LEADING, TitledBorder.TOP, null, null)); GridBagConstraints gbc_modStereoWidthPanel = new GridBagConstraints(); gbc_modStereoWidthPanel.anchor = GridBagConstraints.NORTH; gbc_modStereoWidthPanel.insets = new Insets(0, 0, 5, 0); gbc_modStereoWidthPanel.fill = GridBagConstraints.HORIZONTAL; gbc_modStereoWidthPanel.gridx = 0; gbc_modStereoWidthPanel.gridy = 1; soundTab.add(modStereoWidthPanel, gbc_modStereoWidthPanel); modStereoWidthSlider = new JSlider(); modStereoWidthSlider.setPaintTicks(true); modStereoWidthSlider.setMinorTickSpacing(25); modStereoWidthPanel.add(modStereoWidthSlider); final JLabel modStereoWidthLbl = new JLabel("NN%"); modStereoWidthPanel.add(modStereoWidthLbl); JPanel bufferSizePanel = new JPanel(); FlowLayout flowLayout_3 = (FlowLayout) bufferSizePanel.getLayout(); flowLayout_3.setAlignment(FlowLayout.LEFT); bufferSizePanel.setBorder( new TitledBorder(null, "Buffer Size", TitledBorder.LEADING, TitledBorder.TOP, null, null)); GridBagConstraints gbc_bufferSizePanel = new GridBagConstraints(); gbc_bufferSizePanel.anchor = GridBagConstraints.NORTH; gbc_bufferSizePanel.insets = new Insets(0, 0, 5, 0); gbc_bufferSizePanel.fill = GridBagConstraints.HORIZONTAL; gbc_bufferSizePanel.gridx = 0; gbc_bufferSizePanel.gridy = 2; soundTab.add(bufferSizePanel, gbc_bufferSizePanel); audioBufferSizeCB = new JComboBox(); audioBufferSizeCB.setModel(new DefaultComboBoxModel(AudioBufferSize.values())); bufferSizePanel.add(audioBufferSizeCB); soundOutputSelectorGUI = new SoundOutputSelectorGUI(); soundOutputSelectorGUI.setBorder( new TitledBorder(null, "Output Driver", TitledBorder.LEADING, TitledBorder.TOP, null, null)); GridBagConstraints gbc_soundOutputSelectorGUI = new GridBagConstraints(); gbc_soundOutputSelectorGUI.anchor = GridBagConstraints.NORTH; gbc_soundOutputSelectorGUI.insets = new Insets(0, 0, 5, 0); gbc_soundOutputSelectorGUI.fill = GridBagConstraints.HORIZONTAL; gbc_soundOutputSelectorGUI.gridx = 0; gbc_soundOutputSelectorGUI.gridy = 3; soundTab.add(soundOutputSelectorGUI, gbc_soundOutputSelectorGUI); modStereoWidthSlider.addChangeListener(new ChangeListener() { @Override public void stateChanged(ChangeEvent arg0) { modStereoWidthLbl.setText(modStereoWidthSlider.getValue() + "%"); needRestart = true; } }); JPanel okCancelPanel = new JPanel(); getContentPane().add(okCancelPanel, BorderLayout.SOUTH); okCancelPanel.setLayout(new BorderLayout(0, 0)); JButton btnOk = new JButton("OK"); btnOk.setToolTipText("Apply these settings and close the window"); okCancelPanel.add(btnOk, BorderLayout.WEST); btnOk.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent arg0) { applySettings(); ConfigWindow.this.setVisible(false); } }); JButton btnCancel = new JButton("Cancel"); btnCancel.setToolTipText("Close the window without applying settings"); okCancelPanel.add(btnCancel, BorderLayout.EAST); JLabel lblConfigpath = new JLabel(TRConfiguration.getConfigFilePath().getAbsolutePath()); lblConfigpath.setIcon(null); lblConfigpath.setToolTipText("Default config file path"); lblConfigpath.setHorizontalAlignment(SwingConstants.CENTER); lblConfigpath.setFont(new Font("Dialog", Font.BOLD, 6)); okCancelPanel.add(lblConfigpath, BorderLayout.CENTER); btnCancel.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent arg0) { ConfigWindow.this.setVisible(false); } }); }
From source file:org.notebook.gui.widget.GuiUtils.java
/** * Returns the component orientation as a SwingConstant. * /*w w w. ja va 2 s . c o m*/ * @return The component orientation as a SwingConstant */ public static int getComponentOrientationAsSwingConstant() { if (componentOrientation == null) { setComponentOrientation(); } return componentOrientation.isLeftToRight() ? SwingConstants.LEFT : SwingConstants.RIGHT; }
From source file:org.omegat.gui.scripting.ScriptingWindow.java
private void setupRunButtons(JPanel panel) { m_btnRunScript = new JButton(); Mnemonics.setLocalizedText(m_btnRunScript, OStrings.getString("SCW_RUN_SCRIPT")); m_btnRunScript.setAlignmentX(Component.LEFT_ALIGNMENT); m_btnRunScript.setHorizontalAlignment(SwingConstants.LEFT); m_btnRunScript.addActionListener(new ActionListener() { @Override/*from w w w . j av a 2 s . co m*/ public void actionPerformed(ActionEvent a) { runScript(); } }); panel.add(m_btnRunScript); m_btnCancelScript = new JButton(); Mnemonics.setLocalizedText(m_btnCancelScript, OStrings.getString("SCW_CANCEL_SCRIPT")); m_btnCancelScript.setToolTipText(OStrings.getString("SCW_CANCEL_BUTTON_TOOLTIP")); m_btnCancelScript.setAlignmentX(Component.LEFT_ALIGNMENT); m_btnCancelScript.setHorizontalAlignment(SwingConstants.LEFT); m_btnCancelScript.addActionListener(e -> cancelCurrentScript()); panel.add(m_btnCancelScript); for (int i = 0; i < NUMBERS_OF_QUICK_SCRIPTS; i++) { final int index = i; final int scriptKey = scriptKey(index); m_quickScriptButtons[i] = new JButton(String.valueOf(scriptKey)); // Run a script from the quick button bar m_quickScriptButtons[i].addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent a) { if (Preferences.existsPreference(Preferences.SCRIPTS_QUICK_PREFIX + scriptKey)) { runQuickScript(index); } else { logResult(StringUtil.format(OStrings.getString("SCW_NO_SCRIPT_BOUND"), scriptKey)); } } }); JPopupMenu quickScriptPopup = new JPopupMenu(); // Add a script to the quick script button bar final JMenuItem addQuickScriptMenuItem = new JMenuItem(OStrings.getString("SCW_ADD_SCRIPT")); addQuickScriptMenuItem.addActionListener(new QuickScriptUpdater(index)); quickScriptPopup.add(addQuickScriptMenuItem); // Remove a script from the button bar final JMenuItem removeQuickScriptMenuItem = new JMenuItem(OStrings.getString("SCW_REMOVE_SCRIPT")); removeQuickScriptMenuItem.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent evt) { String scriptName = Preferences .getPreferenceDefault(Preferences.SCRIPTS_QUICK_PREFIX + scriptKey, "(unknown)"); logResult(StringUtil.format(OStrings.getString("SCW_REMOVED_QUICK_SCRIPT"), scriptName, scriptKey)); Preferences.setPreference(Preferences.SCRIPTS_QUICK_PREFIX + scriptKey, ""); m_quickScriptButtons[index].setToolTipText(OStrings.getString("SCW_NO_SCRIPT_SET")); m_quickScriptButtons[index].setText(" " + scriptKey + " "); unsetQuickScriptMenu(index); } }); quickScriptPopup.add(removeQuickScriptMenuItem); quickScriptPopup.addPopupMenuListener(new PopupMenuListener() { @Override public void popupMenuWillBecomeVisible(PopupMenuEvent e) { // Disable add a script command if script selection empty addQuickScriptMenuItem.setEnabled(!m_scriptList.isSelectionEmpty()); // Disable remove a script command if the quick run button is not bounded String scriptName = Preferences .getPreferenceDefault(Preferences.SCRIPTS_QUICK_PREFIX + scriptKey, null); removeQuickScriptMenuItem.setEnabled(!StringUtil.isEmpty(scriptName)); } @Override public void popupMenuWillBecomeInvisible(PopupMenuEvent e) { // do nothing } @Override public void popupMenuCanceled(PopupMenuEvent e) { // do nothing } }); m_quickScriptButtons[i].setComponentPopupMenu(quickScriptPopup); panel.add(m_quickScriptButtons[i]); } }
From source file:org.openconcerto.erp.core.finance.accounting.ui.EtatJournauxPanel.java
private JPanel creerJournalMoisPanel(final Date date, long debit, long credit, final Journal jrnl) { final JPanel panelMoisCompte = new JPanel(); panelMoisCompte.setLayout(new GridBagLayout()); final GridBagConstraints c = new GridBagConstraints(); c.insets = new Insets(2, 2, 1, 2); c.fill = GridBagConstraints.HORIZONTAL; c.anchor = GridBagConstraints.NORTHWEST; c.gridx = 0;/*from w ww.j a v a 2 s . com*/ c.gridy = 0; c.gridwidth = 1; c.gridheight = 1; c.weightx = 1; c.weighty = 0; panelMoisCompte.setBorder(BorderFactory.createTitledBorder(dateFormat.format(date))); // Date du mois panelMoisCompte.add(new JLabel(dateFormat.format(date)), c); // Totaux du mois c.gridx++; panelMoisCompte.add(new JLabel(" dbit : " + GestionDevise.currencyToString(debit)), c); c.gridx++; panelMoisCompte.add(new JLabel(" crdit : " + GestionDevise.currencyToString(credit)), c); // Bouton dtails JButton boutonShow = new JButton("+/-"); boutonShow.setOpaque(false); boutonShow.setHorizontalAlignment(SwingConstants.LEFT); c.weightx = 0; c.gridx++; panelMoisCompte.add(boutonShow, c); boutonShow.addActionListener(new ActionListener() { private boolean isShow = false; private ListPanelEcritures listEcriture; public void actionPerformed(ActionEvent e) { System.err.println(this.isShow); // Afficher la JTable du compte if (!this.isShow) { final SQLElement element = Configuration.getInstance().getDirectory().getElement("ECRITURE"); final SQLTable ecrTable = element.getTable(); Calendar cal = Calendar.getInstance(); cal.setTime(date); cal.set(Calendar.DATE, 1); Date inf = cal.getTime(); cal.set(Calendar.DATE, cal.getActualMaximum(Calendar.DATE)); Date sup = cal.getTime(); System.out.println("Inf : " + inf + " Sup : " + sup); Where w = new Where(ecrTable.getField("ID_JOURNAL"), "=", jrnl.getId()); Where w2 = new Where(ecrTable.getField("DATE"), inf, sup); if (!UserManager.getInstance().getCurrentUser().getRights() .haveRight(ComptaUserRight.ACCES_NOT_RESCTRICTED_TO_411)) { // TODO Show Restricted acces in UI w = w.and(new Where(ecrTable.getField("COMPTE_NUMERO"), "LIKE", "411%")); } this.listEcriture = new ListPanelEcritures(element, w.and(w2)); this.listEcriture.setModificationVisible(false); this.listEcriture.setAjoutVisible(false); this.listEcriture.setSuppressionVisible(false); this.listEcriture.getListe().setSQLEditable(false); Dimension d; // Taille limite 200 maximum if (this.listEcriture.getListe().getPreferredSize().height > 200) { d = new Dimension(this.listEcriture.getListe().getPreferredSize().width, 200); } else { d = new Dimension(this.listEcriture.getListe().getPreferredSize().width, this.listEcriture.getListe().getPreferredSize().height + 30); } this.listEcriture.getListe().setPreferredSize(d); // c.gridy = 2; c.gridx = 0; c.gridy = 1; c.gridwidth = 4; c.weightx = 1; c.weighty = 1; c.fill = GridBagConstraints.BOTH; this.listEcriture.getListe().setSQLEditable(false); panelMoisCompte.add(this.listEcriture, c); this.listEcriture.getListe().getJTable().addMouseListener(new MouseAdapter() { public void mousePressed(MouseEvent e) { if (e.getButton() == MouseEvent.BUTTON3) { JPopupMenu menu = new JPopupMenu(); menu.add(new AbstractAction("Voir la source") { public void actionPerformed(ActionEvent e) { SQLRow row = base.getTable("ECRITURE") .getRow(listEcriture.getListe().getSelectedId()); MouvementSQLElement.showSource(row.getInt("ID_MOUVEMENT")); } }); menu.show(e.getComponent(), e.getPoint().x, e.getPoint().y); } } }); } else { panelMoisCompte.remove(this.listEcriture); System.out.println("Hide ListEcriture"); panelMoisCompte.repaint(); panelMoisCompte.revalidate(); } this.isShow = !this.isShow; SwingUtilities.getRoot(panelMoisCompte).repaint(); } }); return panelMoisCompte; }
From source file:org.openmicroscopy.shoola.agents.fsimporter.util.ChecksumTableRenderer.java
/** * Creates a new instance./*ww w . j av a 2 s . c o m*/ * * @param failure The icon displayed when the checksums do not match. * @param success The icon displayed when the checksums do match. */ ChecksumTableRenderer(Icon failure, Icon success) { this.failure = failure; this.success = success; foreground = getForeground(); setOpaque(true); setHorizontalAlignment(SwingConstants.LEFT); }
From source file:org.openmicroscopy.shoola.agents.treeviewer.view.ToolBar.java
/** * Helper method to create the tool bar hosting the management items. * /*ww w . j a v a 2 s .com*/ * @return See above. */ private JComponent createManagementBar() { bar = new JToolBar(); bar.setFloatable(false); bar.setRollover(true); bar.setBorder(null); JToggleButton button = new JToggleButton(controller.getAction(TreeViewerControl.INSPECTOR)); button.setSelected(true); bar.add(button); button = new JToggleButton(controller.getAction(TreeViewerControl.METADATA)); button.setSelected(true); bar.add(button); JButton b = new JButton(controller.getAction(TreeViewerControl.BROWSE)); UIUtilities.unifiedButtonLookAndFeel(b); bar.add(b); switch (TreeViewerAgent.runAsPlugin()) { case TreeViewer.IMAGE_J: b = UIUtilities.formatButtonFromAction(controller.getAction(TreeViewerControl.VIEW)); UIUtilities.unifiedButtonLookAndFeel(b); b.addMouseListener(new MouseAdapter() { /** * Displays the menu when the user releases the mouse. * @see MouseListener#mouseReleased(MouseEvent) */ public void mouseReleased(MouseEvent e) { controller.showMenu(TreeViewer.VIEW_MENU, (JComponent) e.getSource(), e.getPoint()); } }); bar.add(b); break; default: b = new JButton(controller.getAction(TreeViewerControl.VIEW)); UIUtilities.unifiedButtonLookAndFeel(b); bar.add(b); } bar.add(new JSeparator(JSeparator.VERTICAL)); //Now register the agent if any TaskBar tb = TreeViewerAgent.getRegistry().getTaskBar(); List<JComponent> l = tb.getToolBarEntries(TaskBar.AGENTS); if (l != null) { Iterator<JComponent> i = l.iterator(); JComponent comp; while (i.hasNext()) { comp = i.next(); UIUtilities.unifiedButtonLookAndFeel(comp); bar.add(comp); } bar.add(new JSeparator(JSeparator.VERTICAL)); } fullScreen = new JToggleButton(controller.getAction(TreeViewerControl.FULLSCREEN)); fullScreen.setSelected(model.isFullScreen()); //bar.add(fullScreen); if (TreeViewerAgent.isAdministrator()) { b = new JButton(controller.getAction(TreeViewerControl.UPLOAD_SCRIPT)); UIUtilities.unifiedButtonLookAndFeel(b); bar.add(b); } TreeViewerAction a = controller.getAction(TreeViewerControl.AVAILABLE_SCRIPTS); b = new JButton(a); Icon icon = b.getIcon(); Dimension d = new Dimension(UIUtilities.DEFAULT_ICON_WIDTH, UIUtilities.DEFAULT_ICON_HEIGHT); if (icon != null) d = new Dimension(icon.getIconWidth(), icon.getIconHeight()); busyLabel = new JXBusyLabel(d); busyLabel.setVisible(true); b.addMouseListener((RunScriptAction) a); UIUtilities.unifiedButtonLookAndFeel(b); scriptButton = b; bar.add(b); index = bar.getComponentCount() - 1; bar.add(new JSeparator(JSeparator.VERTICAL)); MouseAdapter adapter = new MouseAdapter() { /** * Shows the menu corresponding to the display mode. */ public void mousePressed(MouseEvent me) { createGroupsAndUsersMenu((Component) me.getSource(), me.getPoint()); } }; a = controller.getAction(TreeViewerControl.SWITCH_USER); IconManager icons = IconManager.getInstance(); menuButton = new JButton(icons.getIcon(IconManager.FILTER_MENU)); menuButton.setVisible(true); menuButton.setText(GROUP_DISPLAY_TEXT); menuButton.setHorizontalTextPosition(SwingConstants.LEFT); menuButton.addMouseListener(adapter); bar.add(menuButton); setPermissions(); return bar; }