List of usage examples for java.awt Font ITALIC
int ITALIC
To view the source code for java.awt Font ITALIC.
Click Source Link
From source file:ComplexRenderingSample.java
public static void main(String args[]) { Object elements[][] = {//from www. j a v a 2s . co m { new Font("Helvetica", Font.PLAIN, 20), Color.red, new DiamondIcon(Color.blue), "Help" }, { new Font("TimesRoman", Font.BOLD, 14), Color.blue, new DiamondIcon(Color.green), "Me" }, { new Font("Courier", Font.ITALIC, 18), Color.green, new DiamondIcon(Color.black), "I'm" }, { new Font("Helvetica", Font.BOLD | Font.ITALIC, 12), Color.gray, new DiamondIcon(Color.magenta), "Trapped" }, { new Font("TimesRoman", Font.PLAIN, 32), Color.pink, new DiamondIcon(Color.yellow), "Inside" }, { new Font("Courier", Font.BOLD, 16), Color.yellow, new DiamondIcon(Color.red), "This" }, { new Font("Helvetica", Font.ITALIC, 8), Color.darkGray, new DiamondIcon(Color.pink), "Computer" } }; JFrame frame = new JFrame("Complex Renderer"); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); Container contentPane = frame.getContentPane(); JList jlist = new JList(elements); ListCellRenderer renderer = new ComplexCellRenderer(); jlist.setCellRenderer(renderer); JScrollPane scrollPane = new JScrollPane(jlist); contentPane.add(scrollPane, BorderLayout.CENTER); JComboBox comboBox = new JComboBox(elements); comboBox.setRenderer(renderer); contentPane.add(comboBox, BorderLayout.NORTH); frame.setSize(300, 300); frame.setVisible(true); }
From source file:ResourceModExample.java
public static void main(String[] args) { Border border = BorderFactory.createRaisedBevelBorder(); Border tripleBorder = new CompoundBorder(new CompoundBorder(border, border), border); UIManager.put("Button.border", tripleBorder); UIManager.put("InternalFrame.closeIcon", new ImageIcon("close.gif")); UIManager.put("InternalFrame.iconizeIcon", new ImageIcon("iconify.gif")); UIManager.put("InternalFrame.maximizeIcon", new ImageIcon("maximize.gif")); UIManager.put("InternalFrame.altMaximizeIcon", new ImageIcon("altMax.gif")); UIManager.put("InternalFrame.titleFont", new Font("Serif", Font.ITALIC, 12)); UIManager.put("ScrollBar.width", new Integer(30)); JFrame f = new JFrame(); f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); Container c = f.getContentPane(); JDesktopPane desk = new JDesktopPane(); c.add(desk, BorderLayout.CENTER); JButton cut = new JButton("Cut"); JButton copy = new JButton("Copy"); JButton paste = new JButton("Paste"); JPanel p = new JPanel(new FlowLayout()); p.add(cut);//from ww w . java 2 s . c o m p.add(copy); p.add(paste); c.add(p, BorderLayout.SOUTH); JInternalFrame inf = new JInternalFrame("MyFrame", true, true, true, true); JLabel l = new JLabel(new ImageIcon("luggage.jpeg")); JScrollPane scroll = new JScrollPane(l); inf.setContentPane(scroll); inf.setBounds(10, 10, 350, 280); desk.add(inf); inf.setVisible(true); f.setSize(380, 360); f.setVisible(true); }
From source file:CreateColorSamplePopup.java
public static void main(String args[]) { JFrame frame = new JFrame("JColorChooser Create Popup Sample"); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); Container contentPane = frame.getContentPane(); final JButton button = new JButton("Pick to Change Background"); ActionListener actionListener = new ActionListener() { public void actionPerformed(ActionEvent actionEvent) { Color initialBackground = button.getBackground(); final JColorChooser colorChooser = new JColorChooser(initialBackground); // colorChooser.setPreviewPanel(new JPanel()); final JLabel previewLabel = new JLabel("I Love Swing", JLabel.CENTER); previewLabel.setFont(new Font("Serif", Font.BOLD | Font.ITALIC, 48)); colorChooser.setPreviewPanel(previewLabel); // Bug workaround colorChooser.updateUI();/*from www . jav a 2s . co m*/ // For okay button selection, change button background to // selected color ActionListener okActionListener = new ActionListener() { public void actionPerformed(ActionEvent actionEvent) { Color newColor = colorChooser.getColor(); if (newColor.equals(button.getForeground())) { System.out.println("Color change rejected"); } else { button.setBackground(colorChooser.getColor()); } } }; // For cancel button selection, change button background to red ActionListener cancelActionListener = new ActionListener() { public void actionPerformed(ActionEvent actionEvent) { button.setBackground(Color.red); } }; final JDialog dialog = JColorChooser.createDialog(null, "Change Button Background", true, colorChooser, okActionListener, cancelActionListener); // Wait until current event dispatching completes before showing // dialog Runnable showDialog = new Runnable() { public void run() { dialog.show(); } }; SwingUtilities.invokeLater(showDialog); } }; button.addActionListener(actionListener); contentPane.add(button, BorderLayout.CENTER); frame.setSize(300, 100); frame.setVisible(true); }
From source file:com.ohalo.cn.awt.JFreeChartTest3.java
public static void main(String[] args) throws Exception { JFreeChart chart = ChartFactory.createPieChart("???", getDataset(), true, true, false);/*from ww w.ja va 2s . c om*/ chart.setTitle(new TextTitle("??", new Font("", Font.BOLD + Font.ITALIC, 20))); LegendTitle legend = chart.getLegend(0);// Legend legend.setItemFont(new Font("", Font.BOLD, 14)); PiePlot plot = (PiePlot) chart.getPlot();// Plot plot.setLabelFont(new Font("", Font.BOLD, 16)); OutputStream os = new FileOutputStream("company.jpeg");// ??FileOutputStream? ChartUtilities.writeChartAsJPEG(os, chart, 1000, 800); // ??applicationchart??JPEG?3?4? os.close();// ? }
From source file:BorderSample.java
public static void main(String args[]) { JFrame frame = new JFrame("Sample Borders"); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); Border bevelBorder = new BevelBorder(BevelBorder.RAISED, Color.red, Color.red.darker(), Color.pink, Color.pink.brighter()); Border emptyBorder = new EmptyBorder(5, 10, 5, 10); Border etchedBorder = new EtchedBorder(EtchedBorder.RAISED, Color.red, Color.pink); Border lineBorder = new LineBorder(Color.red, 5); Icon diamondIcon = new DiamondIcon(Color.red); Border matteBorder = new MatteBorder(5, 10, 5, 10, diamondIcon); Border softBevelBorder = new SoftBevelBorder(BevelBorder.RAISED, Color.red, Color.red.darker(), Color.pink, Color.pink.brighter()); Font font = new Font("Serif", Font.ITALIC, 12); Border titledBorder = new TitledBorder(lineBorder, "Hello", TitledBorder.LEFT, TitledBorder.BELOW_BOTTOM, font, Color.red);/*from w w w. ja va 2 s . co m*/ Border compoundBorder = new CompoundBorder(lineBorder, matteBorder); JLabel bevelLabel = new JLabel("Bevel"); bevelLabel.setBorder(bevelBorder); bevelLabel.setHorizontalAlignment(JLabel.CENTER); JLabel emptyLabel = new JLabel("Empty"); emptyLabel.setBorder(emptyBorder); emptyLabel.setHorizontalAlignment(JLabel.CENTER); JLabel etchedLabel = new JLabel("Etched"); etchedLabel.setBorder(etchedBorder); etchedLabel.setHorizontalAlignment(JLabel.CENTER); JLabel lineLabel = new JLabel("Line"); lineLabel.setBorder(lineBorder); lineLabel.setHorizontalAlignment(JLabel.CENTER); JLabel matteLabel = new JLabel("Matte"); matteLabel.setBorder(matteBorder); matteLabel.setHorizontalAlignment(JLabel.CENTER); JLabel softBevelLabel = new JLabel("Soft Bevel"); softBevelLabel.setBorder(softBevelBorder); softBevelLabel.setHorizontalAlignment(JLabel.CENTER); JLabel titledLabel = new JLabel("Titled"); titledLabel.setBorder(titledBorder); titledLabel.setHorizontalAlignment(JLabel.CENTER); JLabel compoundLabel = new JLabel("Compound"); compoundLabel.setBorder(compoundBorder); compoundLabel.setHorizontalAlignment(JLabel.CENTER); Container contentPane = frame.getContentPane(); contentPane.setLayout(new GridLayout(2, 4, 5, 5)); contentPane.add(bevelLabel); contentPane.add(emptyLabel); contentPane.add(etchedLabel); contentPane.add(lineLabel); contentPane.add(matteLabel); contentPane.add(softBevelLabel); contentPane.add(titledLabel); contentPane.add(compoundLabel); frame.setSize(400, 200); frame.setVisible(true); }
From source file:ComplexCellRenderer.java
public static void main(String args[]) { Object elements[][] = { { new Font("Helvetica", Font.PLAIN, 20), Color.RED, new MyIcon(), "A" }, { new Font("TimesRoman", Font.BOLD, 14), Color.BLUE, new MyIcon(), "A" }, { new Font("Courier", Font.ITALIC, 18), Color.GREEN, new MyIcon(), "A" }, { new Font("Helvetica", Font.BOLD | Font.ITALIC, 12), Color.GRAY, new MyIcon(), "A" }, { new Font("TimesRoman", Font.PLAIN, 32), Color.PINK, new MyIcon(), "A" }, { new Font("Courier", Font.BOLD, 16), Color.YELLOW, new MyIcon(), "A" }, { new Font("Helvetica", Font.ITALIC, 8), Color.DARK_GRAY, new MyIcon(), "A" } }; JFrame frame = new JFrame("Complex Renderer"); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); ListCellRenderer renderer = new ComplexCellRenderer(); JComboBox comboBox = new JComboBox(elements); comboBox.setRenderer(renderer);//from w ww .ja v a 2 s . c o m frame.add(comboBox, BorderLayout.NORTH); frame.setSize(300, 200); frame.setVisible(true); }
From source file:ComplexCellRenderer.java
public static void main(String args[]) { Object elements[][] = { { new Font("Helvetica", Font.PLAIN, 20), Color.RED, new MyIcon(), "A" }, { new Font("TimesRoman", Font.BOLD, 14), Color.BLUE, new MyIcon(), "A" }, { new Font("Courier", Font.ITALIC, 18), Color.GREEN, new MyIcon(), "A" }, { new Font("Helvetica", Font.BOLD | Font.ITALIC, 12), Color.GRAY, new MyIcon(), "A" }, { new Font("TimesRoman", Font.PLAIN, 32), Color.PINK, new MyIcon(), "A" }, { new Font("Courier", Font.BOLD, 16), Color.YELLOW, new MyIcon(), "A" }, { new Font("Helvetica", Font.ITALIC, 8), Color.DARK_GRAY, new MyIcon(), "A" } }; JFrame frame = new JFrame("Complex Renderer"); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); JList jlist = new JList(elements); ListCellRenderer renderer = new ComplexCellRenderer(); jlist.setCellRenderer(renderer);//from w w w.j a v a2 s.c o m JScrollPane scrollPane = new JScrollPane(jlist); frame.add(scrollPane, BorderLayout.CENTER); frame.setSize(300, 200); frame.setVisible(true); }
From source file:Main.java
public static void italicLabel(JLabel label) { label.setFont(label.getFont().deriveFont(Font.ITALIC)); }
From source file:Main.java
public static String getStyleFromInteger(int style) { if (style == Font.BOLD) return "BOLD"; else if (style == Font.ITALIC) return "ITALIC"; else/*from w w w .j ava 2 s . c o m*/ return "PLAIN"; }
From source file:Main.java
public static void italicBoldLabel(JLabel label) { label.setFont(label.getFont().deriveFont(Font.BOLD + Font.ITALIC)); }