List of usage examples for javax.swing JPanel setFont
@BeanProperty(preferred = true, visualUpdate = true, description = "The font for the component.") public void setFont(Font font)
From source file:net.mumie.coursecreator.gui.ClassChooser.java
private void buildLayout() { // Dimensions of the Dialog int width = 10; int height = 160; int buttonWidth = 100; int buttonHeight = 30; // sets the Layout this.getContentPane().setLayout(new GridBagLayout()); // the Button and Label Text String okButtonText = "Zuweisen"; String cancelButtonText = "Cancel"; headlineLabelText = ""; // the Fonts/* w w w .j a va 2 s. c o m*/ Font font = new Font("SansSerif", Font.PLAIN, 14); Font headlineLabelFont = new Font("SansSerif", Font.PLAIN, 12); Font textFieldFont = new Font("Monospaced", Font.PLAIN, 10); // GridBagContraints for rootPanel (s.b.): GridBagConstraints rootPanelStyle = createGridBagContrains(GridBagConstraints.CENTER, 4, 4, 4, 4, 0, 0); // GridBagContraints for headlineLabel: GridBagConstraints headlineLabelStyle = createGridBagContrains(GridBagConstraints.CENTER, 6, 6, 6, 6, 0, 0); // GridBagConstraints for textFieldPanel (s.b.): GridBagConstraints textFieldPanelStyle = createGridBagContrains(GridBagConstraints.CENTER, 4, 4, 4, 4, 0, 1); // GridBagConstraints for buttonPanel (s.b.): GridBagConstraints buttonPanelStyle = createGridBagContrains(GridBagConstraints.CENTER, 4, 4, 4, 4, 0, 2); // GridBagConstraints for serverTextField: GridBagConstraints serverTextFieldStyle = createGridBagContrains(GridBagConstraints.WEST, 6, 6, 6, 6, 1, 0); // GridBagContraints for okButton (s.b.): GridBagConstraints okButtonStyle = createGridBagContrains(GridBagConstraints.CENTER, 6, 6, 6, 6, 0, 0); // GridBagContraints for cancelButton (s.b.): GridBagConstraints cancelButtonStyle = createGridBagContrains(GridBagConstraints.CENTER, 6, 6, 6, 6, 1, 0); // Creating rootPanel (contains all components) JPanel rootPanel = new JPanel(new GridBagLayout()); rootPanel.setFont(font); // Creating headlineLabel: JLabel headlineLabel = new JLabel(headlineLabelText); headlineLabel.setFont(headlineLabelFont); // Creating textFieldPanel: JPanel textFieldPanel = new JPanel(new GridBagLayout()); textFieldPanel.setFont(font); // Creating classTextField: classBox = new JComboBox(this.classList); classBox.setFont(textFieldFont); String classPath = this.controller.getMetaInfoField().getMetaInfos().getClassPath(); String className = this.controller.getMetaInfoField().getMetaInfos().getClassName(); if (setSelectedClass(classPath, className) == -1) headlineLabel.setForeground(Color.RED); else headlineLabel.setForeground(Color.BLACK); headlineLabel.setText(this.headlineLabelText); // Creating buttonPanel: JPanel buttonPanel = new JPanel(new GridBagLayout()); buttonPanel.setFont(font); // okButton: JButton okButton = new JButton(okButtonText); okButton.setPreferredSize(new Dimension(buttonWidth, buttonHeight)); okButton.setActionCommand(CommandConstants.META_INFO_FIELD_OK); okButton.addActionListener(this.controller); // cancelButton: JButton cancelButton = new JButton(cancelButtonText); cancelButton.setPreferredSize(new Dimension(buttonWidth, buttonHeight)); cancelButton.setActionCommand(CommandConstants.META_INFO_FIELD_CANCEL); cancelButton.addActionListener(this.controller); // Composing the GUI: this.getContentPane().setLayout(new GridBagLayout()); this.getContentPane().add(rootPanel, rootPanelStyle); rootPanel.add(headlineLabel, headlineLabelStyle); rootPanel.add(textFieldPanel, textFieldPanelStyle); textFieldPanel.add(classBox, serverTextFieldStyle); rootPanel.add(buttonPanel, buttonPanelStyle); buttonPanel.add(okButton, okButtonStyle); buttonPanel.add(cancelButton, cancelButtonStyle); this.addWindowListener(this.windowListener); int maxString = this.headlineLabelText.length(); for (int i = 0; i < this.classList.size(); i++) { maxString = Math.max(((String) this.classList.get(i).toString()).length(), maxString); } width = Math.max(width, maxString * 8); this.setSize(width, height); }
From source file:com.openbravo.pos.sales.JRetailTicketPreviewTicket.java
private JPanel getLabelPanel(String msg, Color colour) { JPanel panel = new JPanel(); Font font = new Font("Verdana", Font.BOLD, 12); panel.setFont(font); panel.setOpaque(true);/* w w w . j av a2 s . c om*/ // panel.setBackground(Color.BLUE); JLabel label = new JLabel(msg, JLabel.LEFT); label.setForeground(colour); label.setHorizontalAlignment(javax.swing.SwingConstants.LEFT); panel.add(label); return panel; }
From source file:erigo.filepump.FilePump.java
private void createAndShowGUI(String default_outputFolderI, double default_filesPerSecI, int default_totNumFilesI, FileMode default_modeI, String default_ftpHostI, String default_ftpUserI, String default_ftpPasswordI) { // Make sure we have nice window decorations. JFrame.setDefaultLookAndFeelDecorated(true); // Create the GUI components GridBagLayout framegbl = new GridBagLayout(); filePumpGuiFrame = new JFrame("FilePump"); GridBagLayout gbl = new GridBagLayout(); JPanel guiPanel = new JPanel(gbl); outputFolderLabel = new JLabel(" "); Dimension preferredSize = new Dimension(200, 20); outputFolderLabel.setPreferredSize(preferredSize); filesPerSecLabel = new JLabel("1"); totNumFilesLabel = new JLabel("unlimited"); modeLabel = new JLabel("file system folder"); fileCountLabel = new JLabel("0"); endButton = new JButton("Finish test"); endButton.addActionListener(this); actionButton = new JButton("Start pump"); actionButton.setBackground(Color.GREEN); actionButton.addActionListener(this); filePumpGuiFrame.setFont(new Font("Dialog", Font.PLAIN, 12)); guiPanel.setFont(new Font("Dialog", Font.PLAIN, 12)); int row = 0;//from w ww. ja v a2 s. c o m GridBagConstraints gbc = new GridBagConstraints(); gbc.anchor = GridBagConstraints.WEST; gbc.fill = GridBagConstraints.NONE; gbc.weightx = 0; gbc.weighty = 0; // ROW 1 JLabel label = new JLabel("Output directory"); gbc.insets = new Insets(15, 15, 0, 5); Utility.add(guiPanel, label, gbl, gbc, 0, row, 1, 1); gbc.insets = new Insets(15, 0, 0, 15); gbc.fill = GridBagConstraints.HORIZONTAL; gbc.weightx = 100; gbc.weighty = 100; Utility.add(guiPanel, outputFolderLabel, gbl, gbc, 1, row, 1, 1); gbc.fill = GridBagConstraints.NONE; gbc.weightx = 0; gbc.weighty = 0; ++row; // ROW 2 label = new JLabel("Files/sec"); gbc.insets = new Insets(15, 15, 0, 5); Utility.add(guiPanel, label, gbl, gbc, 0, row, 1, 1); gbc.insets = new Insets(15, 0, 0, 15); gbc.fill = GridBagConstraints.HORIZONTAL; gbc.weightx = 100; gbc.weighty = 100; Utility.add(guiPanel, filesPerSecLabel, gbl, gbc, 1, row, 1, 1); gbc.fill = GridBagConstraints.NONE; gbc.weightx = 0; gbc.weighty = 0; ++row; // ROW 3 label = new JLabel("Tot num files"); gbc.insets = new Insets(15, 15, 0, 5); Utility.add(guiPanel, label, gbl, gbc, 0, row, 1, 1); gbc.insets = new Insets(15, 0, 0, 15); gbc.fill = GridBagConstraints.HORIZONTAL; gbc.weightx = 100; gbc.weighty = 100; Utility.add(guiPanel, totNumFilesLabel, gbl, gbc, 1, row, 1, 1); gbc.fill = GridBagConstraints.NONE; gbc.weightx = 0; gbc.weighty = 0; ++row; // ROW 4 label = new JLabel("Mode"); gbc.insets = new Insets(15, 15, 0, 5); Utility.add(guiPanel, label, gbl, gbc, 0, row, 1, 1); gbc.insets = new Insets(15, 0, 0, 15); gbc.fill = GridBagConstraints.HORIZONTAL; gbc.weightx = 100; gbc.weighty = 100; Utility.add(guiPanel, modeLabel, gbl, gbc, 1, row, 1, 1); gbc.fill = GridBagConstraints.NONE; gbc.weightx = 0; gbc.weighty = 0; ++row; // ROW 5 label = new JLabel("File count"); gbc.insets = new Insets(15, 15, 0, 5); Utility.add(guiPanel, label, gbl, gbc, 0, row, 1, 1); gbc.insets = new Insets(15, 0, 0, 15); gbc.fill = GridBagConstraints.HORIZONTAL; gbc.weightx = 100; gbc.weighty = 100; Utility.add(guiPanel, fileCountLabel, gbl, gbc, 1, row, 1, 1); gbc.fill = GridBagConstraints.NONE; gbc.weightx = 0; gbc.weighty = 0; ++row; // ROW 6: command buttons JPanel buttonPanel = new JPanel(); buttonPanel.add(actionButton); buttonPanel.add(endButton); gbc.insets = new Insets(15, 15, 15, 15); gbc.anchor = GridBagConstraints.CENTER; Utility.add(guiPanel, buttonPanel, gbl, gbc, 0, row, 2, 1); gbc.anchor = GridBagConstraints.WEST; ++row; // Now add guiPanel to filePumpGuiFrame gbc.anchor = GridBagConstraints.CENTER; gbc.fill = GridBagConstraints.BOTH; gbc.weightx = 100; gbc.weighty = 100; gbc.insets = new Insets(0, 0, 0, 0); Utility.add(filePumpGuiFrame, guiPanel, framegbl, gbc, 0, 0, 1, 1); // Add menu JMenuBar menuBar = createMenu(); filePumpGuiFrame.setJMenuBar(menuBar); // Display the window. filePumpGuiFrame.pack(); filePumpGuiFrame.setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE); filePumpGuiFrame.addWindowListener(new WindowAdapter() { public void windowClosing(WindowEvent e) { exit(); } }); // Create a settings dialog box pumpSettings = new FilePumpSettings(filePumpGuiFrame, default_outputFolderI, default_filesPerSecI, default_totNumFilesI, default_modeI, default_ftpHostI, default_ftpUserI, default_ftpPasswordI); // Initialize information displayed on the GUI front panel updateMainFrame(); filePumpGuiFrame.setVisible(true); }
From source file:com.openbravo.pos.sales.restaurant.JRetailTicketsBagRestaurantMap.java
private JPanel getLabelPanel(String msg) { JPanel panel = new JPanel(); Font font = new Font("Verdana", Font.BOLD, 12); panel.setFont(font); panel.setOpaque(true);/*from w ww .j a v a 2 s . c o m*/ JLabel label = new JLabel(msg, JLabel.LEFT); label.setForeground(Color.RED); label.setHorizontalAlignment(javax.swing.SwingConstants.LEFT); panel.add(label); return panel; }
From source file:com.openbravo.pos.sales.JRetailPanelTicket.java
private JPanel getLabelPanel(String msg) { JPanel panel = new JPanel(); Font font = new Font("Verdana", Font.BOLD, 12); panel.setFont(font); panel.setOpaque(true);/* w w w . j av a 2s. c o m*/ JLabel label = new JLabel(msg, JLabel.LEFT); label.setForeground(Color.RED); label.setHorizontalAlignment(javax.swing.SwingConstants.LEFT); panel.add(label); return panel; }
From source file:com.openbravo.pos.sales.JRetailPanelTakeAway.java
private JPanel getLabelPanel(String msg) { JPanel panel = new JPanel(); Font font = new Font("Verdana", Font.BOLD, 12); panel.setFont(font); panel.setOpaque(true);//from w w w .j a v a 2 s . com // panel.setBackground(Color.BLUE); JLabel label = new JLabel(msg, JLabel.LEFT); label.setForeground(Color.RED); label.setHorizontalAlignment(javax.swing.SwingConstants.LEFT); panel.add(label); return panel; }
From source file:org.apache.jmeter.protocol.http.config.gui.UrlConfigGui.java
/** * This method defines the Panel for the HTTP path, 'Follow Redirects' * 'Use KeepAlive', and 'Use multipart for HTTP POST' elements. * * @return JPanel The Panel for the path, 'Follow Redirects' and 'Use * KeepAlive' elements.//from w w w. j a v a2 s .com */ protected Component getPathPanel() { path = new JTextField(15); JLabel label = new JLabel(JMeterUtils.getResString("path")); //$NON-NLS-1$ label.setLabelFor(path); if (notConfigOnly) { followRedirects = new JCheckBox(JMeterUtils.getResString("follow_redirects")); // $NON-NLS-1$ followRedirects.setFont(null); followRedirects.setSelected(true); followRedirects.addChangeListener(this); autoRedirects = new JCheckBox(JMeterUtils.getResString("follow_redirects_auto")); //$NON-NLS-1$ autoRedirects.setFont(null); autoRedirects.addChangeListener(this); autoRedirects.setSelected(false);// Default changed in 2.3 and again in 2.4 useKeepAlive = new JCheckBox(JMeterUtils.getResString("use_keepalive")); // $NON-NLS-1$ useKeepAlive.setFont(null); useKeepAlive.setSelected(true); useMultipartForPost = new JCheckBox(JMeterUtils.getResString("use_multipart_for_http_post")); // $NON-NLS-1$ useMultipartForPost.setFont(null); useMultipartForPost.setSelected(false); useBrowserCompatibleMultipartMode = new JCheckBox( JMeterUtils.getResString("use_multipart_mode_browser")); // $NON-NLS-1$ useBrowserCompatibleMultipartMode.setFont(null); useBrowserCompatibleMultipartMode .setSelected(HTTPSamplerBase.BROWSER_COMPATIBLE_MULTIPART_MODE_DEFAULT); } JPanel pathPanel = new HorizontalPanel(); pathPanel.add(label); pathPanel.add(path); JPanel panel = new JPanel(); panel.setLayout(new BoxLayout(panel, BoxLayout.Y_AXIS)); panel.add(pathPanel); if (notConfigOnly) { JPanel optionPanel = new JPanel(new FlowLayout(FlowLayout.LEFT)); optionPanel.setFont(FONT_SMALL); // all sub-components with setFont(null) inherit this font optionPanel.add(autoRedirects); optionPanel.add(followRedirects); optionPanel.add(useKeepAlive); optionPanel.add(useMultipartForPost); optionPanel.add(useBrowserCompatibleMultipartMode); optionPanel.setMinimumSize(optionPanel.getPreferredSize()); panel.add(optionPanel); } return panel; }