List of usage examples for java.awt Font PLAIN
int PLAIN
To view the source code for java.awt Font PLAIN.
Click Source Link
From source file:ComboBoxTest.java
public ComboBoxFrame() { setTitle("ComboBoxTest"); setSize(DEFAULT_WIDTH, DEFAULT_HEIGHT); // add the sample text label label = new JLabel("The quick brown fox jumps over the lazy dog."); label.setFont(new Font("Serif", Font.PLAIN, DEFAULT_SIZE)); add(label, BorderLayout.CENTER); // make a combo box and add face names faceCombo = new JComboBox(); faceCombo.setEditable(true);/*from ww w . j ava 2s . c o m*/ faceCombo.addItem("Serif"); faceCombo.addItem("SansSerif"); faceCombo.addItem("Monospaced"); faceCombo.addItem("Dialog"); faceCombo.addItem("DialogInput"); // the combo box listener changes the label font to the selected face name faceCombo.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent event) { label.setFont(new Font((String) faceCombo.getSelectedItem(), Font.PLAIN, DEFAULT_SIZE)); } }); // add combo box to a panel at the frame's southern border JPanel comboPanel = new JPanel(); comboPanel.add(faceCombo); add(comboPanel, BorderLayout.SOUTH); }
From source file:JSplash.java
private void init() { JPanel pnlImage = new JPanel(); ImageIcon image = new ImageIcon(getClass().getResource("img/logo.jpg")); JLabel lblBack = new JLabel(image); Border raisedbevel = BorderFactory.createRaisedBevelBorder(); Border loweredbevel = BorderFactory.createLoweredBevelBorder(); lblBack.setBounds(0, 0, image.getIconWidth(), image.getIconHeight()); getLayeredPane().add(lblBack, new Integer(Integer.MIN_VALUE)); pnlImage.setLayout(null);/*w w w .j av a 2 s . co m*/ pnlImage.setOpaque(false); pnlImage.setBorder(BorderFactory.createCompoundBorder(raisedbevel, loweredbevel)); pnlImage.add(this.lblVersion); this.lblVersion.setForeground(Color.white); this.lblVersion.setFont(new Font("Dialog", Font.PLAIN, 12)); this.lblVersion.setBounds(15, 69, 120, 20); setContentPane(pnlImage); setSize(image.getIconWidth(), image.getIconHeight()); }
From source file:hermes.swing.SwingAppender.java
public SwingAppender(String filter) { this.filter = filter; textArea.setFont(new Font("Courier", Font.PLAIN, 12)); }
From source file:CheckBoxTest.java
public CheckBoxFrame() { setTitle("CheckBoxTest"); setSize(DEFAULT_WIDTH, DEFAULT_HEIGHT); // add the sample text label label = new JLabel("The quick brown fox jumps over the lazy dog."); label.setFont(new Font("Serif", Font.PLAIN, FONTSIZE)); add(label, BorderLayout.CENTER); // this listener sets the font attribute of // the label to the check box state ActionListener listener = new ActionListener() { public void actionPerformed(ActionEvent event) { int mode = 0; if (bold.isSelected()) mode += Font.BOLD; if (italic.isSelected()) mode += Font.ITALIC; label.setFont(new Font("Serif", mode, FONTSIZE)); }//from w w w.jav a 2s.c o m }; // add the check boxes JPanel buttonPanel = new JPanel(); bold = new JCheckBox("Bold"); bold.addActionListener(listener); buttonPanel.add(bold); italic = new JCheckBox("Italic"); italic.addActionListener(listener); buttonPanel.add(italic); add(buttonPanel, BorderLayout.SOUTH); }
From source file:com.stam.batchmove.BatchMoveUtils.java
public static void showFilesFrame(Object[][] data, String[] columnNames, final JFrame callerFrame) { final FilesFrame filesFrame = new FilesFrame(); DefaultTableModel model = new DefaultTableModel(data, columnNames) { private static final long serialVersionUID = 1L; @Override//from w w w.j av a2 s. com public Class<?> getColumnClass(int column) { return getValueAt(0, column).getClass(); } @Override public boolean isCellEditable(int row, int column) { return column == 0; } }; DefaultTableCellRenderer renderer = new DefaultTableCellRenderer(); renderer.setHorizontalAlignment(JLabel.CENTER); final JTable table = new JTable(model); for (int i = 1; i < table.getColumnCount(); i++) { table.setDefaultRenderer(table.getColumnClass(i), renderer); } // table.setAutoResizeMode(JTable.AUTO_RESIZE_OFF); table.setRowHeight(30); table.getTableHeader().setFont(new Font("Serif", Font.BOLD, 14)); table.setFont(new Font(Font.MONOSPACED, Font.PLAIN, 14)); table.setRowSelectionAllowed(false); table.getColumnModel().getColumn(0).setMaxWidth(35); table.getColumnModel().getColumn(1).setPreferredWidth(350); table.getColumnModel().getColumn(2).setPreferredWidth(90); table.getColumnModel().getColumn(2).setMaxWidth(140); table.getColumnModel().getColumn(3).setMaxWidth(90); JPanel tblPanel = new JPanel(); JPanel btnPanel = new JPanel(); tblPanel.setLayout(new BorderLayout()); if (table.getRowCount() > 15) { JScrollPane scrollPane = new JScrollPane(table); tblPanel.add(scrollPane, BorderLayout.CENTER); } else { tblPanel.add(table.getTableHeader(), BorderLayout.NORTH); tblPanel.add(table, BorderLayout.CENTER); } btnPanel.setLayout(new FlowLayout(FlowLayout.LEFT)); filesFrame.setMinimumSize(new Dimension(800, 600)); filesFrame.setLayout(new BorderLayout()); filesFrame.add(tblPanel, BorderLayout.NORTH); filesFrame.add(btnPanel, BorderLayout.SOUTH); final JLabel resultsLabel = new JLabel(); JButton cancelBtn = new JButton("Cancel"); cancelBtn.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { filesFrame.setVisible(false); callerFrame.setVisible(true); } }); JButton moveBtn = new JButton("Copy"); moveBtn.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { JFileChooser fileChooser = new JFileChooser(); fileChooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY); fileChooser.setDialogTitle("Choose target directory"); int selVal = fileChooser.showOpenDialog(null); if (selVal == JFileChooser.APPROVE_OPTION) { File selection = fileChooser.getSelectedFile(); String targetPath = selection.getAbsolutePath(); DefaultTableModel dtm = (DefaultTableModel) table.getModel(); int nRow = dtm.getRowCount(); int copied = 0; for (int i = 0; i < nRow; i++) { Boolean selected = (Boolean) dtm.getValueAt(i, 0); String filePath = dtm.getValueAt(i, 1).toString(); if (selected) { try { FileUtils.copyFileToDirectory(new File(filePath), new File(targetPath)); dtm.setValueAt("Copied", i, 3); copied++; } catch (Exception ex) { Logger.getLogger(SelectionFrame.class.getName()).log(Level.SEVERE, null, ex); dtm.setValueAt("Failed", i, 3); } } } resultsLabel.setText(copied + " files copied. Finished!"); } } }); btnPanel.add(cancelBtn); btnPanel.add(moveBtn); btnPanel.add(resultsLabel); filesFrame.revalidate(); filesFrame.setVisible(true); callerFrame.setVisible(false); }
From source file:ShowOff.java
public ShowOff(String filename, String message, int split) throws IOException, ImageFormatException { InputStream in = getClass().getResourceAsStream(filename); JPEGImageDecoder decoder = JPEGCodec.createJPEGDecoder(in); mImage = decoder.decodeAsBufferedImage(); in.close();//from w ww .j a v a 2 s .c o m mFont = new Font("Serif", Font.PLAIN, 116); mMessage = message; mSplit = split; setSize((int) mImage.getWidth(), (int) mImage.getHeight()); }
From source file:D20140128.ApacheXMLGraphicsTest.EPSExample1.java
/** * Creates an EPS file. The contents are painted using a Graphics2D * implementation that generates an EPS file. * * @param outputFile the target file//from www. j a v a 2s .co m * @throws IOException In case of an I/O error */ public static void generateEPSusingJava2D(File outputFile) throws IOException { OutputStream out = new java.io.FileOutputStream(outputFile); out = new java.io.BufferedOutputStream(out); try { //Instantiate the EPSDocumentGraphics2D instance EPSDocumentGraphics2D g2d = new EPSDocumentGraphics2D(false); g2d.setGraphicContext(new org.apache.xmlgraphics.java2d.GraphicContext()); //Set up the document size g2d.setupDocument(out, 400, 200); //400pt x 200pt //Paint a bounding box g2d.drawRect(0, 0, 400, 200); //A few rectangles rotated and with different color Graphics2D copy = (Graphics2D) g2d.create(); int c = 12; for (int i = 0; i < c; i++) { float f = ((i + 1) / (float) c); Color col = new Color(0.0f, 1 - f, 0.0f); copy.setColor(col); copy.fillRect(70, 90, 50, 50); copy.rotate(-2 * Math.PI / (double) c, 70, 90); } copy.dispose(); //Some text g2d.rotate(-0.25); g2d.setColor(Color.RED); g2d.setFont(new Font("sans-serif", Font.PLAIN, 36)); g2d.drawString("Hello world!", 140, 140); g2d.setColor(Color.RED.darker()); g2d.setFont(new Font("serif", Font.PLAIN, 36)); g2d.drawString("Hello world!", 140, 180); //Cleanup g2d.finish(); } finally { IOUtils.closeQuietly(out); } }
From source file:RadioButtonTest.java
public RadioButtonFrame() { setTitle("RadioButtonTest"); setSize(DEFAULT_WIDTH, DEFAULT_HEIGHT); // add the sample text label label = new JLabel("The quick brown fox jumps over the lazy dog."); label.setFont(new Font("Serif", Font.PLAIN, DEFAULT_SIZE)); add(label, BorderLayout.CENTER); // add the radio buttons buttonPanel = new JPanel(); group = new ButtonGroup(); addRadioButton("Small", 8); addRadioButton("Medium", 12); addRadioButton("Large", 18); addRadioButton("Extra large", 36); add(buttonPanel, BorderLayout.SOUTH); }
From source file:demo.BarChartDemo11.java
/** * Creates a sample chart./* w w w . j av a2s. c om*/ * * @param dataset the dataset. * * @return The chart. */ private static JFreeChart createChart(CategoryDataset dataset) { // create the chart... JFreeChart chart = ChartFactory.createBarChart("Open Source Projects By License", "License", "Percent", dataset); chart.removeLegend(); TextTitle source = new TextTitle( "Source: http://www.blackducksoftware.com/resources/data/top-20-licenses (as at 30 Aug 2013)", new Font("Dialog", Font.PLAIN, 9)); source.setPosition(RectangleEdge.BOTTOM); chart.addSubtitle(source); // get a reference to the plot for further customisation... CategoryPlot plot = (CategoryPlot) chart.getPlot(); plot.setOrientation(PlotOrientation.HORIZONTAL); plot.setDomainGridlinesVisible(true); plot.getDomainAxis().setMaximumCategoryLabelWidthRatio(0.8f); // set the range axis to display integers only... NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis(); rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); // disable bar outlines... BarRenderer renderer = (BarRenderer) plot.getRenderer(); renderer.setDrawBarOutline(false); StandardCategoryToolTipGenerator tt = new StandardCategoryToolTipGenerator("{1}: {2} percent", new DecimalFormat("0")); renderer.setBaseToolTipGenerator(tt); // set up gradient paints for series... GradientPaint gp0 = new GradientPaint(0.0f, 0.0f, Color.BLUE, 0.0f, 0.0f, new Color(0, 0, 64)); renderer.setSeriesPaint(0, gp0); return chart; }
From source file:charts.AceptadosRechazadosPie.java
private JFreeChart createChart(PieDataset dataset, String title) { JFreeChart chart = ChartFactory.createPieChart(title, dataset, true, true, false); // createBarChart(title, "Cantidades", "Estado de las trazas", dataset, PlotOrientation.VERTICAL, true, true, false); PiePlot plot = (PiePlot) chart.getPlot(); plot.setLabelFont(new Font("SansSerif", Font.PLAIN, 11)); plot.setNoDataMessage("no data"); plot.setCircular(false);//from w w w . j a v a 2s . c om plot.setLabelGap(0.02); return chart; }