List of usage examples for javax.swing BorderFactory createLineBorder
public static Border createLineBorder(Color color)
From source file:org.pmedv.jake.app.PlayerView.java
private JPanel createTopPanel() { JPanel buttonPanel = new JPanel(new FlowLayout(FlowLayout.LEFT)); buttonPanel.setBackground(Colors.LIGHT_GRAY); ImageIcon playIcon = resources.getIcon("icon.play"); ImageIcon stopIcon = resources.getIcon("icon.stop"); ImageIcon nextIcon = resources.getIcon("icon.next"); ImageIcon prevIcon = resources.getIcon("icon.last"); prevButton = new CmdJButton(prevIcon, "Plays the previous song", null); nextButton = new CmdJButton(nextIcon, "Plays the next song", null); startButton = new CmdJButton(playIcon, "Starts playing", null); stopButton = new CmdJButton(stopIcon, "Stops playing", null); buttonPanel.add(startButton);//from ww w . java 2s .c o m buttonPanel.add(stopButton); buttonPanel.add(prevButton); buttonPanel.add(nextButton); buttonPanel.setBorder(new CompoundBorder(BorderFactory.createEmptyBorder(0, 0, 0, 0), BorderFactory.createLineBorder(Color.LIGHT_GRAY))); timeField = new JTextField(5); timeField.setEditable(false); timeField.setBackground(Colors.SOFT_BLUE_ICE); titleField = new JMarqueeTextField(30); titleField.setEditable(false); titleField.setBackground(Colors.SOFT_BLUE_ICE); buttonPanel.add(timeField); buttonPanel.add(titleField); randomBox = new JCheckBox("R"); buttonPanel.add(randomBox); return buttonPanel; }
From source file:eu.cassandra.csn.gui.CSN.java
/** * /*from w w w . ja v a 2 s . c o m*/ * @param graph * @return */ public static JPanel setUpView() { JPanel csnPanel = new JPanel(); vv.getGraphLayout().setSize(new Dimension(csnPanel.getWidth(), csnPanel.getHeight())); setUpVV(); GraphZoomScrollPane graphZoomScrollPane = new GraphZoomScrollPane(vv); JPanel thisPanel = new JPanel(new BorderLayout()); thisPanel.add(graphZoomScrollPane, BorderLayout.CENTER); slider.setBackground(Color.WHITE); slider.setPreferredSize(new Dimension(210, 50)); slider.setPaintTicks(true); slider.setMaximum(100); slider.setMinimum(0); slider.setValue(0); slider.setMajorTickSpacing(50); slider.setPaintLabels(true); slider.setPaintTicks(true); slider.setBorder(BorderFactory.createLineBorder(Color.black)); slider.setEnabled(false); sliderLabel.setEnabled(false); slider.addMouseListener(new MouseListener() { @Override public void mouseReleased(MouseEvent e) { if (sliderLabel.getText().contains("oltage")) ClusterGraph.clusterAndRecolor(ClusterGraph.VoltageClusterer, slider.getValue()); else if (sliderLabel.getText().contains("etweenness")) ClusterGraph.clusterAndRecolor(ClusterGraph.BetweennessClusterer, slider.getValue()); } public void mouseClicked(MouseEvent arg0) { } public void mouseEntered(MouseEvent arg0) { } public void mouseExited(MouseEvent arg0) { } public void mousePressed(MouseEvent arg0) { } }); JPanel p = new JPanel(new BorderLayout()); p.add(sliderLabel, BorderLayout.PAGE_START); p.add(slider, BorderLayout.CENTER); sliderEdge.setBackground(Color.WHITE); sliderEdge.setPreferredSize(new Dimension(210, 50)); sliderEdge.setPaintTicks(true); sliderEdge.setValue(0); sliderEdge.setMajorTickSpacing(5); sliderEdge.setPaintLabels(true); sliderEdge.setPaintTicks(true); sliderEdge.setBorder(BorderFactory.createLineBorder(Color.black)); sliderEdge.setEnabled(false); sliderLabelEdge.setEnabled(false); sliderEdge.addMouseListener(new MouseListener() { @Override public void mouseReleased(MouseEvent e) { double v = Double .parseDouble(((JLabel) sliderEdge.getLabelTable().get(sliderEdge.getValue())).getText()); CSNGraph.addEdgesBasedOnKL(v); } public void mouseClicked(MouseEvent arg0) { } public void mouseEntered(MouseEvent arg0) { } public void mouseExited(MouseEvent arg0) { } public void mousePressed(MouseEvent arg0) { } }); JPanel pEdge = new JPanel(new BorderLayout()); pEdge.add(sliderLabelEdge, BorderLayout.PAGE_START); pEdge.add(sliderEdge, BorderLayout.CENTER); JPanel p2 = new JPanel(new BorderLayout()); p2.add(pEdge, BorderLayout.PAGE_START); p2.add(p, BorderLayout.PAGE_END); thisPanel.add(p2, BorderLayout.PAGE_END); return thisPanel; }
From source file:SimpleDateFormatDemo.java
public SimpleDateFormatDemo() { today = new Date(); availableLocales = new LocaleGroup(); String[] patternExamples = { "dd MMMMM yyyy", "dd.MM.yy", "MM/dd/yy", "yyyy.MM.dd G 'at' hh:mm:ss z", "EEE, MMM d, ''yy", "h:mm a", "H:mm:ss:SSS", "K:mm a,z", "yyyy.MMMMM.dd GGG hh:mm aaa" }; currentPattern = patternExamples[0]; // Set up the UI for selecting a pattern. JLabel patternLabel1 = new JLabel("Enter the pattern string or"); JLabel patternLabel2 = new JLabel("select one from the list:"); patternLabel1.setAlignmentX(Component.LEFT_ALIGNMENT); patternLabel2.setAlignmentX(Component.LEFT_ALIGNMENT); JComboBox patternList = new JComboBox(patternExamples); patternList.setSelectedIndex(0);/*w ww . j a va 2 s.c om*/ patternList.setEditable(true); patternList.setAlignmentX(Component.LEFT_ALIGNMENT); PatternListener patternListener = new PatternListener(); patternList.addActionListener(patternListener); // Set up the UI for selecting a locale. JLabel localeLabel = new JLabel("Select a Locale from the list:"); localeLabel.setAlignmentX(Component.LEFT_ALIGNMENT); JComboBox localeList = new JComboBox(availableLocales.getStrings()); localeList.setSelectedIndex(0); localeList.setAlignmentX(Component.LEFT_ALIGNMENT); LocaleListener localeListener = new LocaleListener(); localeList.addActionListener(localeListener); // Create the UI for displaying result JLabel resultLabel = new JLabel("Current Date and Time", JLabel.LEFT); resultLabel.setAlignmentX(Component.LEFT_ALIGNMENT); result = new JLabel(" "); result.setForeground(Color.black); result.setAlignmentX(Component.LEFT_ALIGNMENT); result.setBorder(BorderFactory.createCompoundBorder(BorderFactory.createLineBorder(Color.black), BorderFactory.createEmptyBorder(5, 5, 5, 5))); // Lay out everything JPanel patternPanel = new JPanel(); patternPanel.setLayout(new BoxLayout(patternPanel, BoxLayout.Y_AXIS)); patternPanel.add(patternLabel1); patternPanel.add(patternLabel2); patternPanel.add(patternList); JPanel localePanel = new JPanel(); localePanel.setLayout(new BoxLayout(localePanel, BoxLayout.Y_AXIS)); localePanel.add(localeLabel); localePanel.add(localeList); JPanel resultPanel = new JPanel(); resultPanel.setLayout(new GridLayout(0, 1)); resultPanel.add(resultLabel); resultPanel.add(result); setLayout(new BoxLayout(this, BoxLayout.Y_AXIS)); patternPanel.setAlignmentX(Component.CENTER_ALIGNMENT); localePanel.setAlignmentX(Component.CENTER_ALIGNMENT); resultPanel.setAlignmentX(Component.CENTER_ALIGNMENT); add(patternPanel); add(Box.createVerticalStrut(10)); add(localePanel); add(Box.createVerticalStrut(10)); add(resultPanel); setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10)); reformat(); }
From source file:org.encog.workbench.tabs.visualize.scatter.ScatterPlotTab.java
private JPanel createPanel(int xIndex, int yIndex, boolean legend) { XYDataset dataset = new ScatterXY(file, xIndex, yIndex); JFreeChart chart = ChartFactory.createScatterPlot(null, null, null, dataset, PlotOrientation.VERTICAL, legend, true, false);//from www .j a va 2 s . co m XYPlot plot = (XYPlot) chart.getPlot(); XYDotRenderer renderer = new XYDotRenderer(); renderer.setDotWidth(4); renderer.setDotHeight(4); if (this.file.isRegression()) { int per = 255 / 10; int r = 0; int b = 255; for (int i = 0; i < file.getSeriesCount(); i++) { renderer.setSeriesPaint(i, new Color(r, 0, b)); r += per; b -= per; } } else { for (int i = 0; i < file.getSeriesCount(); i++) { renderer.setSeriesPaint(i, COLORS[i % COLORS.length]); } } plot.setRenderer(renderer); plot.setDomainCrosshairVisible(true); plot.setRangeCrosshairVisible(true); NumberAxis domainAxis = (NumberAxis) plot.getDomainAxis(); domainAxis.setAutoRangeIncludesZero(false); plot.getRangeAxis().setInverted(false); ChartPanel result = new ChartPanel(chart); result.setBorder(BorderFactory.createLineBorder(Color.black)); // we need one to draw the legend off of if (this.samplePlot == null) this.samplePlot = plot; //chart.removeLegend(); return result; }
From source file:com.okmich.hackerday.client.tool.dashboard.ReportItemPanel.java
public void onMouseEnter() { setBorder(BorderFactory.createLineBorder(Color.YELLOW)); }
From source file:org.cds06.speleograph.graph.GraphEditor.java
/** * Creates a modal dialog by specifying the attached {@link GraphPanel}. * <p>Please look at {@link javax.swing.JDialog#JDialog()} to see defaults params applied to this Dialog.</p> *//*from w ww. j av a2 s. c o m*/ public GraphEditor(GraphPanel panel) { super((Frame) SwingUtilities.windowForComponent(panel), true); Validate.notNull(panel); this.graphPanel = panel; KeyStroke stroke = KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0); mainPanel.registerKeyboardAction(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { setVisible(false); } }, stroke, JComponent.WHEN_IN_FOCUSED_WINDOW); setContentPane(mainPanel); mainPanel.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5)); this.setTitle(I18nSupport.translate("menus.graph.graphEditor")); { // This section use FormLayout which is an external layout for Java, consult the doc before edit the // following lines ! final FormLayout layout = new FormLayout( "right:max(40dlu;p), 4dlu, p:grow, 4dlu, p, 4dlu, p:grow, 4dlu, p", //NON-NLS "p,4dlu,p,4dlu,p,4dlu,p,4dlu,p" //NON-NLS ); PanelBuilder builder = new PanelBuilder(layout); final JLabel colorLabel = new JLabel(); final JTextField titleForGraph = new JTextField( graphPanel.getChart().getTitle() != null ? graphPanel.getChart().getTitle().getText() : ""); final JLabel colorXYPlotLabel = new JLabel(); final JLabel colorGridLabel = new JLabel(); final JCheckBox showLegendCheckBox = new JCheckBox("Afficher la lgende", graphPanel.getChart().getLegend().isVisible()); { builder.addLabel("Titre :", "1,1"); builder.add(titleForGraph, "3,1,7,1"); } { builder.addLabel(I18nSupport.translate("menus.graph.graphEditor.backgroundColor"), "1,3"); colorLabel.setBorder(BorderFactory.createLineBorder(Color.BLACK)); colorLabel.setText(" "); colorLabel.setBackground((Color) graphPanel.getChart().getBackgroundPaint()); colorLabel.setOpaque(true); colorLabel.setEnabled(false); final JButton edit = new JButton(I18nSupport.translate("menus.graph.graphEditor.edit")); edit.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { Color c = JColorChooser.showDialog(GraphEditor.this, I18nSupport.translate("menus.graph.graphEditor.selectColor"), colorLabel.getBackground()); if (c != null) { colorLabel.setBackground(c); } } }); builder.add(colorLabel, "3,3,5,1"); builder.add(edit, "9,3"); } final XYPlot xyPlot = graphPanel.getChart().getXYPlot(); { builder.addLabel(I18nSupport.translate("menus.graph.graphEditor.graphColor"), "1,5"); colorXYPlotLabel.setText(" "); colorXYPlotLabel.setOpaque(true); colorXYPlotLabel.setBorder(BorderFactory.createLineBorder(Color.BLACK)); colorXYPlotLabel.setBackground((Color) xyPlot.getBackgroundPaint()); colorXYPlotLabel.setEnabled(false); final JButton edit = new JButton(I18nSupport.translate("menus.graph.graphEditor.edit")); edit.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { Color c = JColorChooser.showDialog(GraphEditor.this, I18nSupport.translate("menus.graph.graphEditor.selectColor"), colorXYPlotLabel.getBackground()); if (c != null) { colorXYPlotLabel.setBackground(c); } } }); builder.add(colorXYPlotLabel, "3,5,5,1"); builder.add(edit, "9,5"); } { builder.addLabel(I18nSupport.translate("menus.graph.graphEditor.gridColor"), "1,7"); colorGridLabel.setOpaque(true); colorGridLabel.setText(" "); colorGridLabel.setBorder(BorderFactory.createLineBorder(Color.BLACK)); colorGridLabel.setBackground((Color) xyPlot.getRangeGridlinePaint()); colorGridLabel.setEnabled(false); final JButton edit = new JButton(I18nSupport.translate("menus.graph.graphEditor.edit")); edit.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { Color c = JColorChooser.showDialog(GraphEditor.this, I18nSupport.translate("menus.graph.graphEditor.selectColor"), colorGridLabel.getBackground()); if (c != null) { colorGridLabel.setBackground(c); } } }); builder.add(colorGridLabel, "3,7,5,1"); builder.add(edit, "9,7"); } { builder.add(showLegendCheckBox, "1,9,9,1"); } mainPanel.add(builder.build(), BorderLayout.CENTER); ButtonBarBuilder buttonBarBuilder = new ButtonBarBuilder(); buttonBarBuilder.addGlue(); buttonBarBuilder.addButton(new AbstractAction() { { putValue(NAME, I18nSupport.translate("cancel")); } @Override public void actionPerformed(ActionEvent e) { GraphEditor.this.setVisible(false); } }); buttonBarBuilder.addButton(new AbstractAction() { { putValue(NAME, I18nSupport.translate("ok")); } @Override public void actionPerformed(ActionEvent e) { if (titleForGraph.getText().isEmpty()) graphPanel.getChart().setTitle((String) null); else graphPanel.getChart().setTitle(titleForGraph.getText()); { Color c = colorGridLabel.getBackground(); xyPlot.setRangeGridlinePaint(c); xyPlot.setRangeMinorGridlinePaint(c); xyPlot.setDomainGridlinePaint(c); xyPlot.setDomainMinorGridlinePaint(c); } graphPanel.getChart().setBackgroundPaint(colorLabel.getBackground()); xyPlot.setBackgroundPaint(colorXYPlotLabel.getBackground()); graphPanel.getChart().getLegend().setVisible(showLegendCheckBox.isSelected()); GraphEditor.this.setVisible(false); } }); mainPanel.add(buttonBarBuilder.build(), BorderLayout.SOUTH); } pack(); Dimension d = this.getPreferredSize(); this.setSize(new Dimension(d.width + 20, d.height)); setResizable(false); }
From source file:com.okmich.hackerday.client.tool.dashboard.ReportItemPanel.java
public void onMouseExit() { setBorder(BorderFactory.createLineBorder(Color.GRAY)); }
From source file:components.LayeredPaneDemo2.java
private JLabel createColoredLabel(String text, Color color) { JLabel label = new JLabel(text); label.setVerticalAlignment(JLabel.TOP); label.setHorizontalAlignment(JLabel.CENTER); label.setOpaque(true);//from www . j a v a 2 s . c o m label.setBackground(color); label.setForeground(Color.black); label.setBorder(BorderFactory.createLineBorder(Color.black)); label.setPreferredSize(new Dimension(140, 140)); return label; }
From source file:misc.AccessibleScrollDemo.java
public AccessibleScrollDemo() { // Get the image to use. ImageIcon bee = createImageIcon("images/flyingBee.jpg", "Photograph of a flying bee."); // Create the row and column headers. columnView = new Rule(Rule.HORIZONTAL, true); if (bee != null) { columnView.setPreferredWidth(bee.getIconWidth()); } else {/*from w w w . j a va 2 s . c o m*/ columnView.setPreferredWidth(320); } columnView.getAccessibleContext().setAccessibleName("Column Header"); columnView.getAccessibleContext() .setAccessibleDescription("Displays horizontal ruler for " + "measuring scroll pane client."); rowView = new Rule(Rule.VERTICAL, true); if (bee != null) { rowView.setPreferredHeight(bee.getIconHeight()); } else { rowView.setPreferredHeight(480); } rowView.getAccessibleContext().setAccessibleName("Row Header"); rowView.getAccessibleContext() .setAccessibleDescription("Displays vertical ruler for " + "measuring scroll pane client."); // Create the corners. JPanel buttonCorner = new JPanel(); isMetric = new JToggleButton("cm", true); isMetric.setFont(new Font("SansSerif", Font.PLAIN, 11)); isMetric.setMargin(new Insets(2, 2, 2, 2)); isMetric.addItemListener(this); isMetric.setToolTipText("Toggles rulers' unit of measure " + "between inches and centimeters."); buttonCorner.add(isMetric); //Use the default FlowLayout buttonCorner.getAccessibleContext().setAccessibleName("Upper Left Corner"); String desc = "Fills the corner of a scroll pane " + "with color for aesthetic reasons."; Corner lowerLeft = new Corner(); lowerLeft.getAccessibleContext().setAccessibleName("Lower Left Corner"); lowerLeft.getAccessibleContext().setAccessibleDescription(desc); Corner upperRight = new Corner(); upperRight.getAccessibleContext().setAccessibleName("Upper Right Corner"); upperRight.getAccessibleContext().setAccessibleDescription(desc); // Set up the scroll pane. picture = new ScrollablePicture(bee, columnView.getIncrement()); picture.setToolTipText(bee.getDescription()); picture.getAccessibleContext().setAccessibleName("Scroll pane client"); JScrollPane pictureScrollPane = new JScrollPane(picture); pictureScrollPane.setPreferredSize(new Dimension(300, 250)); pictureScrollPane.setViewportBorder(BorderFactory.createLineBorder(Color.black)); pictureScrollPane.setColumnHeaderView(columnView); pictureScrollPane.setRowHeaderView(rowView); // In theory, to support internationalization you would change // UPPER_LEFT_CORNER to UPPER_LEADING_CORNER, // LOWER_LEFT_CORNER to LOWER_LEADING_CORNER, and // UPPER_RIGHT_CORNER to UPPER_TRAILING_CORNER. In practice, // bug #4467063 makes that impossible (at least in 1.4.0). pictureScrollPane.setCorner(JScrollPane.UPPER_LEFT_CORNER, buttonCorner); pictureScrollPane.setCorner(JScrollPane.LOWER_LEFT_CORNER, lowerLeft); pictureScrollPane.setCorner(JScrollPane.UPPER_RIGHT_CORNER, upperRight); // Put it in this panel. setLayout(new BoxLayout(this, BoxLayout.X_AXIS)); add(pictureScrollPane); setBorder(BorderFactory.createEmptyBorder(20, 20, 20, 20)); }
From source file:uk.nhs.cfh.dsp.srth.desktop.modules.querycreationtreepanel.renderer.ReportingQueryStatementTreeCellRenderer.java
public Component getTreeCellRendererComponent(JTree tree, Object value, boolean selected, boolean expanded, boolean leaf, int row, boolean hasFocus) { final JLabel label = new JLabel(); if (value instanceof QueryExpression) { QueryExpression expression = (QueryExpression) value; if (expression instanceof QueryStatement) { label.setText("Get patients who have"); } else if (expression instanceof QueryIntersectionExpression) { QueryIntersectionExpression intersectionObject = (QueryIntersectionExpression) expression; QueryExpression.QueryOperatorType operatorType = intersectionObject.getOperator(); if (operatorType != QueryExpression.QueryOperatorType.AND) { label.setText("ALL of the following (" + operatorType.toString() + ")"); } else { label.setText("ALL of the following"); }/*from www .j ava 2 s . c o m*/ } else if (expression instanceof QueryUnionExpression) { label.setText("ANY of the following"); } else if (expression instanceof QueryComponentExpression) { QueryComponentExpression componentExpression = (QueryComponentExpression) value; TerminologyConstraint includedConstraint = componentExpression.getIncludedConstraint(); if (includedConstraint != null) { String text = humanReadableRender .getHumanReadableLabel((CloseToUserExpression) includedConstraint.getExpression()); label.setText(text); } final Collection<TerminologyConstraint> excludedTerms = componentExpression .getExcludedConstraints(); if (excludedTerms.size() > 0) { label.setIcon(icon); } SwingUtilities.updateComponentTreeUI(label); } // set label text color based on run time status setFontColor(expression, label); } if (hasFocus) { Color lineColor = UIManager.getColor("Tree.selectionBorderColor"); label.setBorder(BorderFactory.createLineBorder(lineColor)); label.setBackground(UIManager.getColor("Tree.selectionBackground")); } else { label.setBorder(BorderFactory.createEmptyBorder(1, 1, 1, 1)); label.setBackground(UIManager.getColor("Tree.background")); } return label; }