List of usage examples for javax.swing SwingConstants HORIZONTAL
int HORIZONTAL
To view the source code for javax.swing SwingConstants HORIZONTAL.
Click Source Link
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);//from ww w . ja v a 2 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); }/* ww w. j av a2s . c om*/ final TestShowLWTCSliderComparison vt = new TestShowLWTCSliderComparison(); vt.go(SwingConstants.VERTICAL); final TestShowLWTCSliderComparison ht = new TestShowLWTCSliderComparison(); ht.go(SwingConstants.HORIZONTAL); }
From source file:us.physion.ovation.ui.editor.PlainTextVisualizationFactory.java
@Override public DataVisualization createVisualization(final Content r) { return new AbstractDataVisualization() { @Override/*from w ww .ja v a2 s. co m*/ public JComponent generatePanel() { class PlainTextArea extends JTextArea { private boolean scrollableTracksViewportWidth = false; @Override public boolean getScrollableTracksViewportWidth() { return scrollableTracksViewportWidth; } private void setScrollableTracksViewportWidth(boolean b) { if (b == scrollableTracksViewportWidth) { return; } scrollableTracksViewportWidth = b; } private void failed() { setText(Bundle.LBL_TextLoadingFailed(ContentUtils.contentLabel(r))); } @Override public void addNotify() { super.addNotify(); ListenableFuture<File> data; try { data = r.getData(); } catch (ResourceNotFoundException ex) { log.warn("Resource not found", ex); failed(); return; } Futures.addCallback(data, new FutureCallback<File>() { @Override public void onSuccess(File f) { try { FileReader fr = new FileReader(f); try { final String text = IOUtils.toString(fr); EventQueue.invokeLater(new Runnable() { @Override public void run() { setText(text); setCaretPosition(0); repaint(); } }); } finally { IOUtils.closeQuietly(fr); } } catch (IOException ex) { log.warn("Could not load text", ex); failed(); } } @Override public void onFailure(Throwable ex) { log.warn("Could not get file", ex); failed(); } }, loadFileExecutors); } } final PlainTextArea t = new PlainTextArea(); t.setEditable(false); t.setText(Bundle.LBL_TextLoading()); ParentWidthPanel panel = new ParentWidthPanel(); panel.add(new JScrollPane(t), BorderLayout.CENTER); { JToolBar toolbar = new JToolBar(SwingConstants.HORIZONTAL); toolbar.setBackground(Color.WHITE); toolbar.add(new JToggleButton(new AbstractAction(Bundle.LBL_LineWrap()) { @Override public void actionPerformed(ActionEvent e) { boolean selected = ((JToggleButton) e.getSource()).isSelected(); t.setLineWrap(selected); t.setScrollableTracksViewportWidth(selected); t.setCaretPosition(0); t.revalidate(); t.repaint(); } })); panel.add(toolbar, BorderLayout.NORTH); } return panel; } @Override public boolean shouldAdd(Content r) { return false; } @Override public void add(Content r) { throw new UnsupportedOperationException(); } @Override public Iterable<? extends OvationEntity> getEntities() { return Sets.newHashSet((OvationEntity) r); } }; }
From source file:verdandi.ui.ProjectViewerPanel.java
private JToolBar getToolbar() { // JPanel toolbar = new JPanel(); // toolbar.setLayout(new BoxLayout(toolbar, BoxLayout.LINE_AXIS)); JToolBar toolbar = new JToolBar(SwingConstants.HORIZONTAL); toolbar.setLayout(new GridBagLayout()); GridBagConstraints c = new GridBagConstraints(); c.gridx = 0;/*from w ww . java 2s .c om*/ c.gridy = 0; c.fill = GridBagConstraints.NONE; c.anchor = GridBagConstraints.WEST; c.weightx = 0.0; c.weighty = 0.0; URL imageURL = null; imageURL = Thread.currentThread().getContextClassLoader() .getResource(THEME_RC.getString("icon.project.add")); ImageIcon addProjectIcon = new ImageIcon(imageURL, "add"); JButton addProject = new JButton(addProjectIcon); addProject.setActionCommand(CMD_ADD_PROJECT); addProject.setToolTipText(RB.getString("projectviewer.add.tooltip")); addProject.addActionListener(this); toolbar.add(addProject, c); c.gridx++; imageURL = getClass().getClassLoader().getResource(THEME_RC.getString("icon.project.edit")); ImageIcon editProjectIcon = new ImageIcon(imageURL, "edit"); JButton editProject = new JButton(editProjectIcon); editProject.setActionCommand(CMD_EDIT_PROJECT); editProject.setToolTipText(RB.getString("projectviewer.edit.tooltip")); editProject.addActionListener(this); toolbar.add(editProject, c); c.gridx++; imageURL = getClass().getClassLoader().getResource(THEME_RC.getString("icon.projects.import")); ImageIcon importProjectIcon = new ImageIcon(imageURL, "import"); JButton importProject = new JButton(importProjectIcon); importProject.setActionCommand(CMD_IMPORT_PROJECT); importProject.setToolTipText(RB.getString("projectviewer.import.tooltip")); importProject.addActionListener(this); toolbar.add(importProject, c); c.gridx++; // THEME_RC.getString("") imageURL = getClass().getClassLoader().getResource(THEME_RC.getString("icon.projects.export")); ImageIcon exportProjectIcon = new ImageIcon(imageURL, "export"); JButton exportProject = new JButton(exportProjectIcon); exportProject.setActionCommand(CMD_EXPORT_PROJECT); exportProject.setToolTipText(RB.getString("projectviewer.export.tooltip")); exportProject.addActionListener(this); toolbar.add(exportProject, c); c.gridx++; toolbar.add(new JToolBar.Separator(), c); c.gridx++; imageURL = getClass().getClassLoader().getResource(THEME_RC.getString("icon.project.hide.active")); hideActiveIcon = new ImageIcon(imageURL, "hide active"); imageURL = getClass().getClassLoader().getResource(THEME_RC.getString("icon.project.show.active")); showActiveIcon = new ImageIcon(imageURL, "show active"); toggleShowActive = new JToggleButton(hideActiveIcon); toggleShowActive.setActionCommand(CMD_TOGGLE_SHOW_ACTIVE); toggleShowActive.setToolTipText(RB.getString("projectviewer.toggleshowactive.tooltip")); toggleShowActive.addActionListener(this); toolbar.add(toggleShowActive, c); c.gridx++; c.weightx = 0.5; toolbar.add(Box.createHorizontalGlue(), c); c.weightx = 0.0; c.gridx++; c.insets = new Insets(0, 5, 0, 5); toolbar.add(new JLabel("Filter"), c); c.gridx++; c.insets = new Insets(0, 0, 0, 0); searchField = new JTextField(10); searchField.getDocument().addDocumentListener(this); searchField.setToolTipText(RB.getString("projectviewer.searchfield.tooltip")); toolbar.add(searchField, c); toolbar.setFloatable(false); return toolbar; }
From source file:volker.streaming.music.gui.FormatPanel.java
private void initComponents() { formatLabel = new JLabel("How should your track info be displayed:"); formatArea = new JTextArea(config.getFormat()); formatLighter = new DefaultHighlighter(); // TODO allow configuration of this color formatPainter = new DefaultHighlighter.DefaultHighlightPainter(new Color(200, 200, 255)); formatArea.setHighlighter(formatLighter); formatArea.getDocument().addDocumentListener(new DocumentListener() { @Override// w w w.j a v a2 s . c o m public void removeUpdate(DocumentEvent e) { formatUpdated(); } @Override public void insertUpdate(DocumentEvent e) { formatUpdated(); } @Override public void changedUpdate(DocumentEvent e) { formatUpdated(); } }); ImageIcon infoIcon = null; try { InputStream is = getClass().getResourceAsStream("info.png"); if (is == null) { LOG.error("Couldn't find the info image."); } else { infoIcon = new ImageIcon(ImageIO.read(is)); is.close(); } } catch (IOException e1) { LOG.error("Couldn't find the info image.", e1); } if (infoIcon == null) { formatInfoButton = new JButton("?"); } else { formatInfoButton = new JButton(infoIcon); formatInfoButton.setBorder(BorderFactory.createEmptyBorder()); } formatInfoButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { showFormatHelp(); } }); templateLabel = new JLabel("Your template:"); tagLabel = new JLabel("Available tags:"); tagList = new JList<String>(new AbstractListModel<String>() { private static final long serialVersionUID = -8886588605378873151L; @Override public int getSize() { return properTags.size(); } @Override public String getElementAt(int index) { return properTags.get(index); } }); tagScrollPane = new JScrollPane(tagList); previewLabel = new JLabel("Preview:"); previewField = new JTextField(); previewField.setEditable(false); previewField.setBorder(BorderFactory.createLineBorder(Color.BLACK, 1)); previewField.setBackground(new Color(255, 255, 150)); formatUpdated(); highlightTags(); nullMessageLabel = new JLabel("Message to display when no song is found:"); nullMessageField = new JTextField(config.getNoTrackMessage() == null ? "" : config.getNoTrackMessage()); nullMessageField.getDocument().addDocumentListener(new DocumentListener() { public void action() { config.setNoTrackMessage(nullMessageField.getText()); } @Override public void removeUpdate(DocumentEvent e) { action(); } @Override public void insertUpdate(DocumentEvent e) { action(); } @Override public void changedUpdate(DocumentEvent e) { action(); } }); hline = new JSeparator(SwingConstants.HORIZONTAL); fileLabel = new JLabel("Location of text file:"); fileChooser = new JFileChooser(); fileChooser.setFileSelectionMode(JFileChooser.FILES_AND_DIRECTORIES); fileField = new JTextField(15); if (config.getOutputFile() != null) { fileField.setText(config.getOutputFile().getAbsolutePath()); } fileField.getDocument().addDocumentListener(new DocumentListener() { public void action() { config.setOutputFile(new File(fileField.getText())); } @Override public void removeUpdate(DocumentEvent e) { action(); } @Override public void insertUpdate(DocumentEvent e) { action(); } @Override public void changedUpdate(DocumentEvent e) { action(); } }); fileButton = new JButton("Browse"); fileButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { browseFile(); } }); }