com.alee.laf.button.WebToggleButton Java Examples
The following examples show how to use
com.alee.laf.button.WebToggleButton.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: JToolBarExample.java From weblaf with GNU General Public License v3.0 | 6 votes |
@NotNull @Override protected List<? extends JComponent> createPreviewElements () { final JToolBar toolBar = new JToolBar ( SwingConstants.HORIZONTAL ); toolBar.putClientProperty ( StyleId.STYLE_PROPERTY, getStyleId () ); toolBar.add ( new WebButton ( getExampleLanguageKey ( "button1" ) ) ); toolBar.add ( new WebButton ( getExampleLanguageKey ( "button2" ) ) ); toolBar.add ( new WebButton ( getExampleLanguageKey ( "button3" ) ) ); toolBar.addSeparator ( new Dimension ( 10, 10 ) ); final WebToggleButton toggle1 = new WebToggleButton ( DemoIcons.win16, SystemUtils.isWindows () ); final WebToggleButton toggle2 = new WebToggleButton ( DemoIcons.mac16, SystemUtils.isMac () ); final WebToggleButton toggle3 = new WebToggleButton ( DemoIcons.unix16, SystemUtils.isUnix () ); final WebToggleButton toggle4 = new WebToggleButton ( DemoIcons.solaris16, SystemUtils.isSolaris () ); toolBar.add ( new GroupPane ( toggle1, toggle2, toggle3, toggle4 ) ); toolBar.addSeparator ( new Dimension ( 10, 10 ) ); toolBar.add ( new WebLabel ( getExampleLanguageKey ( "label1" ) ) ); toolBar.add ( new WebComboBox ( SampleData.createComboBoxModel () ) ); return CollectionUtils.asList ( toolBar ); }
Example #2
Source File: HeatMapTool.java From weblaf with GNU General Public License v3.0 | 6 votes |
/** * Constructs new {@link HeatMapTool}. * * @param application {@link DemoApplication} */ public HeatMapTool ( final DemoApplication application ) { super ( StyleId.panelTransparent, new BorderLayout ( 0, 0 ) ); // Heat map heatMap = new HeatMap (); // Magnifier glass switcher button final WebToggleButton heatMapButton = new WebToggleButton ( DemoStyles.toolButton, DemoIcons.fire16 ); heatMapButton.setLanguage ( "demo.tool.heatmap" ); heatMapButton.setSelected ( heatMap.isDisplayed () ); heatMapButton.addActionListener ( new ActionListener () { @Override public void actionPerformed ( final ActionEvent e ) { heatMap.displayOrDispose ( application ); } } ); add ( heatMapButton ); }
Example #3
Source File: MethodEditorPanel.java From Cafebabe with GNU General Public License v3.0 | 5 votes |
private WebButtonGroup accessToggleGroup() { // do not change tooltips WebToggleButton private_ = new WebToggleButton(MethodListCellRenderer.pri); private_.setToolTipText("private"); WebToggleButton public_ = new WebToggleButton(MethodListCellRenderer.pub); public_.setToolTipText("public"); WebToggleButton protected_ = new WebToggleButton(MethodListCellRenderer.pro); protected_.setToolTipText("protected"); WebToggleButton static_ = new WebToggleButton(MethodListCellRenderer.stat); static_.setToolTipText("static"); WebToggleButton final_ = new WebToggleButton(MethodListCellRenderer.fin); final_.setToolTipText("final"); WebToggleButton abstract_ = new WebToggleButton(MethodListCellRenderer.abs); abstract_.setToolTipText("abstract"); WebToggleButton native_ = new WebToggleButton(MethodListCellRenderer.nat); native_.setToolTipText("native"); WebToggleButton synchronized_ = new WebToggleButton(MethodListCellRenderer.syn); synchronized_.setToolTipText("synchronized"); WebToggleButton synthetic_ = new WebToggleButton(MethodListCellRenderer.synth); synthetic_.setToolTipText("synthetic"); private_.addActionListener(l -> { public_.setSelected(false); protected_.setSelected(false); }); public_.addActionListener(l -> { protected_.setSelected(false); private_.setSelected(false); }); protected_.addActionListener(l -> { public_.setSelected(false); private_.setSelected(false); }); WebButtonGroup accessGroup = new WebButtonGroup(false, private_, public_, protected_, static_, final_, abstract_, native_, synchronized_, synthetic_); accessGroup.setButtonsDrawFocus(false); return accessGroup; }
Example #4
Source File: MethodEditorPanel.java From Cafebabe with GNU General Public License v3.0 | 5 votes |
public void editMethod(MethodNode method) { this.method = method; this.name.setText(method.name); for (Field f : Opcodes.class.getDeclaredFields()) { try { if (f.getName().startsWith("ACC_")) { int acc = f.getInt(null); String accName = f.getName().substring(4).toLowerCase(); for (Component c : access.getComponents()) { WebToggleButton tb = (WebToggleButton) c; if (tb.getToolTipText().equals(accName)) { tb.setSelected((method.access & acc) != 0); break; } } } } catch (Exception e) { e.printStackTrace(); } } this.arguments.setText(Descriptors.getDisplayTypeEditable(method.desc.split("\\)")[0].substring(1))); this.returns.setText(Descriptors.getDisplayTypeEditable(method.desc.split("\\)")[1])); if (method.signature != null) { hasSignature.setSelected(true); this.signature.setText(method.signature); } else { hasSignature.setSelected(false); this.signature.setText(""); } this.exceptions.setText(String.join(", ", method.exceptions)); }
Example #5
Source File: ClassEditorPanel.java From Cafebabe with GNU General Public License v3.0 | 5 votes |
private WebButtonGroup accessToggleGroup() { // do not change tooltips WebToggleButton private_ = new WebToggleButton(MethodListCellRenderer.pri); private_.setToolTipText("private"); WebToggleButton public_ = new WebToggleButton(MethodListCellRenderer.pub); public_.setToolTipText("public"); WebToggleButton protected_ = new WebToggleButton(MethodListCellRenderer.pro); protected_.setToolTipText("protected"); WebToggleButton abstract_ = new WebToggleButton(MethodListCellRenderer.abs); abstract_.setToolTipText("abstract"); WebToggleButton final_ = new WebToggleButton(MethodListCellRenderer.fin); final_.setToolTipText("final"); WebToggleButton synthetic_ = new WebToggleButton(MethodListCellRenderer.synth); synthetic_.setToolTipText("synthetic"); private_.addActionListener(l -> { public_.setSelected(false); protected_.setSelected(false); }); public_.addActionListener(l -> { protected_.setSelected(false); private_.setSelected(false); }); protected_.addActionListener(l -> { public_.setSelected(false); private_.setSelected(false); }); WebButtonGroup accessGroup = new WebButtonGroup(false, private_, public_, protected_, abstract_, final_, synthetic_); accessGroup.setButtonsDrawFocus(false); return accessGroup; }
Example #6
Source File: ClassEditorPanel.java From Cafebabe with GNU General Public License v3.0 | 5 votes |
public void editClass(ClassNode clazz) { this.clazz = clazz; this.name.setText(clazz.name); for (Field f : Opcodes.class.getDeclaredFields()) { try { if (f.getName().startsWith("ACC_")) { int acc = f.getInt(null); String accName = f.getName().substring(4).toLowerCase(); for (Component c : access.getComponents()) { WebToggleButton tb = (WebToggleButton) c; if (tb.getToolTipText().equals(accName)) { tb.setSelected((clazz.access & acc) != 0); break; } } } } catch (Exception e) { e.printStackTrace(); } } this.superName.setText(clazz.superName); this.sourceFile.setText(clazz.sourceFile); this.version.setSelectedItem(clazz.version); if (clazz.signature != null) { hasSignature.setSelected(true); this.signature.setText(clazz.signature); } else { hasSignature.setSelected(false); } }
Example #7
Source File: GroupPaneExample.java From weblaf with GNU General Public License v3.0 | 5 votes |
@NotNull @Override protected List<? extends JComponent> createPreviewElements () { final WebToggleButton b1 = new WebToggleButton ( "First", true ); final WebToggleButton b2 = new WebToggleButton ( "Second" ); final WebToggleButton b3 = new WebToggleButton ( "Third" ); final WebToggleButton b4 = new WebToggleButton ( "Last" ); final GroupPane groupPane = new GroupPane ( getStyleId (), b1, b2, b3, b4 ); SwingUtils.equalizeComponentsWidth ( groupPane.getComponents () ); return CollectionUtils.asList ( groupPane ); }
Example #8
Source File: JMenuBarExample.java From weblaf with GNU General Public License v3.0 | 5 votes |
@NotNull @Override protected List<? extends JComponent> createPreviewElements () { // Menu bar final JMenuBar menuBar = createMenuBar (); // Menu bar in native dialog final WebToggleButton nativeDialog = createDialogButton ( "native", StyleId.dialog ); // Menu bar in decorated dialog final WebToggleButton decoratedDialog = createDialogButton ( "decorated", StyleId.dialogDecorated ); return CollectionUtils.asList ( menuBar, nativeDialog, decoratedDialog ); }
Example #9
Source File: MainFrame.java From desktopclient-java with GNU General Public License v3.0 | 4 votes |
private static WebPanel createListPanel(final WebTable list, String overlayText, WebToggleButton button) { // overlay for empty list WebOverlay listOverlay = new WebOverlay(list); listOverlay.setOverlayMargin(20); final WebTextArea overlayArea = new WebTextArea(); overlayArea.setText(overlayText); overlayArea.setLineWrap(true); overlayArea.setWrapStyleWord(true); overlayArea.setMargin(View.MARGIN_DEFAULT); overlayArea.setFontSize(View.FONT_SIZE_BIG); overlayArea.setEditable(false); BorderPainter<WebTextArea> borderPainter = new BorderPainter<>(Color.LIGHT_GRAY); borderPainter.setRound(15); overlayArea.setPainter(borderPainter); list.getModel().addTableModelListener(new TableModelListener() { @Override public void tableChanged(TableModelEvent e) { overlayArea.setVisible(list.getModel().getRowCount() == 0); } }); overlayArea.setVisible(list.getModel().getRowCount() == 0); listOverlay.addOverlay(overlayArea, SwingConstants.CENTER, SwingConstants.CENTER); WebScrollPane scrollPane = new ComponentUtils.ScrollPane(listOverlay); scrollPane.setDrawBorder(false); // button as overlay button.setOpaque(false); button.setUndecorated(true); WebOverlay chatListOverlay = new WebOverlay(scrollPane, button, SwingConstants.TRAILING, SwingConstants.BOTTOM); chatListOverlay.setOverlayMargin(0, 0, View.GAP_BIG, View.GAP_BIG + SCROLL_BAR_WIDTH); // fixing overlay button paint bug on startup, dont wanna know whats happening here SwingUtils.delayInvokeLater(0, new Runnable() { @Override public void run() { TooltipManager.showOneTimeTooltip(list, new Point(1,1), ""); } }); return chatListOverlay; }
Example #10
Source File: JMenuBarExample.java From weblaf with GNU General Public License v3.0 | 4 votes |
/** * Returns new dialog preview button. * * @param text button text * @param dialogStyleId dialog {@link StyleId} * @return new dialog preview button */ protected WebToggleButton createDialogButton ( final String text, final StyleId dialogStyleId ) { final String showText = getExampleLanguagePrefix () + text; final WebToggleButton showButton = new WebToggleButton ( showText, Icons.external ); showButton.addActionListener ( new ActionListener () { /** * Dialog containing menu bar. */ private WebDialog dialog; @Override public void actionPerformed ( final ActionEvent e ) { if ( dialog == null || !dialog.isVisible () ) { if ( dialog == null ) { dialog = new WebDialog ( dialogStyleId, DemoApplication.getInstance (), getTitle () ); dialog.setJMenuBar ( createMenuBar () ); final String contentText = getExampleLanguagePrefix () + "content"; final WebLabel contentLabel = new WebLabel ( contentText, SwingConstants.CENTER ); dialog.add ( contentLabel.setPreferredSize ( 300, 250 ) ); dialog.setDefaultCloseOperation ( WindowConstants.DISPOSE_ON_CLOSE ); dialog.setModal ( false ); dialog.onClose ( new ComponentEventRunnable () { @Override public void run ( @NotNull final ComponentEvent event ) { if ( showButton.isSelected () ) { showButton.setSelected ( false ); } } } ); } dialog.pack (); dialog.setLocationRelativeTo ( DemoApplication.getInstance () ); dialog.setVisible ( true ); } else { dialog.dispose (); } } } ); return showButton; }
Example #11
Source File: InterfaceInspector.java From weblaf with GNU General Public License v3.0 | 4 votes |
/** * Constructs new {@link InterfaceInspector} for the specified {@link Component} and its childrens tree. * * @param id {@link StyleId} * @param inspected {@link Component} to inspect */ public InterfaceInspector ( @NotNull final StyleId id, @Nullable final Component inspected ) { super ( id ); // Tree scroll final WebScrollPane scrollPane = new WebScrollPane ( StyleId.inspectorScroll.at ( InterfaceInspector.this ) ); scrollPane.setPreferredWidth ( 300 ); // Interface tree tree = new InterfaceTree ( StyleId.inspectorTree.at ( scrollPane ), inspected ); scrollPane.getViewport ().setView ( tree ); // Filtering field final WebTreeFilterField filter = new WebTreeFilterField ( StyleId.inspectorFilter.at ( InterfaceInspector.this ), tree ); // Component inspect behavior final WebToggleButton inspectToggle = new WebToggleButton ( StyleId.inspectorInspect.at ( filter ), Icons.target ); inspectToggle.setRolloverIcon ( Icons.targetHover ); inspectToggle.setSelectedIcon ( Icons.targetSelected ); inspectToggle.setCursor ( Cursor.getDefaultCursor () ); inspectToggle.addHotkey ( Hotkey.CTRL_I ); inspectToggle.addActionListener ( new ActionListener () { @Override public void actionPerformed ( @NotNull final ActionEvent e ) { if ( inspectToggle.isSelected () ) { if ( inspectBehavior == null ) { inspectBehavior = new ComponentInspectBehavior (); } if ( !inspectBehavior.isInstalled () ) { inspectBehavior.install ( inspected, new InspectionListener () { @Override public void inspected ( @NotNull final Component component ) { tree.navigate ( component ); inspectToggle.setSelected ( false ); tree.requestFocusInWindow (); } @Override public void cancelled () { inspectToggle.setSelected ( false ); } } ); } } else { if ( inspectBehavior != null && inspectBehavior.isInstalled () ) { inspectBehavior.uninstall (); } } } } ); filter.setTrailingComponent ( inspectToggle ); // UI composition final WebSeparator separator = new WebSeparator ( StyleId.inspectorSeparator.at ( InterfaceInspector.this ) ); add ( new GroupPanel ( GroupingType.fillLast, 0, false, filter, separator, scrollPane ) ); // Expanding tree root by default tree.expandRoot (); // Visibility behavior new VisibilityBehavior<InterfaceInspector> ( this, true ) { @Override protected void hidden ( @NotNull final InterfaceInspector inspector ) { if ( inspectBehavior != null && inspectBehavior.isInstalled () ) { inspectBehavior.uninstall (); } } }.install (); }
Example #12
Source File: DateCustomizer.java From weblaf with GNU General Public License v3.0 | 2 votes |
/** * Customizes {@link WebToggleButton} representing single {@link Date}. * * @param button {@link WebToggleButton} to customize * @param date {@link Date} */ public void customize ( WebToggleButton button, Date date );