List of usage examples for javax.swing BoxLayout BoxLayout
@ConstructorProperties({ "target", "axis" }) public BoxLayout(Container target, int axis)
From source file:com.apatar.webdav.ui.JWebDavTreeModePanel.java
private void createPanel() { setLayout(new BorderLayout(5, 5)); JPanel panel = new JPanel(); panel.setLayout(new BoxLayout(panel, BoxLayout.Y_AXIS)); add(panel, BorderLayout.CENTER); title = new JLabel(""); panel.add(title);/*from w ww. j a v a 2 s. co m*/ labelPath = new JLabel(WORD_PATH); panel.add(labelPath); panel.add(getFoldersPanel()); }
From source file:BoxAlignmentDemo.java
protected JPanel createButtonRow(boolean changeAlignment) { JButton button1 = new JButton("A JButton", createImageIcon("images/middle.gif")); button1.setVerticalTextPosition(AbstractButton.BOTTOM); button1.setHorizontalTextPosition(AbstractButton.CENTER); JButton button2 = new JButton("Another JButton", createImageIcon("images/geek-cght.gif")); button2.setVerticalTextPosition(AbstractButton.BOTTOM); button2.setHorizontalTextPosition(AbstractButton.CENTER); String title;//from w ww . j av a2 s .c om if (changeAlignment) { title = "Desired"; button1.setAlignmentY(BOTTOM_ALIGNMENT); button2.setAlignmentY(BOTTOM_ALIGNMENT); } else { title = "Default"; } JPanel pane = new JPanel(); pane.setBorder(BorderFactory.createTitledBorder(title)); pane.setLayout(new BoxLayout(pane, BoxLayout.X_AXIS)); pane.add(button1); pane.add(button2); return pane; }
From source file:Align_Projections.java
public void run(String arg) { if (instance != null) { instance.toFront();/*from w ww . j ava2 s.c om*/ return; } instance = this; addKeyListener(IJ.getInstance()); if (sourceStackImp == null) { sourceStackImp = WindowManager.getCurrentImage(); if (sourceStackImp != null) { centerPixel = 0.5 * (sourceStackImp.getWidth() - 1); } else { centerPixel = 50; // completely arbitrary } } setLayout(new BoxLayout(this, BoxLayout.PAGE_AXIS)); Panel valuesPanel = new Panel(); valuesPanel.setLayout(new GridLayout(6, 2)); Label centerPixelLabel = new Label("Center Pixel"); valuesPanel.add(centerPixelLabel); centerPixelText = new TextField(IJ.d2s(centerPixel, 1), 15); valuesPanel.add(centerPixelText); Label detectorAngleLabel = new Label("Detector Angle"); valuesPanel.add(detectorAngleLabel); detectorAngleText = new TextField(IJ.d2s(0, 4), 15); valuesPanel.add(detectorAngleText); Label horizontalBorderLabel = new Label("Horizontal Border"); valuesPanel.add(horizontalBorderLabel); horizontalBorderText = new TextField("0", 15); valuesPanel.add(horizontalBorderText); Label topBorderLabel = new Label("Top Border"); valuesPanel.add(topBorderLabel); topBorderText = new TextField("0", 15); valuesPanel.add(topBorderText); Label bottomBorderLabel = new Label("Bottom Border"); valuesPanel.add(bottomBorderLabel); bottomBorderText = new TextField("0", 15); valuesPanel.add(bottomBorderText); Label crossCorrelationLabel = new Label("Cross-Correlation"); valuesPanel.add(crossCorrelationLabel); crossCorrelationText = new Label("-"); valuesPanel.add(crossCorrelationText); this.add(valuesPanel); updateButton = addButton("Update"); optimizeButton = addButton("Optimize"); applyButton = addButton("Apply to stack and save"); resetButton = addButton("Reset"); pack(); GUI.center(this); show(); }
From source file:org.nees.rpi.vis.ui.XYChartPanelProxy.java
public XYChartPanelProxy(int width, int height) { selectionGroup = new SelectionGroup(); selectionGroup.setSelection(true);/* w ww. j a va2s.c om*/ dataSet = new XYSeriesCollection(); chart = ChartFactory.createXYLineChart(null, domainAxisLabel, rangeAxisLabel, dataSet, PlotOrientation.VERTICAL, true, true, false); chart.setBackgroundPaint(Color.WHITE); chart.getLegend().setPosition(RectangleEdge.RIGHT); chartPanel = new ChartPanel(chart); chartPanel.setPreferredSize(new java.awt.Dimension(width, height)); chartPanel.setFillZoomRectangle(true); chartPanel.setHorizontalAxisTrace(true); chartPanel.setVerticalAxisTrace(true); toolPanel = new JPanel(); toolPanel.setOpaque(false); toolPanel.setLayout(new BoxLayout(toolPanel, BoxLayout.Y_AXIS)); toolPanel.setBorder(BorderFactory.createTitledBorder("Plot Control")); toolPanel.setPreferredSize(new Dimension(155, 100)); chartAreaPanel = new JPanel(); chartAreaPanel.setOpaque(true); chartAreaPanel.setBackground(Color.white); chartAreaPanel.setLayout(new BorderLayout()); chartAreaPanel.add(chartPanel, BorderLayout.CENTER); chartAreaPanel.add(toolPanel, BorderLayout.WEST); initClearSelectionButton(toolPanel); initResetPlotButton(toolPanel); initSaveToImageButton(toolPanel); initShowAsProfilePlotButton(toolPanel); }
From source file:au.org.ala.delta.intkey.ui.FindInCharactersDialog.java
public FindInCharactersDialog(Intkey intkeyApp, IntkeyContext context) { super(intkeyApp.getMainFrame(), false); setResizable(false);// w w w . ja va 2 s . c o m ResourceMap resourceMap = Application.getInstance().getContext() .getResourceMap(FindInCharactersDialog.class); resourceMap.injectFields(this); ActionMap actionMap = Application.getInstance().getContext().getActionMap(this); _intkeyApp = intkeyApp; _numMatchedCharacters = 0; _currentMatchedCharacter = -1; _findAction = actionMap.get("findCharacters"); _nextAction = actionMap.get("nextCharacter"); this.setTitle(windowTitle); _pnlMain = new JPanel(); _pnlMain.setBorder(new EmptyBorder(20, 20, 20, 20)); getContentPane().add(_pnlMain, BorderLayout.CENTER); _pnlMain.setLayout(new BorderLayout(0, 0)); _pnlMainTop = new JPanel(); _pnlMain.add(_pnlMainTop, BorderLayout.NORTH); _pnlMainTop.setLayout(new BoxLayout(_pnlMainTop, BoxLayout.Y_AXIS)); _lblEnterSearchString = new JLabel(enterSearchStringCaption); _lblEnterSearchString.setBorder(new EmptyBorder(0, 0, 5, 0)); _pnlMainTop.add(_lblEnterSearchString); _textField = new JTextField(); _pnlMainTop.add(_textField); _textField.setColumns(10); _textField.getDocument().addDocumentListener(new DocumentListener() { @Override public void removeUpdate(DocumentEvent e) { reset(); } @Override public void insertUpdate(DocumentEvent e) { reset(); } @Override public void changedUpdate(DocumentEvent e) { reset(); } }); _pnlMainBottom = new JPanel(); _pnlMainBottom.setBorder(new EmptyBorder(20, 0, 0, 0)); _pnlMain.add(_pnlMainBottom, BorderLayout.CENTER); _pnlMainBottom.setLayout(new BoxLayout(_pnlMainBottom, BoxLayout.Y_AXIS)); _chckbxSearchStates = new JCheckBox(searchStatesCaption); _chckbxSearchStates.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { reset(); } }); _pnlMainBottom.add(_chckbxSearchStates); _chckbxSearchUsedCharacters = new JCheckBox(searchUsedCharactersCaption); _chckbxSearchUsedCharacters.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { reset(); } }); _pnlMainBottom.add(_chckbxSearchUsedCharacters); _pnlButtons = new JPanel(); _pnlButtons.setBorder(new EmptyBorder(20, 0, 0, 10)); getContentPane().add(_pnlButtons, BorderLayout.EAST); _pnlButtons.setLayout(new BorderLayout(0, 0)); _pnlInnerButtons = new JPanel(); _pnlButtons.add(_pnlInnerButtons, BorderLayout.NORTH); GridBagLayout gbl__pnlInnerButtons = new GridBagLayout(); gbl__pnlInnerButtons.columnWidths = new int[] { 0, 0 }; gbl__pnlInnerButtons.rowHeights = new int[] { 0, 0, 0, 0 }; gbl__pnlInnerButtons.columnWeights = new double[] { 0.0, Double.MIN_VALUE }; gbl__pnlInnerButtons.rowWeights = new double[] { 0.0, 0.0, 0.0, Double.MIN_VALUE }; _pnlInnerButtons.setLayout(gbl__pnlInnerButtons); _btnFindNext = new JButton(); _btnFindNext.setAction(_findAction); GridBagConstraints gbc__btnFindNext = new GridBagConstraints(); gbc__btnFindNext.fill = GridBagConstraints.HORIZONTAL; gbc__btnFindNext.insets = new Insets(0, 0, 5, 0); gbc__btnFindNext.gridx = 0; gbc__btnFindNext.gridy = 0; _pnlInnerButtons.add(_btnFindNext, gbc__btnFindNext); _btnPrevious = new JButton(); _btnPrevious.setAction(actionMap.get("previousCharacter")); _btnPrevious.setEnabled(false); GridBagConstraints gbc__btnPrevious = new GridBagConstraints(); gbc__btnPrevious.insets = new Insets(0, 0, 5, 0); gbc__btnPrevious.gridx = 0; gbc__btnPrevious.gridy = 1; _pnlInnerButtons.add(_btnPrevious, gbc__btnPrevious); _btnDone = new JButton(); _btnDone.setAction(actionMap.get("findCharactersDone")); GridBagConstraints gbc__btnDone = new GridBagConstraints(); gbc__btnDone.fill = GridBagConstraints.HORIZONTAL; gbc__btnDone.gridx = 0; gbc__btnDone.gridy = 2; _pnlInnerButtons.add(_btnDone, gbc__btnDone); this.pack(); this.setLocationRelativeTo(_intkeyApp.getMainFrame()); }
From source file:wattsup.jsdk.ui.ChartPanelSupport.java
/** * /*from w w w . j a va2 s . c o m*/ * @param title * The title of the chart. * @param axisLabel * The axis label. * @param data * The data repository for the chart. Might not be <code>null</code>. * @param updateIntervalInSeconds * The interval in seconds to update the chart. */ public ChartPanelSupport(String title, String axisLabel, T data, int updateIntervalInSeconds) { this.title_ = title; this.axisLabel_ = axisLabel; this.data_ = data; this.updateDelayInSeconds_ = updateIntervalInSeconds; chart_ = this.createChart(); this.chartPanel_ = new org.jfree.chart.ChartPanel(chart_); this.chartPanel_.setDomainZoomable(true); this.chartPanel_.setRangeZoomable(true); setLayout(new BoxLayout(this, 2)); this.add(this.chartPanel_); updateChartExecutorService_ = new ScheduledThreadPoolExecutor(Runtime.getRuntime().availableProcessors()); }
From source file:edu.ku.brc.af.core.NavBox.java
/** * Constructor (with name).//from w w w. jav a 2 s .c o m * @param name the name of the NavBox. * @param collapsable indicates whether the NavBox can be collapsable */ public NavBox(final String name, final boolean collapsable, final boolean scrollable) { super(); this.name = name; setLayout(new BoxLayout(this, BoxLayout.Y_AXIS)); this.scrollable = scrollable; SkinItem skinItem = SkinsMgr.getSkinItem("NavBox"); if (scrollable) { itemsPanel = new JPanel();//new BoxLayout(this, BoxLayout.Y_AXIS)); itemsPanel.setBorder(null); if (skinItem != null) { itemsPanel.setOpaque(skinItem.isOpaque()); skinItem.setupPanel(itemsPanel); } else { itemsPanel.setBackground(NavBoxMgr.getBGColor()); } } setBorder(BorderFactory.createEmptyBorder(22, 4, 4, 4)); setBackground(NavBoxMgr.getBGColor()); setOpaque(!SkinsMgr.hasSkins()); if (scrollable) { JScrollPane scrollPane = new JScrollPane(itemsPanel); scrollPane.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER); scrollPane.setBorder(null); add(scrollPane); } if (collapsable) { /* collapsableIconOpen = IconManager.getIcon("Minimize"); collapsableIconClosed = IconManager.getIcon("Maximize"); addMouseListener(new MouseAdapter() { public void mouseClicked(MouseEvent e) { if (iconRect != null && iconRect.contains(e.getPoint())) { collapsed = !collapsed; if (collapsed) { icon = collapsableIconClosed; setSize(getSize().width, minHeight); } else { icon = collapsableIconOpen; setSize(getPreferredSize()); } validate(); invalidate(); doLayout(); } } }); */ } }
From source file:edu.virginia.speclab.juxta.author.view.export.WebServiceExportDialog.java
public WebServiceExportDialog(JuxtaAuthorFrame frame, WebServiceClient wsClient) { super(frame); this.juxtaFrame = frame; if (wsClient == null) { this.wsClient = new WebServiceClient(frame.getWebServiceUrl()); } else {//from ww w .j av a 2 s . co m this.wsClient = wsClient; } // size and title the main dialog body setTitle("Juxta Web Export"); setResizable(false); setSize(495, 345); setLocationRelativeTo(getParent()); ((JPanel) getContentPane()).setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10)); getContentPane().setLayout(new BorderLayout(15, 15)); getContentPane().setBackground(Color.white); // add the logo to the top left JPanel logoPnl = new JPanel(); logoPnl.setBackground(Color.white); logoPnl.setLayout(new BoxLayout(logoPnl, BoxLayout.Y_AXIS)); logoPnl.add(new JLabel(JuxtaUserInterfaceStyle.JUXTA_LOGO)); logoPnl.add(Box.createVerticalGlue()); getContentPane().add(logoPnl, BorderLayout.WEST); createSetupPane(); createStatusPane(); getContentPane().add(this.setupPanel, BorderLayout.CENTER); getContentPane().add(createButtonBar(), BorderLayout.SOUTH); // create a single scheduled executor to periodically // check for export status. There can only be one at any // give time, so a pool seemed unnecessary this.scheduler = Executors.newSingleThreadScheduledExecutor(); setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE); }
From source file:com._17od.upm.gui.OptionsDialog.java
public OptionsDialog(JFrame frame) { super(frame, Translator.translate("options"), true); Container container = getContentPane(); // Create a pane with an empty border for spacing Border emptyBorder = BorderFactory.createEmptyBorder(2, 5, 5, 5); JPanel emptyBorderPanel = new JPanel(); emptyBorderPanel.setLayout(new BoxLayout(emptyBorderPanel, BoxLayout.Y_AXIS)); emptyBorderPanel.setBorder(emptyBorder); container.add(emptyBorderPanel);/* w ww .j av a2s. c o m*/ // ****************** // *** The DB TO Load On Startup Section // ****************** // Create a pane with an title etched border Border etchedBorder = BorderFactory.createEtchedBorder(EtchedBorder.LOWERED); Border etchedTitleBorder = BorderFactory.createTitledBorder(etchedBorder, ' ' + Translator.translate("general") + ' '); JPanel mainPanel = new JPanel(new GridBagLayout()); mainPanel.setBorder(etchedTitleBorder); emptyBorderPanel.add(mainPanel); GridBagConstraints c = new GridBagConstraints(); // The "Database to Load on Startup" row JLabel urlLabel = new JLabel(Translator.translate("dbToLoadOnStartup")); c.gridx = 0; c.gridy = 0; c.anchor = GridBagConstraints.LINE_START; c.insets = new Insets(0, 5, 3, 0); c.weightx = 1; c.weighty = 0; c.gridwidth = 2; c.fill = GridBagConstraints.NONE; mainPanel.add(urlLabel, c); // The "Database to Load on Startup" input field row dbToLoadOnStartup = new JTextField(Preferences.get(Preferences.ApplicationOptions.DB_TO_LOAD_ON_STARTUP), 25); dbToLoadOnStartup.setHorizontalAlignment(JTextField.LEFT); c.gridx = 0; c.gridy = 1; c.anchor = GridBagConstraints.LINE_START; c.insets = new Insets(0, 5, 5, 5); c.weightx = 1; c.weighty = 0; c.gridwidth = 1; c.fill = GridBagConstraints.HORIZONTAL; mainPanel.add(dbToLoadOnStartup, c); JButton dbToLoadOnStartupButton = new JButton("..."); dbToLoadOnStartupButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { getDBToLoadOnStartup(); } }); c.gridx = 1; c.gridy = 1; c.anchor = GridBagConstraints.LINE_END; c.insets = new Insets(0, 0, 5, 5); c.weightx = 0; c.weighty = 0; c.gridwidth = 1; c.fill = GridBagConstraints.NONE; mainPanel.add(dbToLoadOnStartupButton, c); // The "Language" label row JLabel localeLabel = new JLabel(Translator.translate("language")); c.gridx = 0; c.gridy = 2; c.anchor = GridBagConstraints.LINE_START; c.insets = new Insets(0, 5, 3, 0); c.weightx = 1; c.weighty = 0; c.gridwidth = 2; c.fill = GridBagConstraints.NONE; mainPanel.add(localeLabel, c); // The "Locale" field row localeComboBox = new JComboBox(getSupportedLocaleNames()); for (int i = 0; i < localeComboBox.getItemCount(); i++) { // If the locale language is blank then set it to the English language // I'm not sure why this happens. Maybe it's because the default locale // is English??? String currentLanguage = Translator.getCurrentLocale().getLanguage(); if (currentLanguage.equals("")) { currentLanguage = "en"; } if (currentLanguage.equals(Translator.SUPPORTED_LOCALES[i].getLanguage())) { localeComboBox.setSelectedIndex(i); break; } } c.gridx = 0; c.gridy = 3; c.anchor = GridBagConstraints.LINE_START; c.insets = new Insets(0, 5, 8, 5); c.weightx = 1; c.weighty = 0; c.gridwidth = 2; c.fill = GridBagConstraints.HORIZONTAL; mainPanel.add(localeComboBox, c); // The "Hide account password" row Boolean hideAccountPassword = new Boolean( Preferences.get(Preferences.ApplicationOptions.ACCOUNT_HIDE_PASSWORD, "true")); hideAccountPasswordCheckbox = new JCheckBox(Translator.translate("hideAccountPassword"), hideAccountPassword.booleanValue()); c.gridx = 0; c.gridy = 4; c.anchor = GridBagConstraints.LINE_START; c.insets = new Insets(0, 2, 5, 0); c.weightx = 1; c.weighty = 0; c.gridwidth = 1; c.fill = GridBagConstraints.NONE; mainPanel.add(hideAccountPasswordCheckbox, c); // The "Database auto lock" row Boolean databaseAutoLock = new Boolean( Preferences.get(Preferences.ApplicationOptions.DATABASE_AUTO_LOCK, "false")); databaseAutoLockCheckbox = new JCheckBox(Translator.translate("databaseAutoLock"), databaseAutoLock.booleanValue()); c.gridx = 0; c.gridy = 5; c.anchor = GridBagConstraints.LINE_START; c.insets = new Insets(0, 2, 5, 0); c.weightx = 1; c.weighty = 0; c.gridwidth = 1; c.fill = GridBagConstraints.NONE; mainPanel.add(databaseAutoLockCheckbox, c); databaseAutoLockCheckbox.addItemListener(new ItemListener() { public void itemStateChanged(ItemEvent e) { databaseAutoLockTime.setEnabled(e.getStateChange() == ItemEvent.SELECTED); } }); // The "Database auto lock" field row databaseAutoLockTime = new JTextField( Preferences.get(Preferences.ApplicationOptions.DATABASE_AUTO_LOCK_TIME), 5); c.gridx = 1; c.gridy = 5; c.anchor = GridBagConstraints.LINE_START; c.insets = new Insets(0, 5, 5, 0); c.weightx = 1; c.weighty = 0; c.gridwidth = 1; c.fill = GridBagConstraints.HORIZONTAL; mainPanel.add(databaseAutoLockTime, c); databaseAutoLockTime.setEnabled(databaseAutoLockCheckbox.isSelected()); // The "Generated password length" row accountPasswordLengthLabel = new JLabel(Translator.translate("generatedPasswodLength")); c.gridx = 0; c.gridy = 6; c.anchor = GridBagConstraints.LINE_START; c.insets = new Insets(0, 2, 5, 0); c.weightx = 1; c.weighty = 0; c.gridwidth = 1; c.fill = GridBagConstraints.NONE; mainPanel.add(accountPasswordLengthLabel, c); accountPasswordLength = new JTextField( Preferences.get(Preferences.ApplicationOptions.ACCOUNT_PASSWORD_LENGTH, "8"), 5); c.gridx = 1; c.gridy = 6; c.anchor = GridBagConstraints.LINE_START; c.insets = new Insets(0, 5, 5, 0); c.weightx = 1; c.weighty = 0; c.gridwidth = 1; c.fill = GridBagConstraints.HORIZONTAL; mainPanel.add(accountPasswordLength, c); // Some spacing emptyBorderPanel.add(Box.createVerticalGlue()); // ****************** // *** The HTTPS Section // ****************** // Create a pane with an title etched border Border httpsEtchedTitleBorder = BorderFactory.createTitledBorder(etchedBorder, " HTTPS "); final JPanel httpsPanel = new JPanel(new GridBagLayout()); httpsPanel.setBorder(httpsEtchedTitleBorder); emptyBorderPanel.add(httpsPanel); // The "Accept Self Sigend Certificates" checkbox row Boolean acceptSelfSignedCerts = new Boolean( Preferences.get(Preferences.ApplicationOptions.HTTPS_ACCEPT_SELFSIGNED_CERTS, "false")); acceptSelfSignedCertsCheckbox = new JCheckBox(Translator.translate("acceptSelfSignedCerts"), acceptSelfSignedCerts.booleanValue()); c.gridx = 0; c.gridy = 0; c.anchor = GridBagConstraints.LINE_START; c.insets = new Insets(0, 2, 5, 0); c.weightx = 1; c.weighty = 0; c.gridwidth = 1; c.fill = GridBagConstraints.HORIZONTAL; httpsPanel.add(acceptSelfSignedCertsCheckbox, c); // ****************** // *** The Proxy Section // ****************** // Create a pane with an title etched border Border proxyEtchedTitleBorder = BorderFactory.createTitledBorder(etchedBorder, ' ' + Translator.translate("httpProxy") + ' '); final JPanel proxyPanel = new JPanel(new GridBagLayout()); proxyPanel.setBorder(proxyEtchedTitleBorder); emptyBorderPanel.add(proxyPanel); // The "Enable Proxy" row Boolean proxyEnabled = new Boolean(Preferences.get(Preferences.ApplicationOptions.HTTP_PROXY_ENABLED)); enableProxyCheckbox = new JCheckBox(Translator.translate("enableProxy"), proxyEnabled.booleanValue()); enableProxyCheckbox.addItemListener(new ItemListener() { public void itemStateChanged(ItemEvent e) { if (e.getStateChange() == ItemEvent.SELECTED) { enableProxyComponents(true); } else { enableProxyComponents(false); } } }); c.gridx = 0; c.gridy = 0; c.anchor = GridBagConstraints.LINE_START; c.insets = new Insets(0, 2, 5, 0); c.weightx = 1; c.weighty = 0; c.gridwidth = 1; c.fill = GridBagConstraints.NONE; proxyPanel.add(enableProxyCheckbox, c); // The "HTTP Proxy" label row proxyLabel = new JLabel(Translator.translate("httpProxy")); c.gridx = 0; c.gridy = 1; c.anchor = GridBagConstraints.LINE_START; c.insets = new Insets(0, 5, 3, 0); c.weightx = 1; c.weighty = 0; c.gridwidth = 2; c.fill = GridBagConstraints.NONE; proxyPanel.add(proxyLabel, c); // The "HTTP Proxy Port" label proxyPortLabel = new JLabel(Translator.translate("port")); c.gridx = 1; c.gridy = 1; c.anchor = GridBagConstraints.LINE_START; c.insets = new Insets(0, 5, 3, 5); c.weightx = 1; c.weighty = 0; c.gridwidth = 1; c.fill = GridBagConstraints.NONE; proxyPanel.add(proxyPortLabel, c); // The "HTTP Proxy" field row httpProxyHost = new JTextField(Preferences.get(Preferences.ApplicationOptions.HTTP_PROXY_HOST), 20); c.gridx = 0; c.gridy = 2; c.anchor = GridBagConstraints.LINE_START; c.insets = new Insets(0, 5, 5, 0); c.weightx = 1; c.weighty = 0; c.gridwidth = 1; c.fill = GridBagConstraints.HORIZONTAL; proxyPanel.add(httpProxyHost, c); httpProxyPort = new JTextField(Preferences.get(Preferences.ApplicationOptions.HTTP_PROXY_PORT), 6); c.gridx = 1; c.gridy = 2; c.anchor = GridBagConstraints.LINE_START; c.insets = new Insets(0, 5, 5, 5); c.weightx = 0; c.weighty = 0; c.gridwidth = 1; c.fill = GridBagConstraints.HORIZONTAL; proxyPanel.add(httpProxyPort, c); // The "HTTP Proxy Username" label row proxyUsernameLabel = new JLabel(Translator.translate("httpProxyUsername")); c.gridx = 0; c.gridy = 3; c.anchor = GridBagConstraints.LINE_START; c.insets = new Insets(0, 5, 3, 0); c.weightx = 1; c.weighty = 0; c.gridwidth = 2; c.fill = GridBagConstraints.NONE; proxyPanel.add(proxyUsernameLabel, c); // The "HTTP Proxy Username" field row httpProxyUsername = new JTextField(Preferences.get(Preferences.ApplicationOptions.HTTP_PROXY_USERNAME), 20); c.gridx = 0; c.gridy = 4; c.anchor = GridBagConstraints.LINE_START; c.insets = new Insets(0, 5, 5, 5); c.weightx = 1; c.weighty = 0; c.gridwidth = 2; c.fill = GridBagConstraints.HORIZONTAL; proxyPanel.add(httpProxyUsername, c); // The "HTTP Proxy Password" label row proxyPasswordLabel = new JLabel(Translator.translate("httpProxyPassword")); c.gridx = 0; c.gridy = 5; c.anchor = GridBagConstraints.LINE_START; c.insets = new Insets(0, 5, 3, 0); c.weightx = 1; c.weighty = 0; c.gridwidth = 2; c.fill = GridBagConstraints.NONE; proxyPanel.add(proxyPasswordLabel, c); // The "HTTP Proxy Password" field row String encodedPassword = Preferences.get(Preferences.ApplicationOptions.HTTP_PROXY_PASSWORD); String decodedPassword = null; if (encodedPassword != null) { decodedPassword = new String(Base64.decodeBase64(encodedPassword.getBytes())); } httpProxyPassword = new JPasswordField(decodedPassword, 20); c.gridx = 0; c.gridy = 6; c.anchor = GridBagConstraints.LINE_START; c.insets = new Insets(0, 5, 5, 5); c.weightx = 1; c.weighty = 0; c.gridwidth = 1; c.fill = GridBagConstraints.HORIZONTAL; proxyPanel.add(httpProxyPassword, c); hidePasswordCheckbox = new JCheckBox(Translator.translate("hide"), true); defaultEchoChar = httpProxyPassword.getEchoChar(); hidePasswordCheckbox.addItemListener(new ItemListener() { public void itemStateChanged(ItemEvent e) { if (e.getStateChange() == ItemEvent.SELECTED) { httpProxyPassword.setEchoChar(defaultEchoChar); } else { httpProxyPassword.setEchoChar((char) 0); } } }); c.gridx = 1; c.gridy = 6; c.anchor = GridBagConstraints.LINE_START; c.insets = new Insets(0, 5, 5, 0); c.weightx = 0; c.weighty = 0; c.gridwidth = 1; c.fill = GridBagConstraints.NONE; proxyPanel.add(hidePasswordCheckbox, c); // Some spacing emptyBorderPanel.add(Box.createVerticalGlue()); // The buttons row JPanel buttonPanel = new JPanel(new FlowLayout()); emptyBorderPanel.add(buttonPanel); JButton okButton = new JButton(Translator.translate("ok")); okButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { okButtonAction(); } }); buttonPanel.add(okButton); JButton cancelButton = new JButton(Translator.translate("cancel")); cancelButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { setVisible(false); dispose(); } }); buttonPanel.add(cancelButton); enableProxyComponents(proxyEnabled.booleanValue()); }
From source file:net.lldp.checksims.ui.results.ScrollViewer.java
/** * Create a scroll viewer from a sortable Matrix Viewer * @param results the sortableMatrix to view * @param toRevalidate frame to revalidate sometimes */// w w w . j a va2s. c om public ScrollViewer(SimilarityMatrix exportMatrix, SortableMatrixViewer results, JFrame toRevalidate) { resultsView = new JScrollPane(results); setBackground(Color.black); resultsView.addComponentListener(new ComponentListener() { @Override public void componentHidden(ComponentEvent arg0) { } @Override public void componentMoved(ComponentEvent arg0) { } @Override public void componentResized(ComponentEvent ce) { Dimension size = ce.getComponent().getSize(); results.padToSize(size); } @Override public void componentShown(ComponentEvent arg0) { } }); resultsView.getViewport().addChangeListener(new ChangeListener() { @Override public void stateChanged(ChangeEvent e) { Rectangle r = resultsView.getViewport().getViewRect(); results.setViewAt(r); } }); resultsView.setBackground(Color.black); sidebar = new JPanel(); setPreferredSize(new Dimension(900, 631)); setMinimumSize(new Dimension(900, 631)); sidebar.setPreferredSize(new Dimension(200, 631)); sidebar.setMaximumSize(new Dimension(200, 3000)); resultsView.setMinimumSize(new Dimension(700, 631)); resultsView.setPreferredSize(new Dimension(700, 631)); sidebar.setBackground(Color.GRAY); setLayout(new BoxLayout(this, BoxLayout.LINE_AXIS)); this.add(sidebar); this.add(resultsView); resultsView.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS); resultsView.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_ALWAYS); resultsView.getVerticalScrollBar().setUnitIncrement(16); resultsView.getHorizontalScrollBar().setUnitIncrement(16); Integer[] presetThresholds = { 80, 60, 40, 20, 0 }; JComboBox<Integer> threshHold = new JComboBox<Integer>(presetThresholds); threshHold.addItemListener(new ItemListener() { public void itemStateChanged(ItemEvent event) { if (event.getStateChange() == ItemEvent.SELECTED) { Integer item = (Integer) event.getItem(); results.updateThreshold(item / 100.0); toRevalidate.revalidate(); toRevalidate.repaint(); } } }); threshHold.setSelectedIndex(0); results.updateThreshold((Integer) threshHold.getSelectedItem() / 100.0); JTextField student1 = new JTextField(15); JTextField student2 = new JTextField(15); KeyListener search = new KeyListener() { @Override public void keyPressed(KeyEvent e) { } @Override public void keyReleased(KeyEvent e) { results.highlightMatching(student1.getText(), student2.getText()); toRevalidate.revalidate(); toRevalidate.repaint(); } @Override public void keyTyped(KeyEvent e) { } }; student1.addKeyListener(search); student2.addKeyListener(search); Collection<MatrixPrinter> printerNameSet = MatrixPrinterRegistry.getInstance() .getSupportedImplementations(); JComboBox<MatrixPrinter> exportAs = new JComboBox<>(new Vector<>(printerNameSet)); JButton exportAsSave = new JButton("Save"); JFileChooser fc = new JFileChooser(); fc.setFileSelectionMode(JFileChooser.FILES_ONLY); fc.setCurrentDirectory(new java.io.File(".")); fc.setDialogTitle("Save results"); exportAsSave.addActionListener(ae -> { MatrixPrinter method = (MatrixPrinter) exportAs.getSelectedItem(); int err = fc.showDialog(toRevalidate, "Save"); if (err == JFileChooser.APPROVE_OPTION) { try { FileUtils.writeStringToFile(fc.getSelectedFile(), method.printMatrix(exportMatrix)); } catch (InternalAlgorithmError | IOException e1) { // TODO log / show error } } }); JPanel thresholdLabel = new JPanel(); JPanel studentSearchLabel = new JPanel(); JPanel fileOutputLabel = new JPanel(); thresholdLabel.setBorder(BorderFactory.createTitledBorder("Matching Threshold")); studentSearchLabel.setBorder(BorderFactory.createTitledBorder("Student Search")); fileOutputLabel.setBorder(BorderFactory.createTitledBorder("Save Results")); thresholdLabel.add(threshHold); studentSearchLabel.add(student1); studentSearchLabel.add(student2); fileOutputLabel.add(exportAs); fileOutputLabel.add(exportAsSave); studentSearchLabel.setPreferredSize(new Dimension(200, 100)); studentSearchLabel.setMinimumSize(new Dimension(200, 100)); thresholdLabel.setPreferredSize(new Dimension(200, 100)); thresholdLabel.setMinimumSize(new Dimension(200, 100)); fileOutputLabel.setPreferredSize(new Dimension(200, 100)); fileOutputLabel.setMinimumSize(new Dimension(200, 100)); sidebar.setMaximumSize(new Dimension(200, 4000)); sidebar.add(thresholdLabel); sidebar.add(studentSearchLabel); sidebar.add(fileOutputLabel); }