/** Konstruktor */ public HelpWindow(String url) { super("dŽáma – nápověda"); try { UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName()); } catch (Exception e) { System.err.println("Error setting native LAF: " + e); } this.setIconImage(new ImageIcon(getClass().getResource("/resources/icon_help.png")).getImage()); String ourl = ""; if (url.equals("jar")) { ourl = getClass().getResource("/resources/help/index.html").toString(); } else { ourl = url; } try { htmlPane = new JEditorPane(ourl); htmlPane.setEditable(false); htmlPane.addHyperlinkListener(this); this.add(new JScrollPane(htmlPane)); } catch (IOException ioe) { JOptionPane.showMessageDialog( this, "Soubor s nápovědou neexistuje", "D'oh!", JOptionPane.ERROR_MESSAGE); } this.setPreferredSize(new Dimension(600, 600)); this.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE); this.pack(); this.setLocationRelativeTo(null); this.setVisible(true); this.repaint(); }
public static void main(String[] args) { try { UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName()); } catch (Exception e) { System.err.println("Look and feel not set."); } new gui(); }
public static void main(String[] args) { try { UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName()); } catch (Exception e) { String message = "ExceptionWhileSettingSystemLookAndFeel"; Logging.logger().log(java.util.logging.Level.WARNING, message, e); } start("World Wind - elevations demo", AppFrame.class); }
private ActionMap getActionMap() { ActionMap actionMap = (ActionMap) UIManager.get("Grid.actionMap"); if (actionMap == null) { actionMap = createActionMap(); if (actionMap != null) { UIManager.put("Grid.actionMap", actionMap); } } return actionMap; }
protected void installDefaults() { LookAndFeel.installProperty(progressBar, "opaque", Boolean.TRUE); LookAndFeel.installBorder(progressBar, "ProgressBar.border"); LookAndFeel.installColorsAndFont( progressBar, "ProgressBar.background", "ProgressBar.foreground", "ProgressBar.font"); cellLength = UIManager.getInt("ProgressBar.cellLength"); if (cellLength == 0) cellLength = 1; cellSpacing = UIManager.getInt("ProgressBar.cellSpacing"); selectionForeground = UIManager.getColor("ProgressBar.selectionForeground"); selectionBackground = UIManager.getColor("ProgressBar.selectionBackground"); }
protected void installDefaults(JFileChooser fc) { installIcons(fc); installStrings(fc); usesSingleFilePane = UIManager.getBoolean("FileChooser.usesSingleFilePane"); readOnly = UIManager.getBoolean("FileChooser.readOnly"); TransferHandler th = fc.getTransferHandler(); if (th == null || th instanceof UIResource) { fc.setTransferHandler(defaultTransferHandler); } LookAndFeel.installProperty(fc, "opaque", Boolean.FALSE); }
private void setColumnPreferredSize() { for (int i = 0; i < getColumnCount(); i++) { TableColumn column = getColumnModel().getColumn(i); if (i == AbstractVcsLogTableModel.ROOT_COLUMN) { // thin stripe or nothing int rootWidth = myUI.getColorManager().isMultipleRoots() ? ROOT_INDICATOR_WIDTH : 0; // NB: all further instructions and their order are important, otherwise the minimum size // which is less than 15 won't be applied column.setMinWidth(rootWidth); column.setMaxWidth(rootWidth); column.setPreferredWidth(rootWidth); } else if (i == AbstractVcsLogTableModel .COMMIT_COLUMN) { // let commit message occupy as much as possible column.setPreferredWidth(Short.MAX_VALUE); } else if (i == AbstractVcsLogTableModel.AUTHOR_COLUMN) { // detect author with the longest name int contentWidth = calcMaxContentColumnWidth(i, 1000); column.setMinWidth(Math.min(contentWidth, MAX_DEFAULT_AUTHOR_COLUMN_WIDTH)); column.setWidth(column.getMinWidth()); } else if (i == AbstractVcsLogTableModel.DATE_COLUMN) { // all dates have nearly equal sizes Font tableFont = UIManager.getFont("Table.font"); column.setMinWidth( getFontMetrics(tableFont) .stringWidth("mm" + DateFormatUtil.formatDateTime(new Date()))); column.setWidth(column.getMinWidth()); } } }
@Override public int getRowHeight() { if (myRowHeightIsComputing) { return super.getRowHeight(); } if (myRowHeight < 0) { try { myRowHeightIsComputing = true; for (int row = 0; row < getRowCount(); row++) { for (int column = 0; column < getColumnCount(); column++) { final TableCellRenderer renderer = getCellRenderer(row, column); if (renderer != null) { final Object value = getValueAt(row, column); final Component component = renderer.getTableCellRendererComponent(this, value, true, true, row, column); if (component != null) { final Dimension size = component.getPreferredSize(); myRowHeight = Math.max(size.height, myRowHeight); } } } } } finally { myRowHeightIsComputing = false; } } if (myMinRowHeight == null) { myMinRowHeight = getFontMetrics(UIManager.getFont("Label.font")).getHeight(); } return Math.max(myRowHeight, myMinRowHeight); }
private InputMap getInputMap(int condition) { if (condition == JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT) { return (InputMap) UIManager.get("Grid.ancestorInputMap"); } else { return null; } }
public static void main(String[] args) throws Exception { // JFrame.setDefaultLookAndFeelDecorated(true); UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName()); ThumbMaker tm = new ThumbMaker(); tm.pack(); // center window onscreen Dimension window = tm.getSize(); Dimension screen = Toolkit.getDefaultToolkit().getScreenSize(); int w = (screen.width - window.width) / 2; int h = (screen.height - window.height) / 2; tm.setLocation(w, h); tm.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); tm.setVisible(true); }
protected void installDefaults() { LookAndFeel.installColorsAndFont( optionPane, "OptionPane.background", "OptionPane.foreground", "OptionPane.font"); LookAndFeel.installBorder(optionPane, "OptionPane.border"); minimumSize = UIManager.getDimension("OptionPane.minimumSize"); LookAndFeel.installProperty(optionPane, "opaque", Boolean.TRUE); }
public static void createAndShowGUI() { try { UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName()); } catch (ClassNotFoundException | InstantiationException | IllegalAccessException | UnsupportedLookAndFeelException ex) { ex.printStackTrace(); } JFrame frame = new JFrame("@title@"); frame.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE); frame.getContentPane().add(new MainPanel()); frame.pack(); frame.setLocationRelativeTo(null); frame.setVisible(true); }
@SuppressWarnings("OverridableMethodCallInConstructor") Notepad() { super(true); // Trying to set Nimbus look and feel try { for (LookAndFeelInfo info : UIManager.getInstalledLookAndFeels()) { if ("Nimbus".equals(info.getName())) { UIManager.setLookAndFeel(info.getClassName()); break; } } } catch (Exception ignored) { } setBorder(BorderFactory.createEtchedBorder()); setLayout(new BorderLayout()); // create the embedded JTextComponent editor = createEditor(); // Add this as a listener for undoable edits. editor.getDocument().addUndoableEditListener(undoHandler); // install the command table commands = new HashMap<Object, Action>(); Action[] actions = getActions(); for (Action a : actions) { commands.put(a.getValue(Action.NAME), a); } JScrollPane scroller = new JScrollPane(); JViewport port = scroller.getViewport(); port.add(editor); String vpFlag = getProperty("ViewportBackingStore"); if (vpFlag != null) { Boolean bs = Boolean.valueOf(vpFlag); port.setScrollMode(bs ? JViewport.BACKINGSTORE_SCROLL_MODE : JViewport.BLIT_SCROLL_MODE); } JPanel panel = new JPanel(); panel.setLayout(new BorderLayout()); panel.add("North", createToolbar()); panel.add("Center", scroller); add("Center", panel); add("South", createStatusbar()); }
/** * Resets the UI property to a value from the current look and feel. * * @see JComponent#updateUI */ public void updateUI() { setUI((SliderUI) UIManager.getUI(this)); // The labels preferred size may be derived from the font // of the slider, so we must update the UI of the slider first, then // that of labels. This way when setSize is called the right // font is used. updateLabelUIs(); }
public BasicSearchNavigatorUI(JHelpSearchNavigator b) { ImageIcon icon = getImageIcon(b.getNavigatorView()); if (icon != null) { setIcon(icon); } else { setIcon(UIManager.getIcon("SearchNav.icon")); } }
/** _more_ */ private void init() { // L&F may change UIManager.addPropertyChangeListener( new PropertyChangeListener() { public void propertyChange(PropertyChangeEvent e) { if (e.getPropertyName().equals("lookAndFeel")) { SwingUtilities.updateComponentTreeUI(IndependentDialog.this); } } }); }
public HelpFrame(String helpFileName) { super("Help", true, true, true, true); setFrameIcon( (Icon) UIManager.get( "Tree.openIcon")); // PENDING(steve) need more general palce to get this icon setBounds(200, 25, 400, 400); HtmlPane html = new HtmlPane(helpFileName); setContentPane(html); }
protected void installStrings(JFileChooser fc) { super.installStrings(fc); Locale l = fc.getLocale(); enterFileNameLabelText = UIManager.getString("FileChooser.enterFileNameLabelText", l); enterFileNameLabelMnemonic = UIManager.getInt("FileChooser.enterFileNameLabelMnemonic"); filesLabelText = UIManager.getString("FileChooser.filesLabelText", l); filesLabelMnemonic = UIManager.getInt("FileChooser.filesLabelMnemonic"); foldersLabelText = UIManager.getString("FileChooser.foldersLabelText", l); foldersLabelMnemonic = UIManager.getInt("FileChooser.foldersLabelMnemonic"); pathLabelText = UIManager.getString("FileChooser.pathLabelText", l); pathLabelMnemonic = UIManager.getInt("FileChooser.pathLabelMnemonic"); filterLabelText = UIManager.getString("FileChooser.filterLabelText", l); filterLabelMnemonic = UIManager.getInt("FileChooser.filterLabelMnemonic"); }
private int getMnemonic(String key, Locale l) { String value = (String) UIManager.get(key, l); if (value == null) { return 0; } try { return Integer.parseInt(value); } catch (NumberFormatException nfe) { } return 0; }
/** Set the font used to display today's date as text. */ protected void setupTodayFont() { Font font; if (todaysLabel == null) return; // If not null, use what the user gave us if (todayFont != null) { todaysLabel.setFont(todayFont); } else { font = UIManager.getFont("Label.font"); todaysLabel.setFont(font); } }
/** Set the time spinner's font. */ protected void setupTimeFont() { Font font; if (spinner == null) return; // If not null, use what the user gave us if (timeFont != null) { spinner.setFont(timeFont); } else { font = UIManager.getFont("Spinner.font"); spinner.setFont(font); } }
public Component getListCellRendererComponent( JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) { setText(value.toString()); setBackground(isSelected ? list.getSelectionBackground() : list.getBackground()); setForeground(isSelected ? list.getSelectionForeground() : list.getForeground()); setFont(list.getFont()); setBorder( (cellHasFocus) ? UIManager.getBorder("List.focusCellHighlightBorder") : m_noFocusBorder); return this; }
/** Applet initialization */ public void init() { // Get the port to be used String port_str = getParameter("port"); if (port_str != null) { port = Integer.parseInt(port_str); } // Try to use the system look and feel try { UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName()); } catch (Exception e) { } // Create main panel to hold notebook main_panel = new JPanel(); main_panel.setBackground(Color.white); main_panel.setLayout(new BorderLayout()); setContentPane(main_panel); // Create the notebook tabbed_pane = new JTabbedPane(JTabbedPane.TOP); main_panel.add(tabbed_pane, BorderLayout.CENTER); // Add notebook page for default host connection pages = new Vector(); addPage(new SOAPMonitorPage(getCodeBase().getHost())); }
/** Adds a new group to our tree and element model. */ final void addNewGroup() { DefaultTreeModel model = (DefaultTreeModel) this.tree.getModel(); boolean groupSummaryVisibleByDefault = UIManager.getBoolean(GROUP_SUMMARY_VISIBLE_DEFAULT); boolean scopeVisibleByDefault = UIManager.getBoolean(ANALOG_SCOPE_VISIBLE_DEFAULT); int groupCount = this.model.getGroups().size(); String name = String.format("Group %d", Integer.valueOf(groupCount + 1)); // Create model structure... ElementGroup newGroup = this.model.addGroup(name); newGroup.setVisible(true); SignalElement groupSummaryElement = SignalElement.createGroupSummaryElement(newGroup); groupSummaryElement.setEnabled(groupSummaryVisibleByDefault); newGroup.addElement(groupSummaryElement); SignalElement analogScopeElement = SignalElement.createAnalogScopeElement(newGroup); analogScopeElement.setEnabled(scopeVisibleByDefault); newGroup.addElement(analogScopeElement); // Create tree structure... ElementTreeNode rootNode = (ElementTreeNode) model.getRoot(); ElementTreeNode groupNode = new ElementTreeNode(newGroup); rootNode.add(groupNode); groupNode.add(new ElementTreeNode(groupSummaryElement)); groupNode.add(new ElementTreeNode(analogScopeElement)); int index = rootNode.getIndex(groupNode); model.nodesWereInserted(rootNode, new int[] {index}); model.nodeStructureChanged(groupNode); this.tree.expandRow(index); }
/** Set the title's font. */ protected void setupTitleFont() { Font font; if (monthYearLabel == null) return; // If not null, use what the user gave us if (titleFont != null) { monthYearLabel.setFont(titleFont); } // Otherwise, use the L&F default for a label else { font = UIManager.getFont("Label.font"); monthYearLabel.setFont(font); } }
/** {@inheritDoc} */ public void setArmed(boolean b) { if (isMenuItem() && UIManager.getBoolean("MenuItem.disabledAreNavigable")) { if ((isArmed() == b)) { return; } } else { if ((isArmed() == b) || !isEnabled()) { return; } } if (b) { stateMask |= ARMED; } else { stateMask &= ~ARMED; } fireStateChanged(); }
/** Set the day-of-week labels' font. */ protected void setupDayOfWeekFonts() { Font font; if (dayOfWeekLabels == null) return; // If not null, use what the user gave us font = dayOfWeekFont; // Otherwise, use 9/11 of the L&F default for a label if (font == null) { font = UIManager.getFont("Label.font"); font = font.deriveFont((float) (font.getSize2D() * 9.0 / 11.0)); } // Set the day of week labels' font for (int day = 0; day < 7; day++) { dayOfWeekLabels[day].setFont(font); } }
public Component getTableCellRendererComponent( JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) { ChatRoomWrapper chatRoom = (ChatRoomWrapper) value; this.setText(chatRoom.getChatRoomName()); Image chatRoomImage = ImageLoader.getImage(ImageLoader.CHAT_ROOM_16x16_ICON); if (chatRoom.getChatRoom() == null || !chatRoom.getChatRoom().isJoined()) { chatRoomImage = LightGrayFilter.createDisabledImage(chatRoomImage); } this.setIcon(new ImageIcon(chatRoomImage)); this.setFont(this.getFont().deriveFont(Font.PLAIN)); if (isSelected) this.setBackground(table.getSelectionBackground()); else this.setBackground(UIManager.getColor("Table.background")); return this; }
public Component getTableCellRendererComponent( JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) { if (table != null) { JTableHeader header = table.getTableHeader(); if (header != null) { setForeground(header.getForeground()); setBackground(header.getBackground()); setFont(header.getFont()); } } if (isSelected) { setFont(getFont().deriveFont(Font.BOLD)); } setText((value == null) ? "" : value.toString()); setBorder(UIManager.getBorder("TableHeader.cellBorder")); return this; }
public Component getTableCellRendererComponent( JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) { ProtocolProviderService pps = (ProtocolProviderService) value; OperationSetPresence presence = pps.getOperationSet(OperationSetPresence.class); if (presence != null) { byte[] protocolStatusImage = presence.getPresenceStatus().getStatusIcon(); if (protocolStatusImage != null) { this.setIcon(new ImageIcon(protocolStatusImage)); } else { this.setIcon(null); } } this.setText(pps.getAccountID().getDisplayName()); if (isSelected) this.setBackground(table.getSelectionBackground()); else this.setBackground(UIManager.getColor("Table.background")); return this; }