List of usage examples for javax.swing JScrollPane setBorder
@BeanProperty(preferred = true, visualUpdate = true, description = "The component's border.") public void setBorder(Border border)
From source file:com.projity.pm.graphic.spreadsheet.common.CommonSpreadSheet.java
protected void configureEnclosingScrollPane() { super.configureEnclosingScrollPane(); Container p = getParent();/*from w ww . ja va 2s. co m*/ if (p instanceof JViewport) { Container gp = p.getParent(); if (gp instanceof JScrollPane) { JScrollPane scrollPane = (JScrollPane) gp; JViewport viewport = scrollPane.getViewport(); if (viewport == null || viewport.getView() != this) return; configureScrollPaneHeaders(scrollPane); Border border = scrollPane.getBorder(); if (border == null || border instanceof UIResource) { scrollPane.setBorder(UIManager.getBorder("Table.scrollPaneBorder")); } } } }
From source file:com.jvms.i18neditor.editor.Editor.java
private void setupUI() { Color borderColor = Colors.scale(UIManager.getColor("Panel.background"), .8f); setTitle(TITLE);//from w w w . ja va2 s . c om setDefaultCloseOperation(DO_NOTHING_ON_CLOSE); addWindowListener(new EditorWindowListener()); setIconImages(Lists.newArrayList("512", "256", "128", "64", "48", "32", "24", "20", "16").stream() .map(size -> Images.loadFromClasspath("images/icon-" + size + ".png").getImage()) .collect(Collectors.toList())); translationTree = new TranslationTree(); translationTree.setBorder(BorderFactory.createEmptyBorder(0, 5, 0, 5)); translationTree.addTreeSelectionListener(new TranslationTreeNodeSelectionListener()); translationTree.addMouseListener(new TranslationTreeMouseListener()); translationField = new TranslationField(); translationField.addKeyListener(new TranslationFieldKeyListener()); translationField.setBorder( BorderFactory.createCompoundBorder(BorderFactory.createMatteBorder(1, 0, 0, 1, borderColor), ((CompoundBorder) translationField.getBorder()).getInsideBorder())); JScrollPane translationsScrollPane = new JScrollPane(translationTree); translationsScrollPane.getViewport().setOpaque(false); translationsScrollPane.setOpaque(false); translationsScrollPane.setBorder(BorderFactory.createMatteBorder(0, 0, 0, 1, borderColor)); translationsPanel = new JPanel(new BorderLayout()); translationsPanel.add(translationsScrollPane); translationsPanel.add(translationField, BorderLayout.SOUTH); resourcesPanel = new JScrollablePanel(true, false); resourcesPanel.setLayout(new BoxLayout(resourcesPanel, BoxLayout.Y_AXIS)); resourcesPanel.setBorder(BorderFactory.createEmptyBorder(10, 20, 10, 20)); resourcesPanel.setOpaque(false); resourcesPanel.addMouseListener(new ResourcesPaneMouseListener()); resourcesScrollPane = new JScrollPane(resourcesPanel); resourcesScrollPane.getViewport().setOpaque(false); resourcesScrollPane.setOpaque(false); resourcesScrollPane.setBorder(null); resourcesScrollPane.addMouseListener(new ResourcesPaneMouseListener()); contentPane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, true, translationsPanel, resourcesScrollPane); contentPane.setBorder(null); contentPane.setDividerSize(10); // Style the split pane divider if possible SplitPaneUI splitPaneUI = contentPane.getUI(); if (splitPaneUI instanceof BasicSplitPaneUI) { BasicSplitPaneDivider divider = ((BasicSplitPaneUI) splitPaneUI).getDivider(); divider.setBorder(null); resourcesPanel.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 20)); } introText = new JLabel("<html><body style=\"text-align:center; padding:30px;\">" + MessageBundle.get("core.intro.text") + "</body></html>"); introText.setOpaque(true); introText.setFont(introText.getFont().deriveFont(28f)); introText.setHorizontalTextPosition(JLabel.CENTER); introText.setVerticalTextPosition(JLabel.BOTTOM); introText.setHorizontalAlignment(JLabel.CENTER); introText.setVerticalAlignment(JLabel.CENTER); introText.setForeground(getBackground().darker()); introText.setIcon(Images.loadFromClasspath("images/icon-intro.png")); Container container = getContentPane(); container.add(introText); editorMenu = new EditorMenuBar(this, translationTree); setJMenuBar(editorMenu); }
From source file:lol.search.RankedStatsPage.java
private JScrollPane championSelectPanel() { JPanel mainPanel = new JPanel(new FlowLayout()); //mainPanel.setBorder(BorderFactory.createLineBorder(Color.WHITE)); mainPanel.setBackground(backgroundColor); for (int i = 0; i < this.objChampRankedList.size(); i++) { int position = counter; ImageIcon champImageIcon = this.OBJ_RANKED_STATS_BY_ID.getChampionIconOf(this.champKeyList.get(i)); JButton champButton = new JButton(); champButton.setIcon(champImageIcon); if (i == 0) { champButton.setIcon(this.profileIcon); champButton.setToolTipText("Overall Stats"); }//w w w. ja v a2s . c o m champButton.setPreferredSize(new Dimension(55, 55)); champButton.setBackground(Color.BLACK); champButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { //button pressed background.setIcon(OBJ_GAME_STATIC_DATA.getBackgroundImageIcon(champKeyList.get(position))); loadArtLabel.setIcon(OBJ_GAME_STATIC_DATA.initLoadingArt(champKeyList.get(position))); nameHeader.setText(OBJ_ALL_CHAMPS_BY_ID.getChampNameFromId(champIdList.get(position))); titleHeader.setText(" " + OBJ_ALL_CHAMPS_BY_ID.getChampTitleFromId(champIdList.get(position))); String sessionsWon = ""; String sessionsLost = ""; String winPercentString = ""; try { int won = objChampRankedList.get(position).getJSONObject("stats") .getInt("totalSessionsWon"); sessionsWon = Integer.toString(won); int lost = objChampRankedList.get(position).getJSONObject("stats") .getInt("totalSessionsLost"); sessionsLost = Integer.toString(lost); winPercentString = getWinPercentage(won, lost); totalGamesInt = won + lost; avgKillsLabelValue.setText(new DecimalFormat("##.##") .format((double) objChampRankedList.get(position).getJSONObject("stats") .getInt("totalChampionKills") / (double) totalGamesInt)); avgAssistsLabelValue .setText(new DecimalFormat("##.##").format((double) objChampRankedList.get(position) .getJSONObject("stats").getInt("totalAssists") / (double) totalGamesInt)); avgDeathsLabelValue.setText(new DecimalFormat("##.##") .format((double) objChampRankedList.get(position).getJSONObject("stats") .getInt("totalDeathsPerSession") / (double) totalGamesInt)); avgMinionKillsLabelValue.setText(new DecimalFormat("##.##") .format((double) objChampRankedList.get(position).getJSONObject("stats") .getInt("totalMinionKills") / (double) totalGamesInt)); avgDoubleKillsLabelValue.setText(new DecimalFormat("##.##") .format((double) objChampRankedList.get(position).getJSONObject("stats") .getInt("totalDoubleKills") / (double) totalGamesInt)); avgTripleKillsLabelValue.setText(new DecimalFormat("##.##") .format((double) objChampRankedList.get(position).getJSONObject("stats") .getInt("totalTripleKills") / (double) totalGamesInt)); avgQuadKillsLabelValue.setText(new DecimalFormat("##.##") .format((double) objChampRankedList.get(position).getJSONObject("stats") .getInt("totalQuadraKills") / (double) totalGamesInt)); avgPentaKillsLabelValue.setText(new DecimalFormat("##.##") .format((double) objChampRankedList.get(position).getJSONObject("stats") .getInt("totalPentaKills") / (double) totalGamesInt)); totalKillsLabelValue.setText(new DecimalFormat("#######").format((double) objChampRankedList .get(position).getJSONObject("stats").getInt("totalChampionKills"))); totalDeathsLabelValue .setText(new DecimalFormat("#######").format((double) objChampRankedList .get(position).getJSONObject("stats").getInt("totalDeathsPerSession"))); totalAssistsLabelValue .setText(new DecimalFormat("#######").format((double) objChampRankedList .get(position).getJSONObject("stats").getInt("totalAssists"))); totalMinionsLabelValue .setText(new DecimalFormat("#######").format((double) objChampRankedList .get(position).getJSONObject("stats").getInt("totalMinionKills"))); totalDoubleKillsLabelValue .setText(new DecimalFormat("#######").format((double) objChampRankedList .get(position).getJSONObject("stats").getInt("totalDoubleKills"))); totalTripleKillsLabelValue .setText(new DecimalFormat("#######").format((double) objChampRankedList .get(position).getJSONObject("stats").getInt("totalTripleKills"))); totalQuadKillsLabelValue .setText(new DecimalFormat("#######").format((double) objChampRankedList .get(position).getJSONObject("stats").getInt("totalQuadraKills"))); totalPentaKillsLabelValue .setText(new DecimalFormat("#######").format((double) objChampRankedList .get(position).getJSONObject("stats").getInt("totalPentaKills"))); } catch (JSONException ex) { Logger.getLogger(RankedStatsPage.class.getName()).log(Level.SEVERE, null, ex); } totalWins.setText(sessionsWon); totalLosses.setText(sessionsLost); winPercent.setText(winPercentString + "%"); totalGamesPlayed.setText(String.valueOf(totalGamesInt)); masterFrame.revalidate(); masterFrame.repaint(); } }); champButton.setToolTipText(OBJ_ALL_CHAMPS_BY_ID.getChampNameFromId(champIdList.get(position))); champButtons.add(champButton); //champButton.setBorder(BorderFactory.createLineBorder(Color.BLACK)); counter++; } for (int i = 0; i < champButtons.size(); i++) { mainPanel.add(champButtons.get(i)); mainPanel.revalidate(); } JScrollPane scrollPane = new JScrollPane(mainPanel); scrollPane.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED); scrollPane.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_NEVER); scrollPane.setPreferredSize(new Dimension(1200, 85)); scrollPane.setBackground(new Color(0, 0, 0, 100)); scrollPane.setBorder(BorderFactory.createLineBorder(Color.BLACK)); scrollPane.getHorizontalScrollBar().setUI(new BasicScrollBarUI() { @Override protected void configureScrollBarColors() { this.thumbColor = new Color(124, 124, 124, 255); this.trackColor = Color.BLACK; } }); return scrollPane; }
From source file:com.zigabyte.stock.stratplot.StrategyPlotter.java
private void initLayout() { Container content = this.getContentPane(); JComponent controls = Box.createVerticalBox(); {/*from ww w . j a v a 2s . c om*/ JPanel filePanel = new JPanel(new BorderLayout()); { filePanel.setBorder(BorderFactory.createTitledBorder("Stock Market Trading Data")); JPanel dataButtons = new JPanel(new GridLayout(2, 1)); { dataButtons.add(this.loadFileButton); dataButtons.add(this.viewDataButton); } filePanel.add(dataButtons, BorderLayout.EAST); JPanel fileControls = new JPanel(new FlowLayout()); { fileControls.add(new JLabel("Stock data File:")); fileControls.add(this.fileField); fileControls.add(this.fileBrowseButton); fileControls.add(new JLabel(" Stock data format:")); fileControls.add(this.fileFormatCombo); } filePanel.add(fileControls, BorderLayout.CENTER); } controls.add(filePanel); JComponent simPanel = new JPanel(new BorderLayout()); { simPanel.setBorder(BorderFactory.createTitledBorder("Simulation Run")); simPanel.add(this.runButton, BorderLayout.EAST); JComponent simControlsPanel = Box.createVerticalBox(); { JPanel accountControls = new JPanel(new FlowLayout()); { accountControls.add(new JLabel("Initial Cash:")); accountControls.add(this.initialCashField); accountControls.add(new JLabel(" Per Trade Fee:")); accountControls.add(this.perTradeFeeField); accountControls.add(new JLabel(" Per Share Trade Commission:")); accountControls.add(this.perShareTradeCommissionField); accountControls.add(new JLabel(" Compare:")); accountControls.add(this.compareIndexSymbolField); } simControlsPanel.add(accountControls); JPanel runControls = new JPanel(new FlowLayout()); { runControls.add(this.strategyField); runControls.add(new JLabel("Start Date:")); runControls.add(this.startDateField); runControls.add(new JLabel(" End Date:")); runControls.add(this.endDateField); runControls.add(new JLabel(" Strategy:")); runControls.add(this.strategyField); runControls.add(this.editButton); runControls.add(this.compileButton); } simControlsPanel.add(runControls); } simPanel.add(simControlsPanel, BorderLayout.CENTER); } controls.add(simPanel); } content.add(controls, BorderLayout.NORTH); JSplitPane vSplit = this.vSplit; { vSplit.setResizeWeight(0.5); vSplit.add(this.chartPanel, JSplitPane.TOP); JSplitPane hSplit = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT); { hSplit.setResizeWeight(0.5); // enough for no hscrollbar in 1024 width JSplitPane reportSplit = new JSplitPane(JSplitPane.VERTICAL_SPLIT); { reportSplit.setResizeWeight(0.5); JScrollPane reportScroll = new JScrollPane(this.reportArea); { reportScroll.setBorder(BorderFactory.createTitledBorder("Report")); } reportSplit.add(reportScroll, JSplitPane.TOP); JScrollPane monthScroll = new JScrollPane(this.monthlyLogArea); { monthScroll.setBorder(BorderFactory.createTitledBorder("Monthly Log")); } reportSplit.add(monthScroll, JSplitPane.BOTTOM); } hSplit.add(reportSplit, JSplitPane.LEFT); JScrollPane tradeScroll = new JScrollPane(this.tradeLogArea); { tradeScroll.setBorder(BorderFactory.createTitledBorder("Trade Log")); } hSplit.add(tradeScroll, JSplitPane.RIGHT); } vSplit.add(hSplit, JSplitPane.BOTTOM); } content.add(vSplit, BorderLayout.CENTER); }
From source file:de.codesourcery.eve.skills.ui.components.impl.MarketPriceEditorComponent.java
@Override protected JPanel createPanel() { // add search textfield final JPanel inputPanel = new JPanel(); inputPanel.setBorder(lineBorder(Color.black)); inputPanel.setLayout(new GridBagLayout()); inputPanel.add(itemNameFilter.getPanel(), constraints(0, 0).anchorWest().noResizing().end()); importMarketLogButton.addActionListener(new ActionListener() { @Override/*from w w w.j a v a 2 s . com*/ public void actionPerformed(ActionEvent e) { importMarketLogs(); } }); inputPanel.add(importMarketLogButton, constraints(0, 1).anchorWest().noResizing().end()); // add item description text area selectedItemDescription.setEditable(false); selectedItemDescription.setWrapStyleWord(true); selectedItemDescription.setLineWrap(true); final JScrollPane selectedItemDescPanel = new JScrollPane(selectedItemDescription); selectedItemDescPanel.setBorder(BorderFactory.createTitledBorder("Selected item")); // setup table tableModel.setViewFilter(this.itemNameFilter.getViewFilter()); table.setModel(tableModel); table.setRowSorter(tableModel.getRowSorter()); table.setDefaultRenderer(String.class, new StalePriceInfoHighlighter()); table.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION); table.getSelectionModel().addListSelectionListener(new ListSelectionListener() { @Override public void valueChanged(ListSelectionEvent e) { if (!e.getValueIsAdjusting()) { final int viewRow = table.getSelectedRow(); if (viewRow != -1) { final int modelRow = table.convertRowIndexToModel(viewRow); updateItemDescriptionDisplay(modelRow); } } } }); table.setFillsViewportHeight(true); table.addMouseListener(popupListener); table.setFillsViewportHeight(true); // setup split pane final JPanel result = new JPanel(); final JPanel topPanel = new JPanel(); new GridLayoutBuilder().add(new GridLayoutBuilder.HorizontalGroup(new GridLayoutBuilder.Cell(inputPanel), new GridLayoutBuilder.Cell(selectedItemDescPanel))).addTo(topPanel); final JSplitPane pane = new ImprovedSplitPane(JSplitPane.VERTICAL_SPLIT, topPanel, tablePane); pane.setDividerLocation(0.3d); // only works because of the splitpane // hack pane.setContinuousLayout(true); result.setLayout(new GridBagLayout()); result.add(pane, constraints().resizeBoth().useRemainingSpace().end()); return result; }
From source file:net.pms.newgui.NavigationShareTab.java
public JComponent build() { // Apply the orientation for the locale ComponentOrientation orientation = ComponentOrientation.getOrientation(PMS.getLocale()); String colSpec = FormLayoutUtil.getColSpec(PANEL_COL_SPEC, orientation); // Set basic layout FormLayout layout = new FormLayout(colSpec, PANEL_ROW_SPEC); PanelBuilder builder = new PanelBuilder(layout); builder.border(Borders.DLU4);/*from w ww. j ava2 s . c o m*/ builder.opaque(true); CellConstraints cc = new CellConstraints(); // Init all gui components initSimpleComponents(cc); sharedPanel = initSharedFoldersGuiComponents(cc).build(); // Build gui with initialized components if (!configuration.isHideAdvancedOptions()) { JComponent cmp = builder.addSeparator(Messages.getString("FoldTab.13"), FormLayoutUtil.flip(cc.xyw(1, 1, 12), colSpec, orientation)); cmp = (JComponent) cmp.getComponent(0); cmp.setFont(cmp.getFont().deriveFont(Font.BOLD)); builder.add(GuiUtil.getPreferredSizeComponent(thumbgenCheckBox), FormLayoutUtil.flip(cc.xyw(1, 3, 3), colSpec, orientation)); builder.addLabel(Messages.getString("NetworkTab.16"), FormLayoutUtil.flip(cc.xyw(4, 3, 2), colSpec, orientation)); builder.add(seekpos, FormLayoutUtil.flip(cc.xy(6, 3), colSpec, orientation)); builder.add(GuiUtil.getPreferredSizeComponent(image_thumb), FormLayoutUtil.flip(cc.xyw(9, 3, 4), colSpec, orientation)); builder.addLabel(Messages.getString("FoldTab.26"), FormLayoutUtil.flip(cc.xyw(1, 5, 3), colSpec, orientation)); builder.add(audiothumbnail, FormLayoutUtil.flip(cc.xyw(4, 5, 3), colSpec, orientation)); builder.add(GuiUtil.getPreferredSizeComponent(mplayer_thumb), FormLayoutUtil.flip(cc.xyw(9, 5, 4), colSpec, orientation)); builder.addLabel(Messages.getString("FoldTab.27"), FormLayoutUtil.flip(cc.xy(1, 7), colSpec, orientation)); builder.add(defaultThumbFolder, FormLayoutUtil.flip(cc.xyw(4, 7, 2), colSpec, orientation)); builder.add(select, FormLayoutUtil.flip(cc.xy(6, 7), colSpec, orientation)); builder.add(GuiUtil.getPreferredSizeComponent(dvdiso_thumb), FormLayoutUtil.flip(cc.xyw(9, 7, 4), colSpec, orientation)); cmp = builder.addSeparator(Messages.getString("NetworkTab.59"), FormLayoutUtil.flip(cc.xyw(1, 9, 12), colSpec, orientation)); cmp = (JComponent) cmp.getComponent(0); cmp.setFont(cmp.getFont().deriveFont(Font.BOLD)); builder.addLabel(Messages.getString("FoldTab.18"), FormLayoutUtil.flip(cc.xyw(1, 11, 3), colSpec, orientation)); builder.add(sortmethod, FormLayoutUtil.flip(cc.xyw(4, 11, 3), colSpec, orientation)); builder.add(GuiUtil.getPreferredSizeComponent(ignorethewordthe), FormLayoutUtil.flip(cc.xyw(9, 11, 4), colSpec, orientation)); builder.add(GuiUtil.getPreferredSizeComponent(prettifyfilenames), FormLayoutUtil.flip(cc.xyw(1, 13, 5), colSpec, orientation)); builder.add(GuiUtil.getPreferredSizeComponent(episodeTitles), FormLayoutUtil.flip(cc.xyw(9, 13, 4), colSpec, orientation)); cmp = builder.addSeparator(Messages.getString("NetworkTab.60"), FormLayoutUtil.flip(cc.xyw(1, 15, 12), colSpec, orientation)); cmp = (JComponent) cmp.getComponent(0); cmp.setFont(cmp.getFont().deriveFont(Font.BOLD)); builder.add(GuiUtil.getPreferredSizeComponent(hideextensions), FormLayoutUtil.flip(cc.xyw(1, 17, 3), colSpec, orientation)); builder.add(GuiUtil.getPreferredSizeComponent(hideengines), FormLayoutUtil.flip(cc.xyw(4, 17, 3), colSpec, orientation)); builder.add(GuiUtil.getPreferredSizeComponent(hideemptyfolders), FormLayoutUtil.flip(cc.xyw(9, 17, 4), colSpec, orientation)); builder.add(GuiUtil.getPreferredSizeComponent(itunes), FormLayoutUtil.flip(cc.xy(1, 19), colSpec, orientation)); builder.add(GuiUtil.getPreferredSizeComponent(iphoto), FormLayoutUtil.flip(cc.xyw(4, 19, 3), colSpec, orientation)); builder.add(GuiUtil.getPreferredSizeComponent(aperture), FormLayoutUtil.flip(cc.xyw(9, 19, 4), colSpec, orientation)); builder.add(GuiUtil.getPreferredSizeComponent(cacheenable), FormLayoutUtil.flip(cc.xy(1, 21), colSpec, orientation)); builder.add(cachereset, FormLayoutUtil.flip(cc.xyw(4, 21, 3), colSpec, orientation)); builder.add(GuiUtil.getPreferredSizeComponent(isShowFolderMediaLibrary), FormLayoutUtil.flip(cc.xyw(9, 21, 4), colSpec, orientation)); builder.add(GuiUtil.getPreferredSizeComponent(archive), FormLayoutUtil.flip(cc.xyw(1, 23, 3), colSpec, orientation)); builder.add(GuiUtil.getPreferredSizeComponent(isShowFolderServerSettings), FormLayoutUtil.flip(cc.xyw(4, 23, 3), colSpec, orientation)); builder.add(GuiUtil.getPreferredSizeComponent(isShowFolderTranscode), FormLayoutUtil.flip(cc.xyw(9, 23, 4), colSpec, orientation)); builder.add(GuiUtil.getPreferredSizeComponent(isShowFolderLiveSubtitles), FormLayoutUtil.flip(cc.xyw(1, 25, 3), colSpec, orientation)); builder.addLabel(Messages.getString("FoldTab.37"), FormLayoutUtil.flip(cc.xyw(4, 25, 2), colSpec, orientation)); builder.add(atzLimit, FormLayoutUtil.flip(cc.xy(6, 25), colSpec, orientation)); builder.add(GuiUtil.getPreferredSizeComponent(isShowFolderNewMedia), FormLayoutUtil.flip(cc.xyw(9, 25, 4), colSpec, orientation)); builder.add(GuiUtil.getPreferredSizeComponent(resume), FormLayoutUtil.flip(cc.xy(1, 27), colSpec, orientation)); builder.add(GuiUtil.getPreferredSizeComponent(isShowFolderRecentlyPlayed), FormLayoutUtil.flip(cc.xyw(9, 27, 4), colSpec, orientation)); builder.addLabel(Messages.getString("FoldTab.72"), FormLayoutUtil.flip(cc.xy(1, 29), colSpec, orientation)); builder.add(fullyPlayedAction, FormLayoutUtil.flip(cc.xyw(4, 29, 3), colSpec, orientation)); builder.add(fullyPlayedOutputDirectory, FormLayoutUtil.flip(cc.xyw(9, 29, 2), colSpec, orientation)); builder.add(selectFullyPlayedOutputDirectory, FormLayoutUtil.flip(cc.xyw(11, 29, 2), colSpec, orientation)); builder.add(sharedPanel, FormLayoutUtil.flip(cc.xyw(1, 31, 12), colSpec, orientation)); } else { builder.add(sharedPanel, FormLayoutUtil.flip(cc.xyw(1, 1, 12), colSpec, orientation)); } builder.add(sharedPanel, FormLayoutUtil.flip(cc.xyw(1, 31, 12), colSpec, orientation)); JPanel panel = builder.getPanel(); // Apply the orientation to the panel and all components in it panel.applyComponentOrientation(orientation); JScrollPane scrollPane = new JScrollPane(panel, JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED, JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED); scrollPane.setBorder(BorderFactory.createEmptyBorder()); return scrollPane; }
From source file:io.github.jeremgamer.editor.ManagerFrame.java
public ManagerFrame(String projectName, final JFrame parent) { dialog = this; ArrayList<BufferedImage> icons = new ArrayList<BufferedImage>(); try {/* www . j a v a 2 s .c o m*/ icons.add(ImageIO.read(ImageGetter.class.getResource("icon16.png"))); icons.add(ImageIO.read(ImageGetter.class.getResource("icon32.png"))); icons.add(ImageIO.read(ImageGetter.class.getResource("icon64.png"))); icons.add(ImageIO.read(ImageGetter.class.getResource("icon128.png"))); } catch (IOException e1) { e1.printStackTrace(); } this.setIconImages((List<? extends Image>) icons); this.setTitle("Grer les projets"); this.setSize(300, 200); this.setModal(true); this.setLocationRelativeTo(parent); this.setResizable(false); final JScrollPane scroll = new JScrollPane(content); scroll.getVerticalScrollBar().setUnitIncrement(Editor.SCROLL_SPEED); content.setBorder(BorderFactory.createTitledBorder("")); content.setLayout(new BoxLayout(content, BoxLayout.PAGE_AXIS)); for (File project : new File("projects").listFiles()) { if (project.getName().equals(Editor.getProjectName())) { content.add(new ProjectPanel(project.getName(), true, parent, this)); } else { content.add(new ProjectPanel(project.getName(), false, parent, this)); } } try { final JButton add = new JButton("Crer un nouveau projet", new ImageIcon(ImageIO.read(ImageGetter.class.getResource("add.png")))); newProjectPanel.add(newProjectName); newProjectPanel.add(validate); this.setLayout(new BorderLayout()); scroll.setBorder(null); this.add(scroll, BorderLayout.CENTER); this.add(add, BorderLayout.SOUTH); add.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent event) { validate.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { dispose(); parent.dispose(); new Thread(new Runnable() { public void run() { window.getContentPane() .add(new JLabel("", new ImageIcon(ImageGetter.class.getResource("splash.gif")), SwingConstants.CENTER)); window.setBackground(new Color(0, 0, 0, 0)); window.setSize(300, 300); window.setLocationRelativeTo(null); window.setVisible(true); } }).start(); new Thread(new Runnable() { public void run() { new Editor(newProjectName.getText()); window.setVisible(false); } }).start(); } }); CaretListener caretUpdate = new CaretListener() { public void caretUpdate(javax.swing.event.CaretEvent e) { JTextField text = (JTextField) e.getSource(); for (File dir : new File("projects").listFiles()) { if (dir.isDirectory() && text.getText().equals(dir.getName())) { validate.setEnabled(false); validate.setText("Existe dj"); break; } else { validate.setEnabled(true); validate.setText("Crer!"); } } } }; JButton cancel = null; try { cancel = new JButton( new ImageIcon(ImageIO.read(ImageGetter.class.getResource("cancel.png")))); } catch (IOException e1) { e1.printStackTrace(); } newProjectName.addCaretListener(caretUpdate); remove(add); addPanel.setLayout(new BorderLayout()); addPanel.add(newProjectPanel, BorderLayout.CENTER); addPanel.add(cancel, BorderLayout.EAST); add(addPanel, BorderLayout.SOUTH); revalidate(); repaint(); cancel.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent event) { newProjectName.setText(""); remove(addPanel); add(add, BorderLayout.SOUTH); revalidate(); repaint(); } }); newProjectName.requestFocusInWindow(); newProjectName.requestFocus(); } }); this.setVisible(true); } catch (IOException e) { e.printStackTrace(); } }
From source file:com.jug.MotherMachine.java
/** * Created and shows the console window and redirects System.out and * System.err to it.// w ww .j a va2 s . c o m */ private void initConsoleWindow() { frameConsoleWindow = new JFrame("MotherMachine Console Window"); // frameConsoleWindow.setResizable( false ); consoleWindowTextArea = new JTextArea(); final int centerX = (int) Toolkit.getDefaultToolkit().getScreenSize().getWidth() / 2; final int centerY = (int) Toolkit.getDefaultToolkit().getScreenSize().getHeight() / 2; frameConsoleWindow.setBounds(centerX - GUI_CONSOLE_WIDTH / 2, centerY - GUI_HEIGHT / 2, GUI_CONSOLE_WIDTH, GUI_HEIGHT); final JScrollPane scrollPane = new JScrollPane(consoleWindowTextArea); scrollPane.setBorder(BorderFactory.createEmptyBorder(0, 15, 0, 0)); frameConsoleWindow.getContentPane().add(scrollPane); final OutputStream out = new OutputStream() { private final PrintStream original = new PrintStream(System.out); @Override public void write(final int b) throws IOException { updateConsoleTextArea(String.valueOf((char) b)); original.print(String.valueOf((char) b)); } @Override public void write(final byte[] b, final int off, final int len) throws IOException { updateConsoleTextArea(new String(b, off, len)); original.print(new String(b, off, len)); } @Override public void write(final byte[] b) throws IOException { write(b, 0, b.length); } }; final OutputStream err = new OutputStream() { private final PrintStream original = new PrintStream(System.out); @Override public void write(final int b) throws IOException { updateConsoleTextArea(String.valueOf((char) b)); original.print(String.valueOf((char) b)); } @Override public void write(final byte[] b, final int off, final int len) throws IOException { updateConsoleTextArea(new String(b, off, len)); original.print(new String(b, off, len)); } @Override public void write(final byte[] b) throws IOException { write(b, 0, b.length); } }; System.setOut(new PrintStream(out, true)); System.setErr(new PrintStream(err, true)); }
From source file:com.rapidminer.gui.properties.RegexpPropertyDialog.java
public RegexpPropertyDialog(final Collection<String> items, String predefinedRegexp, String description) { super(ApplicationFrame.getApplicationFrame(), "parameter.regexp", ModalityType.APPLICATION_MODAL, new Object[] {}); this.items = items; this.supportsItems = items != null; this.infoText = "<html>" + I18N.getMessage(I18N.getGUIBundle(), getKey() + ".title") + ": <br/>" + description + "</html>"; Dimension size = new Dimension(420, 500); this.setMinimumSize(size); this.setPreferredSize(size); JPanel panel = new JPanel(createGridLayout(1, supportsItems ? 2 : 1)); // create regexp text field regexpTextField = new JTextField(predefinedRegexp); regexpTextField.setToolTipText(/* www. j a v a 2s . c o m*/ I18N.getMessage(I18N.getGUIBundle(), "gui.dialog.parameter.regexp.regular_expression.tip")); regexpTextField.addKeyListener(new KeyListener() { @Override public void keyPressed(KeyEvent e) { } @Override public void keyReleased(KeyEvent e) { fireRegularExpressionUpdated(); } @Override public void keyTyped(KeyEvent e) { } }); regexpTextField.requestFocus(); // create replacement text field replacementTextField = new JTextField(); replacementTextField.setToolTipText( I18N.getMessage(I18N.getGUIBundle(), "gui.dialog.parameter.regexp.replacement.tip")); replacementTextField.addKeyListener(new KeyListener() { @Override public void keyPressed(KeyEvent e) { } @Override public void keyReleased(KeyEvent e) { fireRegularExpressionUpdated(); } @Override public void keyTyped(KeyEvent e) { } }); // create inline search documents inlineSearchDocument = new RegexpSearchStyledDocument(); inlineReplaceDocument = new RegexpReplaceStyledDocument(); // create search results list DefaultListCellRenderer resultCellRenderer = new DefaultListCellRenderer() { private static final long serialVersionUID = 1L; @Override public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) { super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus); setBackground(list.getBackground()); setForeground(list.getForeground()); setBorder(getNoFocusBorder()); return this; } private Border getNoFocusBorder() { Border border = BorderFactory.createMatteBorder(0, 0, 1, 0, Color.gray); return border; } }; JList<RegExpResult> regexpFindingsList = new JList<RegExpResult>(resultsListModel); regexpFindingsList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); regexpFindingsList.setLayoutOrientation(JList.VERTICAL); regexpFindingsList.setCellRenderer(resultCellRenderer); // regexp panel on left side of dialog JPanel regexpPanel = new JPanel(new GridBagLayout()); regexpPanel.setBorder(createTitledBorder( I18N.getMessage(I18N.getGUIBundle(), "gui.dialog.parameter.regexp.regular_expression.border"))); GridBagConstraints c = new GridBagConstraints(); c.insets = new Insets(4, 4, 4, 0); c.gridx = 0; c.gridy = 0; c.weightx = 1; c.fill = GridBagConstraints.BOTH; regexpPanel.add(regexpTextField, c); // make shortcut button final Action nullAction = new DefaultAction(); PlainArrowDropDownButton autoWireDropDownButton = PlainArrowDropDownButton.makeDropDownButton(nullAction); for (String[] popupItem : (String[][]) ArrayUtils.addAll(regexpConstructs, regexpShortcuts)) { String shortcut = popupItem[0].length() > 14 ? popupItem[0].substring(0, 14) + "..." : popupItem[0]; autoWireDropDownButton .add(new InsertionAction("<html><table border=0 cellpadding=0 cellspacing=0><tr><td width=100>" + shortcut + "</td><td>" + popupItem[1] + "</td></tr></table></html>", popupItem[0])); } c.insets = new Insets(4, 0, 4, 0); c.gridx = 1; c.weightx = 0; c.fill = GridBagConstraints.HORIZONTAL; regexpPanel.add(autoWireDropDownButton.getDropDownArrowButton(), c); // make delete button c.insets = new Insets(4, 0, 4, 4); c.gridx = 2; c.weightx = 0; c.fill = GridBagConstraints.HORIZONTAL; JButton clearRegexpTextFieldButton = new JButton(SwingTools.createIcon("16/delete2.png")); clearRegexpTextFieldButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { regexpTextField.setText(""); fireRegularExpressionUpdated(); regexpTextField.requestFocusInWindow(); } }); regexpPanel.add(clearRegexpTextFieldButton, c); errorMessage = new JLabel(NO_ERROR_MESSAGE, NO_ERROR_ICON, SwingConstants.LEFT); errorMessage.setFocusable(false); c.insets = new Insets(4, 8, 4, 4); c.gridx = 0; c.gridy = 1; c.weightx = 0; c.weighty = 0; c.gridwidth = GridBagConstraints.REMAINDER; regexpPanel.add(errorMessage, c); // create replacement panel JPanel replacementPanel = new JPanel(new GridBagLayout()); replacementPanel.setBorder(createTitledBorder( I18N.getMessage(I18N.getGUIBundle(), "gui.dialog.parameter.regexp.replacement.border"))); JPanel testerPanel = new JPanel(new GridBagLayout()); c.insets = new Insets(4, 4, 4, 0); c.gridx = 0; c.gridy = 0; c.weightx = 1; c.fill = GridBagConstraints.HORIZONTAL; replacementPanel.add(replacementTextField, c); // create inline search panel JPanel inlineSearchPanel = new JPanel(new GridBagLayout()); c.insets = new Insets(8, 4, 4, 4); c.gridx = 0; c.gridy = 0; c.weightx = 1; c.weighty = 0; c.fill = GridBagConstraints.HORIZONTAL; inlineSearchPanel.add( new JLabel( I18N.getMessage(I18N.getGUIBundle(), "gui.dialog.parameter.regexp.inline_search.search")), c); c.insets = new Insets(0, 0, 0, 0); c.gridx = 0; c.gridy = 1; c.weightx = 1; c.weighty = 1; c.fill = GridBagConstraints.BOTH; inlineSearchPanel.add(new JScrollPane(new JTextPane(inlineSearchDocument)), c); c.insets = new Insets(8, 4, 4, 4); c.gridx = 0; c.gridy = 2; c.weightx = 1; c.weighty = 0; c.fill = GridBagConstraints.HORIZONTAL; inlineSearchPanel.add( new JLabel( I18N.getMessage(I18N.getGUIBundle(), "gui.dialog.parameter.regexp.inline_search.replaced")), c); c.insets = new Insets(0, 0, 0, 0); c.gridx = 0; c.gridy = 3; c.weightx = 1; c.weighty = 1; c.fill = GridBagConstraints.BOTH; JTextPane replaceTextPane = new JTextPane(inlineReplaceDocument); replaceTextPane.setEditable(false); inlineSearchPanel.add(new JScrollPane(replaceTextPane), c); // create regexp options panel ItemListener defaultOptionListener = new ItemListener() { @Override public void itemStateChanged(ItemEvent e) { fireRegexpOptionsChanged(); } }; cbCaseInsensitive = new JCheckBox(I18N.getMessage(I18N.getGUIBundle(), "gui.dialog.parameter.regexp.regular_expression.regexp_options.case_insensitive")); cbCaseInsensitive.setToolTipText(I18N.getMessage(I18N.getGUIBundle(), "gui.dialog.parameter.regexp.regular_expression.regexp_options.case_insensitive.tip")); cbCaseInsensitive.addItemListener(defaultOptionListener); cbMultiline = new JCheckBox(I18N.getMessage(I18N.getGUIBundle(), "gui.dialog.parameter.regexp.regular_expression.regexp_options.multiline_mode")); cbMultiline.setToolTipText(I18N.getMessage(I18N.getGUIBundle(), "gui.dialog.parameter.regexp.regular_expression.regexp_options.multiline_mode.tip")); cbMultiline.addItemListener(defaultOptionListener); cbDotall = new JCheckBox(I18N.getMessage(I18N.getGUIBundle(), "gui.dialog.parameter.regexp.regular_expression.regexp_options.dotall_mode")); cbDotall.setToolTipText(I18N.getMessage(I18N.getGUIBundle(), "gui.dialog.parameter.regexp.regular_expression.regexp_options.dotall_mode.tip")); cbDotall.addItemListener(defaultOptionListener); cbUnicodeCase = new JCheckBox(I18N.getMessage(I18N.getGUIBundle(), "gui.dialog.parameter.regexp.regular_expression.regexp_options.unicode_case")); cbUnicodeCase.setToolTipText(I18N.getMessage(I18N.getGUIBundle(), "gui.dialog.parameter.regexp.regular_expression.regexp_options.unicode_case.tip")); cbUnicodeCase.addItemListener(defaultOptionListener); JPanel regexpOptionsPanelWrapper = new JPanel(new BorderLayout()); JPanel regexpOptionsPanel = new JPanel(new GridBagLayout()); regexpOptionsPanelWrapper.add(regexpOptionsPanel, BorderLayout.NORTH); c.insets = new Insets(12, 4, 0, 4); c.gridx = 0; c.gridy = 0; c.weightx = 1; c.weighty = 0; c.fill = GridBagConstraints.HORIZONTAL; regexpOptionsPanel.add(cbMultiline, c); c.insets = new Insets(8, 4, 0, 4); c.gridy = 1; regexpOptionsPanel.add(cbCaseInsensitive, c); c.gridy = 2; regexpOptionsPanel.add(cbUnicodeCase, c); c.gridy = 3; regexpOptionsPanel.add(cbDotall, c); // create tabbed panel c.insets = new Insets(8, 4, 4, 4); c.gridx = 0; c.gridy = 0; c.weightx = 1; c.weighty = 1; c.gridwidth = GridBagConstraints.REMAINDER; c.fill = GridBagConstraints.BOTH; testExp = new JTabbedPane(); testExp.add( I18N.getMessage(I18N.getGUIBundle(), "gui.dialog.parameter.regexp.regular_expression.inline_search.title"), new JScrollPane(inlineSearchPanel)); testExp.add( I18N.getMessage(I18N.getGUIBundle(), "gui.dialog.parameter.regexp.regular_expression.result_list.title"), new JScrollPane(regexpFindingsList)); testExp.add( I18N.getMessage(I18N.getGUIBundle(), "gui.dialog.parameter.regexp.regular_expression.regexp_options.title"), regexpOptionsPanelWrapper); testerPanel.add(testExp, c); JPanel groupPanel = new JPanel(new GridBagLayout()); c.insets = new Insets(4, 4, 4, 4); c.gridx = 0; c.gridy = 0; c.weightx = 1; c.weighty = 0; c.fill = GridBagConstraints.HORIZONTAL; groupPanel.add(regexpPanel, c); c.insets = new Insets(4, 4, 4, 4); c.gridx = 0; c.gridy = 1; c.weightx = 1; c.weighty = 0; c.fill = GridBagConstraints.HORIZONTAL; groupPanel.add(replacementPanel, c); c.insets = new Insets(4, 4, 4, 4); c.gridx = 0; c.gridy = 2; c.weightx = 1; c.weighty = 1; c.fill = GridBagConstraints.BOTH; groupPanel.add(testerPanel, c); panel.add(groupPanel, 1, 0); if (supportsItems) { // item shortcuts list itemShortcutsList = new JList<String>(items.toArray(new String[items.size()])); itemShortcutsList.setToolTipText( I18N.getMessage(I18N.getGUIBundle(), "gui.dialog.parameter.regexp.item_shortcuts.tip")); itemShortcutsList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); itemShortcutsList.addMouseListener(new MouseListener() { @Override public void mouseClicked(MouseEvent e) { if (e.getClickCount() == 2) { String text = regexpTextField.getText(); int cursorPosition = regexpTextField.getCaretPosition(); int index = itemShortcutsList.getSelectedIndex(); if (index > -1 && index < itemShortcutsList.getModel().getSize()) { String insertionString = itemShortcutsList.getModel().getElementAt(index).toString(); String newText = text.substring(0, cursorPosition) + insertionString + (cursorPosition < text.length() ? text.substring(cursorPosition) : ""); regexpTextField.setText(newText); regexpTextField.setCaretPosition(cursorPosition + insertionString.length()); regexpTextField.requestFocus(); fireRegularExpressionUpdated(); } } } @Override public void mouseEntered(MouseEvent e) { } @Override public void mouseExited(MouseEvent e) { } @Override public void mousePressed(MouseEvent e) { } @Override public void mouseReleased(MouseEvent e) { } }); JScrollPane itemShortcutsPane = new JScrollPane(itemShortcutsList); itemShortcutsPane.setBorder(createTitledBorder( I18N.getMessage(I18N.getGUIBundle(), "gui.dialog.parameter.regexp.item_shortcuts.border"))); // matched items list matchedItemsListModel = new DefaultListModel<String>(); JList<String> matchedItemsList = new JList<String>(matchedItemsListModel); matchedItemsList.setToolTipText( I18N.getMessage(I18N.getGUIBundle(), "gui.dialog.parameter.regexp.matched_items.tip")); // add custom cell renderer to disallow selections matchedItemsList.setCellRenderer(new DefaultListCellRenderer() { private static final long serialVersionUID = -5795848004756768378L; @Override public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) { return super.getListCellRendererComponent(list, value, index, false, false); } }); JScrollPane matchedItemsPanel = new JScrollPane(matchedItemsList); matchedItemsPanel.setBorder(createTitledBorder( I18N.getMessage(I18N.getGUIBundle(), "gui.dialog.parameter.regexp.matched_items.border"))); // item panel on right side of dialog JPanel itemPanel = new JPanel(createGridLayout(1, 2)); itemPanel.add(itemShortcutsPane, 0, 0); itemPanel.add(matchedItemsPanel, 0, 1); panel.add(itemPanel, 0, 1); } okButton = makeOkButton("regexp_property_dialog_apply"); fireRegularExpressionUpdated(); layoutDefault(panel, supportsItems ? NORMAL : NARROW, okButton, makeCancelButton()); }
From source file:edu.ku.brc.stats.StatGroupTable.java
/** * Constructor with the localized name of the Group * @param name name of the group (already been localized) * @param useSeparator use non-border separator titles *//*from www . ja v a 2 s . com*/ public StatGroupTable(final String name, final String[] columnNames, final boolean useSeparator, final int numRows) { this.name = name; this.useSeparator = useSeparator; this.skinItem = SkinsMgr.getSkinItem("StatGroup"); if (progressIcon == null) { progressIcon = IconManager.getIcon("Progress", IconManager.IconSize.Std16); } setLayout(new BorderLayout()); setBackground(Color.WHITE); model = new StatGroupTableModel(this, columnNames); //table = numRows > SCROLLPANE_THRESOLD ? (new SortableJTable(new SortableTableModel(model))) : (new JTable(model)); if (numRows > SCROLLPANE_THRESOLD) { table = new SortableJTable(new SortableTableModel(model)) { protected void configureEnclosingScrollPane() { Container p = getParent(); if (p instanceof JViewport) { Container gp = p.getParent(); if (gp instanceof JScrollPane) { JScrollPane scrollPane = (JScrollPane) gp; // Make certain we are the viewPort's view and not, for // example, the rowHeaderView of the scrollPane - // an implementor of fixed columns might do this. JViewport viewport = scrollPane.getViewport(); if (viewport == null || viewport.getView() != this) { return; } // scrollPane.setColumnHeaderView(getTableHeader()); //scrollPane.getViewport().setBackingStoreEnabled(true); scrollPane.setBorder(UIManager.getBorder("Table.scrollPaneBorder")); } } } }; } else { table = new JTable(model) { protected void configureEnclosingScrollPane() { Container p = getParent(); if (p instanceof JViewport) { Container gp = p.getParent(); if (gp instanceof JScrollPane) { JScrollPane scrollPane = (JScrollPane) gp; // Make certain we are the viewPort's view and not, for // example, the rowHeaderView of the scrollPane - // an implementor of fixed columns might do this. JViewport viewport = scrollPane.getViewport(); if (viewport == null || viewport.getView() != this) { return; } // scrollPane.setColumnHeaderView(getTableHeader()); //scrollPane.getViewport().setBackingStoreEnabled(true); scrollPane.setBorder(UIManager.getBorder("Table.scrollPaneBorder")); } } } }; } table.setShowVerticalLines(false); table.setShowHorizontalLines(false); if (SkinsMgr.shouldBeOpaque(skinItem)) { table.setOpaque(false); setOpaque(false); } else { table.setOpaque(true); setOpaque(true); } table.addMouseMotionListener(new TableMouseMotion()); table.addMouseListener(new LinkListener()); if (table.getColumnModel().getColumnCount() == 1) { table.getColumnModel().getColumn(0) .setCellRenderer(new StatGroupTableCellRenderer(SwingConstants.CENTER, 1)); } else { table.getColumnModel().getColumn(0) .setCellRenderer(new StatGroupTableCellRenderer(SwingConstants.LEFT, 2)); table.getColumnModel().getColumn(1) .setCellRenderer(new StatGroupTableCellRenderer(SwingConstants.RIGHT, 2)); } //table.setRowSelectionAllowed(true); if (numRows > SCROLLPANE_THRESOLD) { scrollPane = new JScrollPane(table, ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER); if (table instanceof SortableJTable) { ((SortableJTable) table).installColumnHeaderListeners(); } scrollPane.setOpaque(false); scrollPane.getViewport().setOpaque(false); scrollPane.setBorder(BorderFactory.createEmptyBorder()); //scrollPane.getViewport().setBorder(BorderFactory.createEmptyBorder()); } if (useSeparator) { setBorder(BorderFactory.createEmptyBorder(2, 2, 2, 2)); CellConstraints cc = new CellConstraints(); if (StringUtils.isNotEmpty(name)) { builder.addSeparator(name, cc.xy(1, 1)); } builder.add(scrollPane != null ? scrollPane : table, cc.xy(1, 2)); builder.getPanel().setOpaque(false); add(builder.getPanel()); } else { setBorder(BorderFactory.createEmptyBorder(15, 2, 2, 2)); setBorder(BorderFactory.createCompoundBorder(new CurvedBorder(new Color(160, 160, 160)), getBorder())); add(scrollPane != null ? scrollPane : table, BorderLayout.CENTER); } }