List of usage examples for java.awt BorderLayout WEST
String WEST
To view the source code for java.awt BorderLayout WEST.
Click Source Link
From source file:nz.ac.waikato.cms.supernova.gui.Supernova.java
/** * Creates the panel for generating a single graph. * * @return the panel//from w ww. j ava 2 s . com */ protected BasePanel createSinglePanel() { BasePanel result; JPanel params; JPanel left1; JPanel left2; JPanel panel; JPanel panel2; result = new BasePanel(new BorderLayout()); panel = new JPanel(new BorderLayout()); result.add(panel, BorderLayout.CENTER); m_PanelSinglePreview = new ImagePanel(); panel.add(new BaseScrollPane(m_PanelSinglePreview), BorderLayout.CENTER); panel2 = new JPanel(new FlowLayout(FlowLayout.RIGHT)); panel.add(panel2, BorderLayout.SOUTH); m_SingleCopy = new JButton(GUIHelper.getIcon("copy.gif")); m_SingleCopy.setEnabled(false); m_SingleCopy.addActionListener((ActionEvent e) -> copySinglePreview()); panel2.add(m_SingleCopy); left1 = new JPanel(new BorderLayout()); result.add(left1, BorderLayout.WEST); // params with height 2 params = new JPanel(new GridLayout(0, 1)); left1.add(params, BorderLayout.NORTH); m_SingleStatistics = new StatisticsTable(); left1.add(new BaseScrollPane(m_SingleStatistics), BorderLayout.NORTH); // params with height 1 panel = new JPanel(new BorderLayout()); left1.add(panel, BorderLayout.CENTER); left2 = new JPanel(new BorderLayout()); panel.add(left2, BorderLayout.NORTH); params = new JPanel(new GridLayout(0, 1)); left2.add(params, BorderLayout.NORTH); // background m_SingleBackground = new ColorButton(Color.BLACK); params.add(createParameter("Background", m_SingleBackground)); // opacity m_SingleOpacity = new JSpinner(); m_SingleOpacity.setValue(10); ((SpinnerNumberModel) m_SingleOpacity.getModel()).setMinimum(0); ((SpinnerNumberModel) m_SingleOpacity.getModel()).setMaximum(100); ((SpinnerNumberModel) m_SingleOpacity.getModel()).setStepSize(10); ((JSpinner.DefaultEditor) m_SingleOpacity.getEditor()).getTextField().setColumns(5); params.add(createParameter("Opacity %", m_SingleOpacity)); // margin m_SingleMargin = new JSpinner(); m_SingleMargin.setValue(20); ((SpinnerNumberModel) m_SingleMargin.getModel()).setMinimum(0); ((SpinnerNumberModel) m_SingleMargin.getModel()).setMaximum(100); ((SpinnerNumberModel) m_SingleMargin.getModel()).setStepSize(10); ((JSpinner.DefaultEditor) m_SingleMargin.getEditor()).getTextField().setColumns(5); params.add(createParameter("Margin %", m_SingleMargin)); // width m_SingleWidth = new JSpinner(); m_SingleWidth.setValue(400); ((SpinnerNumberModel) m_SingleWidth.getModel()).setMinimum(1); ((SpinnerNumberModel) m_SingleWidth.getModel()).setStepSize(100); ((JSpinner.DefaultEditor) m_SingleWidth.getEditor()).getTextField().setColumns(5); params.add(createParameter("Width", m_SingleWidth)); // height m_SingleHeight = new JSpinner(); m_SingleHeight.setValue(400); ((SpinnerNumberModel) m_SingleHeight.getModel()).setMinimum(1); ((SpinnerNumberModel) m_SingleHeight.getModel()).setStepSize(100); ((JSpinner.DefaultEditor) m_SingleHeight.getEditor()).getTextField().setColumns(5); params.add(createParameter("Height", m_SingleHeight)); // generator m_SingleGenerator = new JComboBox<>(Registry.toStringArray(Registry.getGenerators(), true)); m_SingleGenerator.addActionListener((ActionEvent e) -> { updateSingleOutput(); }); params.add(createParameter("Generator", m_SingleGenerator)); // center m_SingleCenter = new JComboBox<>(Registry.toStringArray(Registry.getCenters(), true)); params.add(createParameter("Center", m_SingleCenter)); // output m_SingleOutput = new FileChooserPanel(); m_SingleOutput.setUseSaveDialog(true); m_SingleOutput.setPreferredSize(new Dimension(170, (int) m_SingleOutput.getPreferredSize().getHeight())); params.add(createParameter("Output", m_SingleOutput)); // preview/generate panel = new JPanel(new FlowLayout(FlowLayout.LEFT)); m_SinglePreview = new JButton("Preview"); m_SinglePreview.addActionListener((ActionEvent e) -> generateSinglePreview()); m_SingleGenerate = new JButton("Generate"); m_SingleGenerate.addActionListener((ActionEvent e) -> generateSingleOutput()); panel.add(m_SinglePreview); panel.add(m_SingleGenerate); params.add(panel); adjustLabels(); return result; }
From source file:pcgen.gui2.dialog.ChooserDialog.java
private void initComponents() { setTitle(chooser.getName());/*from w w w. j a va2 s. com*/ setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE); addWindowListener(new WindowAdapter() { @Override public void windowClosed(WindowEvent e) { //detach listeners from the chooser treeViewModel.setDelegate(null); listModel.setListFacade(null); chooser.getRemainingSelections().removeReferenceListener(ChooserDialog.this); } }); Container pane = getContentPane(); pane.setLayout(new BorderLayout()); JSplitPane split = new JSplitPane(); JPanel leftPane = new JPanel(new BorderLayout()); if (availTable != null) { availTable.setAutoCreateRowSorter(true); availTable.setTreeViewModel(treeViewModel); availTable.getRowSorter().toggleSortOrder(0); availTable.addActionListener(this); leftPane.add(new JScrollPane(availTable), BorderLayout.CENTER); } else { availInput.addActionListener(this); Dimension maxDim = new Dimension(Integer.MAX_VALUE, availInput.getPreferredSize().height); availInput.setMaximumSize(maxDim); JPanel availPanel = new JPanel(); availPanel.setLayout(new BoxLayout(availPanel, BoxLayout.PAGE_AXIS)); availPanel.add(Box.createRigidArea(new Dimension(10, 30))); availPanel.add(Box.createVerticalGlue()); availPanel.add(new JLabel(LanguageBundle.getString("in_uichooser_value"))); availPanel.add(availInput); availPanel.add(Box.createVerticalGlue()); leftPane.add(availPanel, BorderLayout.WEST); } JPanel buttonPane1 = new JPanel(new FlowLayout()); JButton addButton = new JButton(chooser.getAddButtonName()); addButton.setActionCommand("ADD"); addButton.addActionListener(this); buttonPane1.add(addButton); buttonPane1.add(new JLabel(Icons.Forward16.getImageIcon())); leftPane.add(buttonPane1, BorderLayout.SOUTH); split.setLeftComponent(leftPane); JPanel rightPane = new JPanel(new BorderLayout()); JPanel labelPane = new JPanel(new GridBagLayout()); GridBagConstraints gbc = new GridBagConstraints(); gbc.gridwidth = GridBagConstraints.REMAINDER; labelPane.add(new JLabel(chooser.getSelectionCountName()), new GridBagConstraints()); remainingLabel.setText(chooser.getRemainingSelections().get().toString()); labelPane.add(remainingLabel, gbc); labelPane.add(new JLabel(chooser.getSelectedTableTitle()), gbc); rightPane.add(labelPane, BorderLayout.NORTH); list.setModel(listModel); list.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); list.addActionListener(this); rightPane.add(new JScrollPane(list), BorderLayout.CENTER); JPanel buttonPane2 = new JPanel(new FlowLayout()); buttonPane2.add(new JLabel(Icons.Back16.getImageIcon())); JButton removeButton = new JButton(chooser.getRemoveButtonName()); removeButton.setActionCommand("REMOVE"); removeButton.addActionListener(this); buttonPane2.add(removeButton); rightPane.add(buttonPane2, BorderLayout.SOUTH); split.setRightComponent(rightPane); if (chooser.isInfoAvailable()) { JSplitPane infoSplit = new JSplitPane(JSplitPane.VERTICAL_SPLIT); infoSplit.setTopComponent(split); infoSplit.setBottomComponent(infoPane); infoSplit.setResizeWeight(0.8); pane.add(infoSplit, BorderLayout.CENTER); if (availTable != null) { availTable.getSelectionModel().addListSelectionListener(this); } } else { pane.add(split, BorderLayout.CENTER); } JPanel bottomPane = new JPanel(new FlowLayout()); JButton button = new JButton(LanguageBundle.getString("in_ok")); //$NON-NLS-1$ button.setMnemonic(LanguageBundle.getMnemonic("in_mn_ok")); //$NON-NLS-1$ button.setActionCommand("OK"); button.addActionListener(this); bottomPane.add(button); button = new JButton(LanguageBundle.getString("in_cancel")); //$NON-NLS-1$ button.setMnemonic(LanguageBundle.getMnemonic("in_mn_cancel")); //$NON-NLS-1$ button.setActionCommand("CANCEL"); button.addActionListener(this); bottomPane.add(button); pane.add(bottomPane, BorderLayout.SOUTH); }
From source file:edu.clemson.cs.nestbed.client.gui.MoteDetailFrame.java
private JPanel buildMotePanel() { JPanel panel = new JPanel(); panel.setBorder(new TitledBorder("Mote Information")); panel.setLayout(new BorderLayout()); panel.add(buildMoteLabelPanel(), BorderLayout.WEST); panel.add(buildMoteFieldPanel(), BorderLayout.CENTER); return panel; }
From source file:org.fhaes.FHRecorder.FireHistoryRecorder.java
public void generateScreens(FHX2File inFHX2File) { sampleInput = new SampleInputPanel(inFHX2File.getRequiredPart()); siteInfo = new SiteInfoPanel(inFHX2File.getOptionalPart()); comments = new CommentsPanel(inFHX2File.getOptionalPart()); fileErrors = new FileErrorPanel(); summaryPanel = new SummaryPanel(); graphicsPanel = new GraphicsPanel(); tabbedPane.addChangeListener(new TabChangeListener(tabbedPane, summaryPanel, graphicsPanel)); sampleInputHolder.add(sampleInput, BorderLayout.CENTER); siteInfoHolder.add(siteInfo, BorderLayout.CENTER); siteInfoHolder.add(comments, BorderLayout.SOUTH); fileErrorHolder.add(fileErrors, BorderLayout.CENTER); summaryHolder.add(summaryPanel, BorderLayout.WEST); graphicsHolder.add(graphicsPanel, BorderLayout.CENTER); }
From source file:com.entertailion.java.fling.FlingFrame.java
public FlingFrame(String appId) { super();/*from w w w .ja v a 2s .c om*/ this.appId = appId; rampClient = new RampClient(this); addWindowListener(this); simpleDateFormat.setTimeZone(TimeZone.getTimeZone("UTC")); Locale locale = Locale.getDefault(); resourceBundle = ResourceBundle.getBundle("com/entertailion/java/fling/resources/resources", locale); setTitle(MessageFormat.format(resourceBundle.getString("fling.title"), Fling.VERSION)); JPanel listPane = new JPanel(); // show list of ChromeCast devices detected on the local network listPane.setLayout(new BoxLayout(listPane, BoxLayout.PAGE_AXIS)); JPanel devicePane = new JPanel(); devicePane.setLayout(new BoxLayout(devicePane, BoxLayout.LINE_AXIS)); deviceList = new JComboBox(); deviceList.addActionListener(this); devicePane.add(deviceList); URL url = ClassLoader.getSystemResource("com/entertailion/java/fling/resources/refresh.png"); ImageIcon icon = new ImageIcon(url, resourceBundle.getString("button.refresh")); refreshButton = new JButton(icon); refreshButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { // refresh the list of devices if (deviceList.getItemCount() > 0) { deviceList.setSelectedIndex(0); } discoverDevices(); } }); refreshButton.setToolTipText(resourceBundle.getString("button.refresh")); devicePane.add(refreshButton); url = ClassLoader.getSystemResource("com/entertailion/java/fling/resources/settings.png"); icon = new ImageIcon(url, resourceBundle.getString("settings.title")); settingsButton = new JButton(icon); settingsButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { JTextField transcodingExtensions = new JTextField(50); transcodingExtensions.setText(transcodingExtensionValues); JTextField transcodingParameters = new JTextField(50); transcodingParameters.setText(transcodingParameterValues); JPanel myPanel = new JPanel(new BorderLayout()); JPanel labelPanel = new JPanel(new GridLayout(3, 1)); JPanel fieldPanel = new JPanel(new GridLayout(3, 1)); myPanel.add(labelPanel, BorderLayout.WEST); myPanel.add(fieldPanel, BorderLayout.CENTER); labelPanel.add(new JLabel(resourceBundle.getString("transcoding.extensions"), JLabel.RIGHT)); fieldPanel.add(transcodingExtensions); labelPanel.add(new JLabel(resourceBundle.getString("transcoding.parameters"), JLabel.RIGHT)); fieldPanel.add(transcodingParameters); labelPanel.add(new JLabel(resourceBundle.getString("device.manual"), JLabel.RIGHT)); JPanel devicePanel = new JPanel(new FlowLayout(FlowLayout.LEFT)); final JComboBox manualDeviceList = new JComboBox(); if (manualServers.size() == 0) { manualDeviceList.setVisible(false); } else { for (DialServer dialServer : manualServers) { manualDeviceList.addItem(dialServer); } } devicePanel.add(manualDeviceList); JButton addButton = new JButton(resourceBundle.getString("device.manual.add")); addButton.setToolTipText(resourceBundle.getString("device.manual.add.tooltip")); addButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { JTextField name = new JTextField(); JTextField ipAddress = new JTextField(); Object[] message = { resourceBundle.getString("device.manual.name") + ":", name, resourceBundle.getString("device.manual.ipaddress") + ":", ipAddress }; int option = JOptionPane.showConfirmDialog(null, message, resourceBundle.getString("device.manual"), JOptionPane.OK_CANCEL_OPTION); if (option == JOptionPane.OK_OPTION) { try { manualServers.add( new DialServer(name.getText(), InetAddress.getByName(ipAddress.getText()))); Object selected = deviceList.getSelectedItem(); int selectedIndex = deviceList.getSelectedIndex(); deviceList.removeAllItems(); deviceList.addItem(resourceBundle.getString("devices.select")); for (DialServer dialServer : servers) { deviceList.addItem(dialServer); } for (DialServer dialServer : manualServers) { deviceList.addItem(dialServer); } deviceList.invalidate(); if (selectedIndex > 0) { deviceList.setSelectedItem(selected); } else { if (deviceList.getItemCount() == 2) { // Automatically select single device deviceList.setSelectedIndex(1); } } manualDeviceList.removeAllItems(); for (DialServer dialServer : manualServers) { manualDeviceList.addItem(dialServer); } manualDeviceList.setVisible(true); storeProperties(); } catch (UnknownHostException e1) { Log.e(LOG_TAG, "manual IP address", e1); JOptionPane.showMessageDialog(FlingFrame.this, resourceBundle.getString("device.manual.invalidip")); } } } }); devicePanel.add(addButton); JButton removeButton = new JButton(resourceBundle.getString("device.manual.remove")); removeButton.setToolTipText(resourceBundle.getString("device.manual.remove.tooltip")); removeButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { Object selected = manualDeviceList.getSelectedItem(); manualDeviceList.removeItem(selected); if (manualDeviceList.getItemCount() == 0) { manualDeviceList.setVisible(false); } deviceList.removeItem(selected); deviceList.invalidate(); manualServers.remove(selected); storeProperties(); } }); devicePanel.add(removeButton); fieldPanel.add(devicePanel); int result = JOptionPane.showConfirmDialog(FlingFrame.this, myPanel, resourceBundle.getString("settings.title"), JOptionPane.OK_CANCEL_OPTION); if (result == JOptionPane.OK_OPTION) { transcodingParameterValues = transcodingParameters.getText(); transcodingExtensionValues = transcodingExtensions.getText(); storeProperties(); } } }); settingsButton.setToolTipText(resourceBundle.getString("settings.title")); devicePane.add(settingsButton); listPane.add(devicePane); // TODO volume = new JSlider(JSlider.VERTICAL, 0, 100, 0); volume.setUI(new MySliderUI(volume)); volume.setMajorTickSpacing(25); // volume.setMinorTickSpacing(5); volume.setPaintTicks(true); volume.setEnabled(true); volume.setValue(100); volume.setToolTipText(resourceBundle.getString("volume.title")); volume.addChangeListener(new ChangeListener() { @Override public void stateChanged(ChangeEvent e) { JSlider source = (JSlider) e.getSource(); if (!source.getValueIsAdjusting()) { int position = (int) source.getValue(); rampClient.volume(position / 100.0f); } } }); JPanel centerPanel = new JPanel(new BorderLayout()); // centerPanel.add(volume, BorderLayout.WEST); centerPanel.add(DragHereIcon.makeUI(this), BorderLayout.CENTER); listPane.add(centerPanel); scrubber = new JSlider(JSlider.HORIZONTAL, 0, 100, 0); scrubber.addChangeListener(this); scrubber.setMajorTickSpacing(25); scrubber.setMinorTickSpacing(5); scrubber.setPaintTicks(true); scrubber.setEnabled(false); listPane.add(scrubber); // panel of playback buttons JPanel buttonPane = new JPanel(); buttonPane.setLayout(new BoxLayout(buttonPane, BoxLayout.LINE_AXIS)); label = new JLabel("00:00:00"); buttonPane.add(label); url = ClassLoader.getSystemResource("com/entertailion/java/fling/resources/play.png"); icon = new ImageIcon(url, resourceBundle.getString("button.play")); playButton = new JButton(icon); playButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { rampClient.play(); } }); buttonPane.add(playButton); url = ClassLoader.getSystemResource("com/entertailion/java/fling/resources/pause.png"); icon = new ImageIcon(url, resourceBundle.getString("button.pause")); pauseButton = new JButton(icon); pauseButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { rampClient.pause(); } }); buttonPane.add(pauseButton); url = ClassLoader.getSystemResource("com/entertailion/java/fling/resources/stop.png"); icon = new ImageIcon(url, resourceBundle.getString("button.stop")); stopButton = new JButton(icon); stopButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { rampClient.stop(); setDuration(0); scrubber.setValue(0); scrubber.setEnabled(false); } }); buttonPane.add(stopButton); listPane.add(buttonPane); getContentPane().add(listPane); createProgressDialog(); startWebserver(); discoverDevices(); }
From source file:org.eobjects.datacleaner.panels.OpenAnalysisJobPanel.java
public OpenAnalysisJobPanel(final FileObject file, final AnalyzerBeansConfiguration configuration, final OpenAnalysisJobActionListener openAnalysisJobActionListener) { super(WidgetUtils.BG_COLOR_LESS_BRIGHT, WidgetUtils.BG_COLOR_LESS_BRIGHT); _file = file;//from w w w . ja v a 2s . c o m _openAnalysisJobActionListener = openAnalysisJobActionListener; setLayout(new BorderLayout()); setBorder(WidgetUtils.BORDER_LIST_ITEM); final AnalysisJobMetadata metadata = getMetadata(configuration); final String jobName = metadata.getJobName(); final String jobDescription = metadata.getJobDescription(); final String datastoreName = metadata.getDatastoreName(); final boolean isDemoJob = isDemoJob(metadata); final DCPanel labelListPanel = new DCPanel(); labelListPanel.setLayout(new VerticalLayout(4)); labelListPanel.setBorder(new EmptyBorder(4, 4, 4, 0)); final String title; final String filename = file.getName().getBaseName(); if (Strings.isNullOrEmpty(jobName)) { final String extension = FileFilters.ANALYSIS_XML.getExtension(); if (filename.toLowerCase().endsWith(extension)) { title = filename.substring(0, filename.length() - extension.length()); } else { title = filename; } } else { title = jobName; } final JButton titleButton = new JButton(title); titleButton.setFont(WidgetUtils.FONT_HEADER1); titleButton.setForeground(WidgetUtils.BG_COLOR_BLUE_MEDIUM); titleButton.setHorizontalAlignment(SwingConstants.LEFT); titleButton.setBorder(BorderFactory.createMatteBorder(0, 0, 1, 0, WidgetUtils.BG_COLOR_MEDIUM)); titleButton.setToolTipText("Open job"); titleButton.setOpaque(false); titleButton.setMargin(new Insets(0, 0, 0, 0)); titleButton.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR)); titleButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { if (isDemoDatastoreConfigured(datastoreName, configuration)) { _openAnalysisJobActionListener.openFile(_file); } } }); final JButton executeButton = new JButton(executeIcon); executeButton.setOpaque(false); executeButton.setToolTipText("Execute job directly"); executeButton.setMargin(new Insets(0, 0, 0, 0)); executeButton.setBorderPainted(false); executeButton.setHorizontalAlignment(SwingConstants.RIGHT); executeButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { if (isDemoDatastoreConfigured(datastoreName, configuration)) { final ImageIcon executeIconLarge = ImageManager.get().getImageIcon(IconUtils.ACTION_EXECUTE); final String question = "Are you sure you want to execute the job\n'" + title + "'?"; final int choice = JOptionPane.showConfirmDialog(null, question, "Execute job?", JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE, executeIconLarge); if (choice == JOptionPane.YES_OPTION) { final Injector injector = _openAnalysisJobActionListener.openAnalysisJob(_file); if (injector != null) { final ResultWindow resultWindow = injector.getInstance(ResultWindow.class); resultWindow.open(); resultWindow.startAnalysis(); } } } } }); final DCPanel titlePanel = new DCPanel(); titlePanel.setLayout(new BorderLayout()); titlePanel.add(DCPanel.around(titleButton), BorderLayout.CENTER); titlePanel.add(executeButton, BorderLayout.EAST); labelListPanel.add(titlePanel); if (!Strings.isNullOrEmpty(jobDescription)) { String desc = StringUtils.replaceWhitespaces(jobDescription, " "); desc = StringUtils.replaceAll(desc, " ", " "); final JLabel label = new JLabel(desc); label.setFont(WidgetUtils.FONT_SMALL); labelListPanel.add(label); } final Icon icon; { if (!StringUtils.isNullOrEmpty(datastoreName)) { final JLabel label = new JLabel(" " + datastoreName); label.setFont(WidgetUtils.FONT_SMALL); labelListPanel.add(label); final Datastore datastore = configuration.getDatastoreCatalog().getDatastore(datastoreName); if (isDemoJob) { icon = demoBadgeIcon; } else { icon = IconUtils.getDatastoreSpecificAnalysisJobIcon(datastore); } } else { icon = ImageManager.get().getImageIcon(IconUtils.MODEL_JOB, IconUtils.ICON_SIZE_LARGE); } } final JLabel iconLabel = new JLabel(icon); iconLabel.setPreferredSize(new Dimension(icon.getIconWidth(), icon.getIconHeight())); add(iconLabel, BorderLayout.WEST); add(labelListPanel, BorderLayout.CENTER); }
From source file:JavaXWin.java
public WindowWatcher(JDesktopPane desktop) { m_desktop = desktop;//from www.ja v a2 s . c o m setOpaque(true); m_northResizer = new NorthResizeEdge(this); m_southResizer = new SouthResizeEdge(this); m_eastResizer = new EastResizeEdge(this); m_westResizer = new WestResizeEdge(this); setLayout(new BorderLayout()); add(m_northResizer, BorderLayout.NORTH); add(m_southResizer, BorderLayout.SOUTH); add(m_eastResizer, BorderLayout.EAST); add(m_westResizer, BorderLayout.WEST); MouseInputAdapter ma = new MouseInputAdapter() { public void mousePressed(MouseEvent e) { m_XDifference = e.getX(); m_YDifference = e.getY(); } public void mouseDragged(MouseEvent e) { int vx = 0; int vy = 0; if (m_desktop.getParent() instanceof JViewport) { vx = ((JViewport) m_desktop.getParent()).getViewPosition().x; vy = ((JViewport) m_desktop.getParent()).getViewPosition().y; } int w = m_desktop.getParent().getWidth(); int h = m_desktop.getParent().getHeight(); int x = getX(); int y = getY(); int ex = e.getX(); int ey = e.getY(); if ((ey + y > vy && ey + y < h + vy) && (ex + x > vx && ex + x < w + vx)) { setLocation(ex - m_XDifference + x, ey - m_YDifference + y); } else if (!(ey + y > vy && ey + y < h + vy) && (ex + x > vx && ex + x < w + vx)) { if (!(ey + y > vy) && ey + y < h + vy) setLocation(ex - m_XDifference + x, vy - m_YDifference); else if (ey + y > vy && !(ey + y < h + vy)) setLocation(ex - m_XDifference + x, (h + vy) - m_YDifference); } else if ((ey + y > vy && ey + y < h + vy) && !(ex + x > vx && ex + x < w + vx)) { if (!(ex + x > vx) && ex + x < w + vx) setLocation(vx - m_XDifference, ey - m_YDifference + y); else if (ex + x > vx && !(ex + x < w)) setLocation((w + vx) - m_XDifference, ey - m_YDifference + y); } else if (!(ey + y > vy) && ey + y < h + vy && !(ex + x > vx) && ex + x < w + vx) setLocation(vx - m_XDifference, vy - m_YDifference); else if (!(ey + y > vy) && ey + y < h + vy && ex + x > vx && !(ex + x < w + vx)) setLocation((w + vx) - m_XDifference, vy - m_YDifference); else if (ey + y > vy && !(ey + y < h + vy) && !(ex + x > vx) && ex + x < w + vx) setLocation(vx - m_XDifference, (h + vy) - m_YDifference); else if (ey + y > vy && !(ey + y < h + vy) && ex + x > vx && !(ex + x < w + vx)) setLocation((w + vx) - m_XDifference, (h + vy) - m_YDifference); } public void mouseEntered(MouseEvent e) { setCursor(Cursor.getPredefinedCursor(Cursor.MOVE_CURSOR)); } public void mouseExited(MouseEvent e) { setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR)); } }; addMouseListener(ma); addMouseMotionListener(ma); }
From source file:au.org.ala.delta.intkey.ui.CharacterImageDialog.java
private void init(List<Character> characters, Character dependentCharacter, boolean valuesEditable) { ResourceMap resourceMap = Application.getInstance().getContext().getResourceMap(CharacterImageDialog.class); resourceMap.injectFields(this); _characters = characters;//from w ww . j a v a2 s . com _valuesEditable = valuesEditable; getContentPane().setLayout(new BorderLayout(0, 0)); buildMenuItems(); if (dependentCharacter != null) { if (characters.size() != 1) { throw new IllegalArgumentException( "Dependent character should only be supplied if there is a single character being viewed in the dialog"); } Character ch = characters.get(0); _pnlControllingCharacterMessage = new JPanel(); _pnlControllingCharacterMessage.setFocusable(false); _pnlControllingCharacterMessage.setBorder(new EmptyBorder(5, 0, 0, 0)); getContentPane().add(_pnlControllingCharacterMessage, BorderLayout.NORTH); _pnlControllingCharacterMessage.setLayout(new BorderLayout(0, 0)); _lblWarningIcon = new JLabel(""); _lblWarningIcon.setFocusable(false); _lblWarningIcon.setIcon(UIManager.getIcon("OptionPane.warningIcon")); _pnlControllingCharacterMessage.add(_lblWarningIcon, BorderLayout.WEST); _txtControllingCharacterMessage = new JTextArea(); CharacterFormatter formatter = new CharacterFormatter(true, CommentStrippingMode.RETAIN, AngleBracketHandlingMode.REMOVE_SURROUNDING_REPLACE_INNER, true, false); String setControllingCharacterMessage = UIUtils.getResourceString( "MultiStateInputDialog.setControllingCharacterMessage", formatter.formatCharacterDescription(dependentCharacter), formatter.formatCharacterDescription(ch)); _txtControllingCharacterMessage.setText(setControllingCharacterMessage); _txtControllingCharacterMessage.setFocusable(false); _txtControllingCharacterMessage.setBorder(new EmptyBorder(0, 5, 0, 0)); _txtControllingCharacterMessage.setEditable(false); _pnlControllingCharacterMessage.add(_txtControllingCharacterMessage); _txtControllingCharacterMessage.setWrapStyleWord(true); _txtControllingCharacterMessage.setFont(UIManager.getFont("Button.font")); _txtControllingCharacterMessage.setLineWrap(true); _txtControllingCharacterMessage.setBackground(SystemColor.control); } }
From source file:net.sourceforge.doddle_owl.ui.InputDocumentSelectionPanel.java
public InputDocumentSelectionPanel(InputTermSelectionPanel iwsPanel, DODDLEProject p) { project = p;/*from www.ja v a 2s . c om*/ inputTermSelectionPanel = iwsPanel; termInfoMap = new HashMap<String, TermInfo>(); stopWordSet = new HashSet<String>(); docList = new JList(new DefaultListModel()); docList.addListSelectionListener(this); JScrollPane docListScroll = new JScrollPane(docList); inputDocList = new JList(new DefaultListModel()); inputDocList.addListSelectionListener(this); JScrollPane inputDocListScroll = new JScrollPane(inputDocList); DefaultComboBoxModel docLangBoxModel = new DefaultComboBoxModel(new Object[] { "en", "ja" }); docLangBox = new JComboBox(docLangBoxModel); docLangBox.addActionListener(this); addDocButton = new JButton(new AddDocAction(Translator.getTerm("AddDocumentButton"))); removeDocButton = new JButton(new RemoveDocAction(Translator.getTerm("RemoveDocumentButton"))); DefaultComboBoxModel inputDocLangBoxModel = new DefaultComboBoxModel(new Object[] { "en", "ja" }); inputDocLangBox = new JComboBox(inputDocLangBoxModel); inputDocLangBox.addActionListener(this); addInputDocButton = new JButton(new AddInputDocAction(Translator.getTerm("AddInputDocumentButton"))); removeInputDocButton = new JButton( new RemoveInputDocAction(Translator.getTerm("RemoveInputDocumentButton"))); inputDocArea = new JTextArea(); inputDocArea.setLineWrap(true); JScrollPane inputDocAreaScroll = new JScrollPane(inputDocArea); JPanel docButtonPanel = new JPanel(); docButtonPanel.setLayout(new BorderLayout()); docButtonPanel.setLayout(new GridLayout(1, 3)); docButtonPanel.add(docLangBox); docButtonPanel.add(addDocButton); docButtonPanel.add(removeDocButton); JPanel docPanel = new JPanel(); docPanel.setLayout(new BorderLayout()); docPanel.add(docListScroll, BorderLayout.CENTER); docPanel.add(docButtonPanel, BorderLayout.SOUTH); punctuationField = new JTextField(10); punctuationField.setText(PUNCTUATION_CHARS); setPunctuationButton = new JButton(Translator.getTerm("SetPunctuationCharacterButton")); setPunctuationButton.addActionListener(this); JPanel punctuationPanel = new JPanel(); punctuationPanel.add(punctuationField); punctuationPanel.add(setPunctuationButton); JPanel inputDocButtonPanel = new JPanel(); inputDocButtonPanel.setLayout(new GridLayout(1, 3)); inputDocButtonPanel.add(inputDocLangBox); inputDocButtonPanel.add(addInputDocButton); inputDocButtonPanel.add(removeInputDocButton); JPanel southPanel = new JPanel(); southPanel.setLayout(new BorderLayout()); southPanel.add(inputDocButtonPanel, BorderLayout.WEST); southPanel.add(punctuationPanel, BorderLayout.EAST); JPanel inputDocPanel = new JPanel(); inputDocPanel.setLayout(new BorderLayout()); inputDocPanel.add(inputDocListScroll, BorderLayout.CENTER); inputDocPanel.add(southPanel, BorderLayout.SOUTH); termExtractionButton = new JButton(Translator.getTerm("InputTermExtractionButton"), Utils.getImageIcon("input_term_selection.png")); termExtractionButton.addActionListener(this); genSenCheckBox = new JCheckBox(Translator.getTerm("GensenCheckBox")); genSenCheckBox.setSelected(false); cabochaCheckBox = new JCheckBox(Translator.getTerm("CabochaCheckBox")); cabochaCheckBox.setSelected(true); showImportanceCheckBox = new JCheckBox("??"); nounCheckBox = new JCheckBox(Translator.getTerm("NounCheckBox")); nounCheckBox.setSelected(true); verbCheckBox = new JCheckBox(Translator.getTerm("VerbCheckBox")); verbCheckBox.setSelected(false); otherCheckBox = new JCheckBox(Translator.getTerm("OtherPOSCheckBox")); oneWordCheckBox = new JCheckBox(Translator.getTerm("OneCharacterCheckBox")); JPanel morphemeAnalysisPanel = new JPanel(); morphemeAnalysisPanel.add(genSenCheckBox); morphemeAnalysisPanel.add(cabochaCheckBox); morphemeAnalysisPanel.add(nounCheckBox); morphemeAnalysisPanel.add(verbCheckBox); morphemeAnalysisPanel.add(otherCheckBox); morphemeAnalysisPanel.add(oneWordCheckBox); JPanel buttonPanel = new JPanel(); buttonPanel.setLayout(new BorderLayout()); buttonPanel.add(morphemeAnalysisPanel, BorderLayout.WEST); buttonPanel.add(termExtractionButton, BorderLayout.EAST); mainViews = new View[2]; ViewMap viewMap = new ViewMap(); // mainViews[0] = new View(Translator.getTerm("DocumentList"), null, // docPanel); mainViews[0] = new View(Translator.getTerm("InputDocumentList"), null, inputDocPanel); mainViews[1] = new View(Translator.getTerm("InputDocumentArea"), null, inputDocAreaScroll); for (int i = 0; i < mainViews.length; i++) { viewMap.addView(i, mainViews[i]); } rootWindow = Utils.createDODDLERootWindow(viewMap); setLayout(new BorderLayout()); add(rootWindow, BorderLayout.CENTER); add(buttonPanel, BorderLayout.SOUTH); }
From source file:edu.virginia.speclab.juxta.author.view.export.WebServiceExportDialog.java
/** * Creates the UI panel containing all of the fields necessary to upload * the current session data to the web service *//*from w w w.ja va2 s . co m*/ private void createSetupPane() { this.setupPanel = new JPanel(); this.setupPanel.setLayout(new BorderLayout()); this.setupPanel.setBackground(Color.white); try { String data = IOUtils.toString(LoginDialog.class.getResourceAsStream("/export2.html")); data = data.replace("{LIST}", formatWitnessList()); JLabel txt = new JLabel(data); this.setupPanel.add(txt, BorderLayout.NORTH); } catch (IOException e) { // dunno. not much that can be done! } // ugly layout code to follow. avert your eyes JPanel data = new JPanel(); data.setLayout(new BorderLayout()); data.setBackground(Color.white); JPanel names = new JPanel(); names.setLayout(new BoxLayout(names, BoxLayout.Y_AXIS)); names.setBackground(Color.white); JLabel l = new JLabel("Name:", SwingConstants.RIGHT); l.setPreferredSize(new Dimension(100, 20)); l.setMaximumSize(new Dimension(100, 20)); l.setAlignmentX(RIGHT_ALIGNMENT); names.add(l); names.add(Box.createVerticalStrut(5)); JLabel l2 = new JLabel("Description:", SwingConstants.RIGHT); l2.setPreferredSize(new Dimension(100, 20)); l2.setMaximumSize(new Dimension(100, 20)); l2.setAlignmentX(RIGHT_ALIGNMENT); names.add(l2); data.add(names, BorderLayout.WEST); JPanel edits = new JPanel(); edits.setBackground(Color.white); edits.setLayout(new BoxLayout(edits, BoxLayout.Y_AXIS)); this.nameEdit = new JTextField(); this.nameEdit.setPreferredSize(new Dimension(200, 22)); this.nameEdit.setMaximumSize(new Dimension(200, 22)); File saveFile = this.juxtaFrame.getSession().getSaveFile(); if (saveFile == null) { this.nameEdit.setText("new_session"); } else { String name = saveFile.getName(); this.nameEdit.setText(name.substring(0, name.lastIndexOf('.'))); } edits.add(this.nameEdit); this.descriptionEdit = new JTextArea(3, 0); this.descriptionEdit.setLineWrap(true); this.descriptionEdit.setWrapStyleWord(true); JScrollPane sp = new JScrollPane(this.descriptionEdit); sp.setPreferredSize(new Dimension(194, 60)); sp.setMaximumSize(new Dimension(194, 300)); edits.add(Box.createVerticalStrut(4)); edits.add(sp); data.add(edits, BorderLayout.CENTER); this.setupPanel.add(data, BorderLayout.SOUTH); }