List of usage examples for javax.swing BorderFactory createLineBorder
public static Border createLineBorder(Color color)
From source file:AccessibleScrollDemo.java
public AccessibleScrollDemo() { //Load the photograph into an image icon. ImageIcon david = new ImageIcon("images/youngdad.jpeg"); david.setDescription("Photograph of David McNabb in his youth."); //Create the row and column headers columnView = new Rule(Rule.HORIZONTAL, true); columnView.setPreferredWidth(david.getIconWidth()); columnView.getAccessibleContext().setAccessibleName("Column Header"); columnView.getAccessibleContext()//from ww w. j av a2 s .c o m .setAccessibleDescription("Displays horizontal ruler for " + "measuring scroll pane client."); rowView = new Rule(Rule.VERTICAL, true); rowView.setPreferredHeight(david.getIconHeight()); 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(new UnitsListener()); 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(david, columnView.getIncrement()); picture.setToolTipText(david.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); 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:org.apache.cayenne.swing.components.textpane.JCayenneTextPane.java
public JCayenneTextPane(SyntaxConstant syntaxConstant) { super();//from w w w .j ava 2 s.c o m Dimension dimention = new Dimension(15, 15); setMinimumSize(dimention); setPreferredSize(dimention); setMinimumSize(dimention); setBackground(new Color(245, 238, 238)); setBorder(null); pane = new JTextPaneScrollable(new EditorKit(syntaxConstant)) { public void paint(Graphics g) { super.paint(g); JCayenneTextPane.this.repaint(); } }; pane.setFont(SQLSyntaxConstants.DEFAULT_FONT); pane.setBorder(new LineNumberedBorder(this)); scrollPane = new JScrollPane(pane); scrollPane.setBorder(BorderFactory.createLineBorder(new Color(115, 115, 115))); this.painter = new UnderlineHighlighterForText.UnderlineHighlightPainter(Color.red); pane.getDocument().addDocumentListener(new DocumentListener() { public void insertUpdate(DocumentEvent evt) { try { String text = pane.getText(evt.getOffset(), 1).toString(); if (text.equals("/") || text.equals("*")) { removeHighlightText(); pane.repaint(); } if (text.equals(" ") || text.equals("\t") || text.equals("\n")) { pane.repaint(); } } catch (Exception e) { logObj.warn("Error: ", e); } } public void removeUpdate(DocumentEvent evt) { } public void changedUpdate(DocumentEvent evt) { } }); }
From source file:ome.formats.importer.gui.GuiCommonElements.java
/** * Add a plane sub-panel to an existing container * /*from w ww. j a v a2 s . c o m*/ * @param container - parent container * @param tableSize - TableLayout table array * @param debug - turn on/off red debug borders * @return new JPanel */ public static JPanel addPlanePanel(Container container, double tableSize[][], boolean debug) { JPanel panel = new JPanel(); panel.setOpaque(false); TableLayout layout = new TableLayout(tableSize); panel.setLayout(layout); panel.setBorder(BorderFactory.createEmptyBorder()); if (debug == true) panel.setBorder(BorderFactory.createCompoundBorder(BorderFactory.createLineBorder(Color.red), panel.getBorder())); return panel; }
From source file:es.emergya.ui.gis.popups.SDSDialog.java
public SDSDialog(Recurso r) { super();/*from w w w . j a v a 2 s . c om*/ setAlwaysOnTop(true); setResizable(false); iconTransparente = LogicConstants.getIcon("48x48_transparente"); iconEnviando = LogicConstants.getIcon("anim_enviando"); destino = r; setDefaultCloseOperation(DO_NOTHING_ON_CLOSE); addWindowListener(new WindowAdapter() { @Override public void windowClosing(WindowEvent e) { super.windowClosing(e); cancel.doClick(); } }); // setPreferredSize(new Dimension(400, 150)); setTitle(i18n.getString("window.sds.titleBar") + " " + r.getIdentificador()); try { setIconImage(((BasicWindow) GoClassLoader.getGoClassLoader().load(BasicWindow.class)).getFrame() .getIconImage()); } catch (Throwable e) { LOG.error("There is no icon image", e); } JPanel base = new JPanel(); base.setBackground(Color.WHITE); base.setLayout(new BoxLayout(base, BoxLayout.Y_AXIS)); // Icono del titulo JPanel title = new JPanel(new FlowLayout(FlowLayout.LEADING)); final JLabel titleLabel = new JLabel(i18n.getString("window.sds.title"), LogicConstants.getIcon("tittleventana_icon_enviarsds"), JLabel.LEFT); titleLabel.setFont(LogicConstants.deriveBoldFont(12f)); title.add(titleLabel); title.setOpaque(false); base.add(title); // Espacio para el mensaje sds = new JTextArea(7, 40); sds.setLineWrap(true); final JScrollPane sdsp = new JScrollPane(sds); sdsp.setOpaque(false); sdsp.setBorder(new TitledBorder(BorderFactory.createLineBorder(Color.BLACK), i18n.getString("Admin.message") + "\t (0/" + maxChars + ")")); sds.setDocument(new PlainDocument() { @Override public void insertString(int offs, String str, AttributeSet a) throws BadLocationException { if (this.getLength() + str.length() <= maxChars) { super.insertString(offs, str, a); } } }); sds.getDocument().addDocumentListener(new DocumentListener() { @Override public void removeUpdate(DocumentEvent e) { updateChars(e); } @Override public void insertUpdate(DocumentEvent e) { updateChars(e); } @Override public void changedUpdate(DocumentEvent e) { updateChars(e); } private void updateChars(DocumentEvent e) { ((TitledBorder) sdsp.getBorder()).setTitle( i18n.getString("Admin.message") + "\t (" + sds.getText().length() + "/" + maxChars + ")"); sdsp.repaint(); send.setEnabled(!sds.getText().isEmpty()); notification.setForeground(Color.WHITE); notification.setText("PLACEHOLDER"); } }); base.add(sdsp); // Area para mensajes JPanel notificationArea = new JPanel(); notificationArea.setOpaque(false); notification = new JLabel("TEXT"); notification.setForeground(Color.WHITE); notificationArea.add(notification); base.add(notificationArea); JPanel buttons = new JPanel(); buttons.setOpaque(false); buttons.setLayout(new BoxLayout(buttons, BoxLayout.X_AXIS)); send = new JButton(i18n.getString("Buttons.send"), LogicConstants.getIcon("ventanacontextual_button_enviarsds")); send.addActionListener(this); send.setEnabled(false); buttons.add(send); buttons.add(Box.createHorizontalGlue()); progressIcon = new JLabel(iconTransparente); buttons.add(progressIcon); buttons.add(Box.createHorizontalGlue()); cancel = new JButton(i18n.getString("Buttons.cancel"), LogicConstants.getIcon("button_cancel")); cancel.addActionListener(this); buttons.add(cancel); base.add(buttons); getContentPane().add(base); pack(); int x; int y; Container myParent; try { myParent = ((BasicWindow) GoClassLoader.getGoClassLoader().load(BasicWindow.class)).getFrame() .getContentPane(); java.awt.Point topLeft = myParent.getLocationOnScreen(); Dimension parentSize = myParent.getSize(); Dimension mySize = getSize(); if (parentSize.width > mySize.width) x = ((parentSize.width - mySize.width) / 2) + topLeft.x; else x = topLeft.x; if (parentSize.height > mySize.height) y = ((parentSize.height - mySize.height) / 2) + topLeft.y; else y = topLeft.y; setLocation(x, y); } catch (Throwable e1) { LOG.error("There is no basic window!", e1); } this.addWindowListener(new WindowAdapter() { @Override public void windowOpened(WindowEvent arg0) { deleteErrorMessage(); } @Override public void windowClosed(WindowEvent arg0) { deleteErrorMessage(); } private void deleteErrorMessage() { SwingWorker<Object, Object> sw = new SwingWorker<Object, Object>() { @Override protected Object doInBackground() throws Exception { if (bandejaSalida != null) { MessageGenerator.remove(bandejaSalida.getId()); } bandejaSalida = null; return null; } @Override protected void done() { super.done(); SDSDialog.this.sds.setText(""); SDSDialog.this.sds.setEnabled(true); SDSDialog.this.sds.repaint(); SDSDialog.this.progressIcon.setIcon(iconTransparente); SDSDialog.this.progressIcon.repaint(); SDSDialog.this.notification.setText(""); SDSDialog.this.notification.repaint(); } }; sw.execute(); } }); }
From source file:forge.gui.CardDetailPanel.java
public final void setItem(final InventoryItemFromSet item) { nameCostLabel.setText(item.getName()); typeLabel.setVisible(false);//from w w w . j av a2 s .c o m powerToughnessLabel.setVisible(false); idLabel.setText(""); cdArea.setText(CardDetailUtil.getItemDescription(item)); updateBorder(item instanceof IPaperCard ? Card.getCardForUi((IPaperCard) item).getView().getCurrentState() : null, true); final String set = item.getEdition(); setInfoLabel.setText(set); setInfoLabel.setToolTipText(""); if (StringUtils.isEmpty(set)) { setInfoLabel.setOpaque(false); setInfoLabel.setBorder(null); } else { final CardEdition edition = FModel.getMagicDb().getEditions().get(set); if (null != edition) { setInfoLabel.setToolTipText(edition.getName()); } setInfoLabel.setOpaque(true); setInfoLabel.setBackground(Color.BLACK); setInfoLabel.setForeground(Color.WHITE); setInfoLabel.setBorder(BorderFactory.createLineBorder(Color.WHITE)); } SwingUtilities.invokeLater(new Runnable() { @Override public void run() { scrArea.getVerticalScrollBar().setValue(scrArea.getVerticalScrollBar().getMinimum()); } }); }
From source file:com.joey.software.memoryToolkit.MemoryUsagePanel.java
/** * Creates a new application./*w ww . j ava 2 s.co m*/ * * @param historyCount * the history count (in milliseconds). */ public MemoryUsagePanel(int historyCount, int interval) { super(new BorderLayout()); // create two series that automatically discard data more than 30 // seconds old... this.total = new TimeSeries("Total Memory", Millisecond.class); this.total.setMaximumItemCount(historyCount); this.free = new TimeSeries("Free Memory", Millisecond.class); this.free.setMaximumItemCount(historyCount); this.used = new TimeSeries("Used Memory", Millisecond.class); this.used.setMaximumItemCount(historyCount); this.max = new TimeSeries("Used Memory", Millisecond.class); this.max.setMaximumItemCount(historyCount); TimeSeriesCollection dataset = new TimeSeriesCollection(); dataset.addSeries(this.total); dataset.addSeries(this.free); dataset.addSeries(this.used); dataset.addSeries(this.max); DateAxis domain = new DateAxis("Time"); NumberAxis range = new NumberAxis("Memory"); domain.setTickLabelFont(new Font("SansSerif", Font.PLAIN, 12)); range.setTickLabelFont(new Font("SansSerif", Font.PLAIN, 12)); domain.setLabelFont(new Font("SansSerif", Font.PLAIN, 14)); range.setLabelFont(new Font("SansSerif", Font.PLAIN, 14)); XYItemRenderer renderer = new XYLineAndShapeRenderer(true, false); renderer.setSeriesPaint(0, Color.red); renderer.setSeriesPaint(1, Color.green); renderer.setSeriesPaint(2, Color.black); renderer.setStroke(new BasicStroke(1f, BasicStroke.CAP_BUTT, BasicStroke.JOIN_BEVEL)); XYPlot plot = new XYPlot(dataset, domain, range, renderer); plot.setBackgroundPaint(Color.lightGray); plot.setDomainGridlinePaint(Color.white); plot.setRangeGridlinePaint(Color.white); plot.setAxisOffset(new RectangleInsets(5.0, 5.0, 5.0, 5.0)); domain.setAutoRange(true); domain.setLowerMargin(0.0); domain.setUpperMargin(0.0); domain.setTickLabelsVisible(true); range.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); JFreeChart chart = new JFreeChart("JVM Memory Usage", new Font("SansSerif", Font.BOLD, 24), plot, true); chart.setBackgroundPaint(Color.white); ChartPanel chartPanel = new ChartPanel(chart); chartPanel.setBorder(BorderFactory.createCompoundBorder(BorderFactory.createEmptyBorder(4, 4, 4, 4), BorderFactory.createLineBorder(Color.black))); add(chartPanel); gen = new DataGenerator(interval); }
From source file:org.pmedv.core.dialogs.AbstractNiceDialog.java
private JPanel createHeader(String title, String subTitle, ImageIcon icon) { int headerHeight = 50; FormLayout formLayout = new FormLayout("8dlu, 10dlu, fill:pref:grow, 7dlu, pref, 7dlu", "4dlu, 13dlu,max(" + (headerHeight - 17) + "dlu;default),default"); // GradientPanel header = new GradientPanel(formLayout,Color.WHITE,Color.LIGHT_GRAY); Color blue = new Color(153, 204, 255); GradientPanel header = new GradientPanel(formLayout, Color.WHITE, blue); header.setBorder(BorderFactory.createLineBorder(Color.LIGHT_GRAY)); header.setBackground(Color.white); JLabel titleLabel = new JLabel(title); JLabel subTitleLabel = new JLabel(subTitle); JLabel iconLabel = (icon == null ? new JLabel() : new JLabel(icon)); titleLabel.setForeground(Color.black); subTitleLabel.setForeground(Color.black); titleLabel.setFont(new Font("Arial", Font.BOLD, 15)); subTitleLabel.setFont(new Font("Arial", Font.PLAIN, 12)); CellConstraints cc = new CellConstraints(); header.add(titleLabel, cc.xywh(2, 2, 2, 1)); header.add(subTitleLabel, cc.xywh(2, 3, 2, 1)); header.add(iconLabel, cc.xywh(5, 1, 1, 3, "right,center")); return (header); }
From source file:com.chart.SwingChart.java
/** * Update background, tick and gridline colors * @param cfg cfg[0] Background, cfg[1] Chart background, cfg[2] y cfg[3] gridline *///from www . j a v a 2 s .co m public void updateChartColors(String[] cfg) { strBackgroundColor = cfg[0]; for (Node le : legendFrame.getChildren()) { if (le instanceof LegendAxis) { le.setStyle("-fx-background-color:" + strBackgroundColor); ((LegendAxis) le).selected = false; } } chart.setBackgroundPaint(scene2awtColor(javafx.scene.paint.Color.web(strBackgroundColor))); chartPanel.setBorder(BorderFactory.createCompoundBorder(BorderFactory.createEmptyBorder(4, 4, 4, 4), BorderFactory.createLineBorder(scene2awtColor(javafx.scene.paint.Color.web(strBackgroundColor))))); chartPanel.setBackground(scene2awtColor(javafx.scene.paint.Color.web(strBackgroundColor))); legendFrame.setStyle("marco: " + strBackgroundColor + ";-fx-background-color: marco;"); strChartBackgroundColor = cfg[1]; ; plot.setBackgroundPaint(scene2awtColor(javafx.scene.paint.Color.web(strChartBackgroundColor))); for (Node le : legendFrame.getChildren()) { if (le instanceof LegendAxis) { le.setStyle("-fx-background-color:" + strBackgroundColor); ((LegendAxis) le).selected = false; for (Node nn : ((LegendAxis) le).getChildren()) { if (nn instanceof Label) { ((Label) nn).setStyle("fondo: " + strChartBackgroundColor + ";-fx-background-color: fondo;-fx-text-fill: ladder(fondo, white 49%, black 50%);-fx-padding:5px;-fx-background-radius: 5;-fx-font-size: " + String.valueOf(fontSize) + "px"); } } } } strGridlineColor = cfg[2]; ; plot.setDomainGridlinePaint(scene2awtColor(javafx.scene.paint.Color.web(strGridlineColor))); plot.setRangeGridlinePaint(scene2awtColor(javafx.scene.paint.Color.web(strGridlineColor))); strTickColor = cfg[3]; ; abcissaAxis.setLabelPaint(scene2awtColor(javafx.scene.paint.Color.web(strTickColor))); abcissaAxis.setTickLabelPaint(scene2awtColor(javafx.scene.paint.Color.web(strTickColor))); for (NumberAxis ejeOrdenada : AxesList) { ejeOrdenada.setLabelPaint(scene2awtColor(javafx.scene.paint.Color.web(strTickColor))); ejeOrdenada.setTickLabelPaint(scene2awtColor(javafx.scene.paint.Color.web(strTickColor))); } }
From source file:be.nbb.demetra.dfm.DfmExecViewTopComponent.java
@Override public JComponent getToolbarRepresentation() { JToolBar toolBar = NbComponents.newInnerToolbar(); toolBar.addSeparator();//from w w w .jav a 2s .c om toolBar.add(Box.createRigidArea(new Dimension(5, 0))); JToggleButton startStop = (JToggleButton) toolBar .add(new JToggleButton(StartStopCommand.INSTANCE.toAction(this))); startStop.setIcon(DemetraUiIcon.COMPILE_16); startStop.setDisabledIcon(createDisabledIcon(startStop.getIcon())); startStop.setToolTipText("Start/Stop"); JButton edit = toolBar.add(EditSpecCommand.INSTANCE.toAction(this)); edit.setIcon(DemetraUiIcon.PREFERENCES); edit.setDisabledIcon(createDisabledIcon(edit.getIcon())); edit.setToolTipText("Specification"); JButton clear = toolBar.add(ClearCommand.INSTANCE.toAction(this)); clear.setIcon(DemetraUiIcon.EDIT_CLEAR_16); clear.setDisabledIcon(createDisabledIcon(clear.getIcon())); clear.setToolTipText("Clear"); SwingColorSchemeSupport colorSchemeSupport = SwingColorSchemeSupport .from(DemetraUI.getInstance().getColorScheme()); sparkline = (ChartPanel) toolBar .add(Charts.avoidScaling(new ChartPanel(Charts.createSparkLineChart(null)))); sparkline.setPreferredSize(new Dimension(150, 16)); sparkline.setMaximumSize(new Dimension(150, 16)); sparkline.getChart().getXYPlot().setDataset(dataset); sparkline.getChart().getXYPlot().getRenderer() .setBasePaint(colorSchemeSupport.getLineColor(ColorScheme.KnownColor.GREEN)); sparkline.setBackground(colorSchemeSupport.getPlotColor()); sparkline.setBorder(BorderFactory.createLineBorder(colorSchemeSupport.getGridColor())); sparkline.setToolTipText("loglikelihood"); return toolBar; }
From source file:controletanquesproj1.FrameInicial.java
/** * Creates new form FrameInicial/* ww w . ja v a 2s . c o m*/ */ public FrameInicial() { initComponents(); jLabel_4v.setEnabled(false); jSpinner_4v.setEnabled(false); jLabel_SetPoint.setEnabled(true); jSpinner_0a30.setEnabled(true); jLabel_Am_mi.setEnabled(false); jSpinner_Am_mi.setEnabled(false); jLabel_Du_ma.setEnabled(false); jSpinner_Du_ma.setEnabled(false); jLabel_Du_mi.setEnabled(false); jSpinner_Du_mi.setEnabled(false); jLabel_Offset.setEnabled(false); jSpinner_Offset.setEnabled(false); jLabel_Periodo.setEnabled(false); jSpinner_Periodo.setEnabled(false); jCBPlotP0.setVisible(false); jCBPlotP1.setVisible(false); jCBPlotErro_T1.setVisible(false); jCBPlotAcaoP_T1.setVisible(false); jCBPlotAcaoI_T1.setVisible(false); jCBPlotAcaoD_T1.setVisible(false); jCBPlotSP_T2.setVisible(false); jCBPlotMV_T2.setVisible(false); jCBPlotErro_T2.setVisible(false); jCBPlotAcaoP_T2.setVisible(false); jCBPlotAcaoI_T2.setVisible(false); jCBPlotAcaoD_T2.setVisible(false); jPanelGrafico.setLayout(new java.awt.BorderLayout()); demo = new Grafico(); itensDeGraficoV.add(new ItemDeGrafico("MV_T1", sizePlot)); itensDeGraficoV.add(new ItemDeGrafico("MVSat", sizePlot)); itensDeGraficoCm.add(new ItemDeGrafico("SetPoint_T1", sizePlot)); vetorDeItensDeGrafico = new ArrayList[2]; vetorDeItensDeGrafico[0] = itensDeGraficoV; vetorDeItensDeGrafico[1] = itensDeGraficoCm; demo.createDatasets(vetorDeItensDeGrafico); //Inconsistencia //dataset = demo.createDataset(itensDeGrafico); JFreeChart chart = demo.createChart(); ChartPanel chartPanel = new ChartPanel(chart); chartPanel.setPreferredSize(new java.awt.Dimension(1000, 660)); setPanel(chartPanel); for (int i = 0; i < 8; i++) { jCBoxCanalSaida.addItem(i); } jCBoxTanque1.addItem(0); jCBoxTanque1.addItem(1); jCBoxTanque2.addItem(0); jCBoxTanque2.addItem(1); jCBoxTanque2.setSelectedItem(1); jCBoxTanqueSelected.addItem(1); jCBoxTanqueSelected.addItem(2); jCBoxTanqueSelected.setSelectedItem(2); Border lineBorder = BorderFactory.createLineBorder(Color.black); Border titledBorder = BorderFactory.createTitledBorder(lineBorder, "Tanque 1"); jPanel_PlotT1.setBorder(titledBorder); Border titledBorder2 = BorderFactory.createTitledBorder(lineBorder, "Tanque 2"); jPanel_PlotT2.setBorder(titledBorder2); //System.out.println("Thread Grafico = " + Thread.currentThread().getId()); }