Search in sources :

Example 11 with JToggleButton

use of javax.swing.JToggleButton in project jdk8u_jdk by JetBrains.

the class Test6817933 method main.

public static void main(String[] args) throws Exception {
    try {
        UIManager.setLookAndFeel("com.sun.java.swing.plaf.windows.WindowsLookAndFeel");
    } catch (Exception exception) {
        exception.printStackTrace();
        // ignore test on non-Windows machines
        return;
    }
    SwingUtilities.invokeAndWait(new Runnable() {

        public void run() {
            StyleSheet css = new StyleSheet();
            css.addRule(STYLE);
            HTMLEditorKit kit = new HTMLEditorKit();
            kit.setStyleSheet(css);
            JFrame frame = new JFrame(STYLE);
            frame.add(chooser = new JFileChooser());
            frame.setSize(640, 480);
            frame.setVisible(true);
        }
    });
    SunToolkit toolkit = (SunToolkit) Toolkit.getDefaultToolkit();
    toolkit.realSync(500);
    SwingUtilities.invokeAndWait(new Runnable() {

        public void run() {
            try {
                JToggleButton button = get(JToggleButton.class, get(WindowsPlacesBar.class, chooser));
                int width = button.getWidth();
                int height = button.getHeight() / 3;
                Point point = new Point(0, height * 2);
                SwingUtilities.convertPointToScreen(point, button);
                width += point.x;
                height += point.y;
                int count = 0;
                Robot robot = new Robot();
                for (int x = point.x; x < width; x++) {
                    for (int y = point.y; y < height; y++) {
                        count += COLOR.equals(robot.getPixelColor(x, y)) ? -2 : 1;
                    }
                }
                if (count < 0) {
                    throw new Exception("TEST ERROR: a lot of red pixels");
                }
            } catch (Exception exception) {
                throw new Error(exception);
            } finally {
                SwingUtilities.getWindowAncestor(chooser).dispose();
            }
        }
    });
}
Also used : StyleSheet(javax.swing.text.html.StyleSheet) JFileChooser(javax.swing.JFileChooser) JToggleButton(javax.swing.JToggleButton) JFrame(javax.swing.JFrame) SunToolkit(sun.awt.SunToolkit) HTMLEditorKit(javax.swing.text.html.HTMLEditorKit) Point(java.awt.Point) Robot(java.awt.Robot)

Example 12 with JToggleButton

use of javax.swing.JToggleButton in project jdk8u_jdk by JetBrains.

the class DimensionEncapsulation method run.

@Override
public void run() {
    runTest(new Panel());
    runTest(new Button());
    runTest(new Checkbox());
    runTest(new Canvas());
    runTest(new Choice());
    runTest(new Label());
    runTest(new Scrollbar());
    runTest(new TextArea());
    runTest(new TextField());
    runTest(new Dialog(new JFrame()));
    runTest(new Frame());
    runTest(new Window(new JFrame()));
    runTest(new FileDialog(new JFrame()));
    runTest(new List());
    runTest(new ScrollPane());
    runTest(new JFrame());
    runTest(new JDialog(new JFrame()));
    runTest(new JWindow(new JFrame()));
    runTest(new JLabel("hi"));
    runTest(new JMenu());
    runTest(new JTree());
    runTest(new JTable());
    runTest(new JMenuItem());
    runTest(new JCheckBoxMenuItem());
    runTest(new JToggleButton());
    runTest(new JSpinner());
    runTest(new JSlider());
    runTest(Box.createVerticalBox());
    runTest(Box.createHorizontalBox());
    runTest(new JTextField());
    runTest(new JTextArea());
    runTest(new JTextPane());
    runTest(new JPasswordField());
    runTest(new JFormattedTextField());
    runTest(new JEditorPane());
    runTest(new JButton());
    runTest(new JColorChooser());
    runTest(new JFileChooser());
    runTest(new JCheckBox());
    runTest(new JInternalFrame());
    runTest(new JDesktopPane());
    runTest(new JTableHeader());
    runTest(new JLayeredPane());
    runTest(new JRootPane());
    runTest(new JMenuBar());
    runTest(new JOptionPane());
    runTest(new JRadioButton());
    runTest(new JRadioButtonMenuItem());
    runTest(new JPopupMenu());
    //runTest(new JScrollBar()); --> don't test defines max and min in
    // terms of preferred
    runTest(new JScrollPane());
    runTest(new JViewport());
    runTest(new JSplitPane());
    runTest(new JTabbedPane());
    runTest(new JToolBar());
    runTest(new JSeparator());
    runTest(new JProgressBar());
    if (!failures.isEmpty()) {
        System.out.println("These classes failed");
        for (final Component failure : failures) {
            System.out.println(failure.getClass());
        }
        throw new RuntimeException("Test failed");
    }
}
Also used : JDesktopPane(javax.swing.JDesktopPane) Choice(java.awt.Choice) JTextArea(javax.swing.JTextArea) TextArea(java.awt.TextArea) JTextArea(javax.swing.JTextArea) Label(java.awt.Label) JLabel(javax.swing.JLabel) JTableHeader(javax.swing.table.JTableHeader) JToggleButton(javax.swing.JToggleButton) JToggleButton(javax.swing.JToggleButton) Button(java.awt.Button) JRadioButton(javax.swing.JRadioButton) JButton(javax.swing.JButton) JFrame(javax.swing.JFrame) Checkbox(java.awt.Checkbox) JDialog(javax.swing.JDialog) FileDialog(java.awt.FileDialog) Dialog(java.awt.Dialog) JTextField(javax.swing.JTextField) TextField(java.awt.TextField) JFormattedTextField(javax.swing.JFormattedTextField) JSlider(javax.swing.JSlider) ArrayList(java.util.ArrayList) List(java.awt.List) Canvas(java.awt.Canvas) JWindow(javax.swing.JWindow) JRadioButtonMenuItem(javax.swing.JRadioButtonMenuItem) JOptionPane(javax.swing.JOptionPane) JCheckBoxMenuItem(javax.swing.JCheckBoxMenuItem) JCheckBox(javax.swing.JCheckBox) JTree(javax.swing.JTree) JFileChooser(javax.swing.JFileChooser) JPasswordField(javax.swing.JPasswordField) ScrollPane(java.awt.ScrollPane) JScrollPane(javax.swing.JScrollPane) JTable(javax.swing.JTable) JSpinner(javax.swing.JSpinner) JSplitPane(javax.swing.JSplitPane) JColorChooser(javax.swing.JColorChooser) JInternalFrame(javax.swing.JInternalFrame) JDialog(javax.swing.JDialog) JFrame(javax.swing.JFrame) Frame(java.awt.Frame) JInternalFrame(javax.swing.JInternalFrame) JRadioButton(javax.swing.JRadioButton) JLayeredPane(javax.swing.JLayeredPane) JTabbedPane(javax.swing.JTabbedPane) JButton(javax.swing.JButton) JProgressBar(javax.swing.JProgressBar) JTextField(javax.swing.JTextField) JSeparator(javax.swing.JSeparator) JTextPane(javax.swing.JTextPane) JMenuItem(javax.swing.JMenuItem) Component(java.awt.Component) Scrollbar(java.awt.Scrollbar) Window(java.awt.Window) JWindow(javax.swing.JWindow) JScrollPane(javax.swing.JScrollPane) JViewport(javax.swing.JViewport) JFormattedTextField(javax.swing.JFormattedTextField) JLabel(javax.swing.JLabel) JToolBar(javax.swing.JToolBar) JPopupMenu(javax.swing.JPopupMenu) Panel(java.awt.Panel) JEditorPane(javax.swing.JEditorPane) JRootPane(javax.swing.JRootPane) FileDialog(java.awt.FileDialog) JMenu(javax.swing.JMenu) JMenuBar(javax.swing.JMenuBar)

Example 13 with JToggleButton

use of javax.swing.JToggleButton in project aima-java by aimacode.

the class AgentAppFrame method initComponents.

/** Assembles the inner structure of the frame. */
private void initComponents() {
    addWindowListener(new java.awt.event.WindowAdapter() {

        @Override
        public void windowClosing(java.awt.event.WindowEvent evt) {
            System.exit(0);
        }
    });
    JPanel contentPanel = new JPanel();
    contentPanel.setLayout(new BorderLayout());
    getContentPane().add(contentPanel, BorderLayout.CENTER);
    toolbar = new JToolBar();
    toolbar.setFloatable(false);
    selectors = new SelectorContainer();
    toolbar.add(Box.createHorizontalGlue());
    clearButton = new JButton("Clear");
    clearButton.setToolTipText("Clear Views");
    clearButton.addActionListener(actionListener);
    toolbar.add(clearButton);
    prepareButton = new JButton("Prepare");
    prepareButton.setToolTipText("Prepare Simulation");
    prepareButton.addActionListener(actionListener);
    toolbar.add(prepareButton);
    runButton = new JButton("Run");
    runButton.setToolTipText("Run Simulation");
    runButton.addActionListener(actionListener);
    toolbar.add(runButton);
    stepButton = new JButton("Step");
    stepButton.setToolTipText("Execute Simulation Step");
    stepButton.addActionListener(actionListener);
    toolbar.add(stepButton);
    pauseButton = new JToggleButton("Pause");
    pauseButton.setToolTipText("Pause Simulation");
    pauseButton.addActionListener(actionListener);
    toolbar.add(pauseButton);
    contentPanel.add(toolbar, java.awt.BorderLayout.NORTH);
    messageLogger = new MessageLoggerPanel();
    centerPane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT);
    centerPane.add(JSplitPane.RIGHT, messageLogger);
    centerPane.setDividerSize(5);
    centerPane.setResizeWeight(0.7);
    contentPanel.add(centerPane, BorderLayout.CENTER);
    JPanel statusPanel = new JPanel(new BorderLayout());
    statusLabel = new JLabel("");
    // BevelBorder
    statusLabel.setBorder(new javax.swing.border.EtchedBorder());
    statusPanel.add(statusLabel, BorderLayout.CENTER);
    cancelButton = new JButton("Cancel");
    cancelButton.setToolTipText("Cancel Simulation");
    cancelButton.addActionListener(actionListener);
    cancelButton.setPreferredSize(new java.awt.Dimension(80, 20));
    cancelButton.setBorder(new javax.swing.border.EtchedBorder());
    statusPanel.add(cancelButton, BorderLayout.EAST);
    contentPanel.add(statusPanel, BorderLayout.SOUTH);
}
Also used : JPanel(javax.swing.JPanel) JButton(javax.swing.JButton) JLabel(javax.swing.JLabel) JToolBar(javax.swing.JToolBar) BorderLayout(java.awt.BorderLayout) JToggleButton(javax.swing.JToggleButton) JSplitPane(javax.swing.JSplitPane)

Example 14 with JToggleButton

use of javax.swing.JToggleButton in project jadx by skylot.

the class MainWindow method initMenuAndToolbar.

private void initMenuAndToolbar() {
    Action openAction = new AbstractAction(NLS.str("file.open"), ICON_OPEN) {

        @Override
        public void actionPerformed(ActionEvent e) {
            openFile();
        }
    };
    openAction.putValue(Action.SHORT_DESCRIPTION, NLS.str("file.open"));
    openAction.putValue(Action.ACCELERATOR_KEY, getKeyStroke(KeyEvent.VK_O, KeyEvent.CTRL_DOWN_MASK));
    Action saveAllAction = new AbstractAction(NLS.str("file.save_all"), ICON_SAVE_ALL) {

        @Override
        public void actionPerformed(ActionEvent e) {
            saveAll(false);
        }
    };
    saveAllAction.putValue(Action.SHORT_DESCRIPTION, NLS.str("file.save_all"));
    saveAllAction.putValue(Action.ACCELERATOR_KEY, getKeyStroke(KeyEvent.VK_S, KeyEvent.CTRL_DOWN_MASK));
    Action exportAction = new AbstractAction(NLS.str("file.export_gradle"), ICON_EXPORT) {

        @Override
        public void actionPerformed(ActionEvent e) {
            saveAll(true);
        }
    };
    exportAction.putValue(Action.SHORT_DESCRIPTION, NLS.str("file.export_gradle"));
    exportAction.putValue(Action.ACCELERATOR_KEY, getKeyStroke(KeyEvent.VK_E, KeyEvent.CTRL_DOWN_MASK));
    JMenu recentFiles = new JMenu(NLS.str("menu.recent_files"));
    recentFiles.addMenuListener(new RecentFilesMenuListener(recentFiles));
    Action prefsAction = new AbstractAction(NLS.str("menu.preferences"), ICON_PREF) {

        @Override
        public void actionPerformed(ActionEvent e) {
            new JadxSettingsWindow(MainWindow.this, settings).setVisible(true);
        }
    };
    prefsAction.putValue(Action.SHORT_DESCRIPTION, NLS.str("menu.preferences"));
    prefsAction.putValue(Action.ACCELERATOR_KEY, getKeyStroke(KeyEvent.VK_P, KeyEvent.CTRL_DOWN_MASK | KeyEvent.SHIFT_DOWN_MASK));
    Action exitAction = new AbstractAction(NLS.str("file.exit"), ICON_CLOSE) {

        @Override
        public void actionPerformed(ActionEvent e) {
            dispose();
        }
    };
    isFlattenPackage = settings.isFlattenPackage();
    flatPkgMenuItem = new JCheckBoxMenuItem(NLS.str("menu.flatten"), ICON_FLAT_PKG);
    flatPkgMenuItem.setState(isFlattenPackage);
    Action syncAction = new AbstractAction(NLS.str("menu.sync"), ICON_SYNC) {

        @Override
        public void actionPerformed(ActionEvent e) {
            syncWithEditor();
        }
    };
    syncAction.putValue(Action.SHORT_DESCRIPTION, NLS.str("menu.sync"));
    syncAction.putValue(Action.ACCELERATOR_KEY, getKeyStroke(KeyEvent.VK_T, KeyEvent.CTRL_DOWN_MASK));
    Action textSearchAction = new AbstractAction(NLS.str("menu.text_search"), ICON_SEARCH) {

        @Override
        public void actionPerformed(ActionEvent e) {
            new SearchDialog(MainWindow.this, EnumSet.of(SearchOptions.CODE)).setVisible(true);
        }
    };
    textSearchAction.putValue(Action.SHORT_DESCRIPTION, NLS.str("menu.text_search"));
    textSearchAction.putValue(Action.ACCELERATOR_KEY, getKeyStroke(KeyEvent.VK_F, KeyEvent.CTRL_DOWN_MASK | KeyEvent.SHIFT_DOWN_MASK));
    Action clsSearchAction = new AbstractAction(NLS.str("menu.class_search"), ICON_FIND) {

        @Override
        public void actionPerformed(ActionEvent e) {
            new SearchDialog(MainWindow.this, EnumSet.of(SearchOptions.CLASS)).setVisible(true);
        }
    };
    clsSearchAction.putValue(Action.SHORT_DESCRIPTION, NLS.str("menu.class_search"));
    clsSearchAction.putValue(Action.ACCELERATOR_KEY, getKeyStroke(KeyEvent.VK_N, KeyEvent.CTRL_DOWN_MASK));
    Action deobfAction = new AbstractAction(NLS.str("preferences.deobfuscation"), ICON_DEOBF) {

        @Override
        public void actionPerformed(ActionEvent e) {
            toggleDeobfuscation();
        }
    };
    deobfAction.putValue(Action.SHORT_DESCRIPTION, NLS.str("preferences.deobfuscation"));
    deobfAction.putValue(Action.ACCELERATOR_KEY, getKeyStroke(KeyEvent.VK_D, KeyEvent.CTRL_DOWN_MASK | KeyEvent.ALT_DOWN_MASK));
    deobfToggleBtn = new JToggleButton(deobfAction);
    deobfToggleBtn.setSelected(settings.isDeobfuscationOn());
    deobfToggleBtn.setText("");
    deobfMenuItem = new JCheckBoxMenuItem(deobfAction);
    deobfMenuItem.setState(settings.isDeobfuscationOn());
    Action logAction = new AbstractAction(NLS.str("menu.log"), ICON_LOG) {

        @Override
        public void actionPerformed(ActionEvent e) {
            new LogViewer(settings).setVisible(true);
        }
    };
    logAction.putValue(Action.SHORT_DESCRIPTION, NLS.str("menu.log"));
    logAction.putValue(Action.ACCELERATOR_KEY, getKeyStroke(KeyEvent.VK_L, KeyEvent.CTRL_DOWN_MASK | KeyEvent.SHIFT_DOWN_MASK));
    Action aboutAction = new AbstractAction(NLS.str("menu.about")) {

        @Override
        public void actionPerformed(ActionEvent e) {
            new AboutDialog().setVisible(true);
        }
    };
    Action backAction = new AbstractAction(NLS.str("nav.back"), ICON_BACK) {

        @Override
        public void actionPerformed(ActionEvent e) {
            tabbedPane.navBack();
        }
    };
    backAction.putValue(Action.SHORT_DESCRIPTION, NLS.str("nav.back"));
    backAction.putValue(Action.ACCELERATOR_KEY, getKeyStroke(KeyEvent.VK_LEFT, KeyEvent.CTRL_DOWN_MASK | KeyEvent.ALT_DOWN_MASK));
    Action forwardAction = new AbstractAction(NLS.str("nav.forward"), ICON_FORWARD) {

        @Override
        public void actionPerformed(ActionEvent e) {
            tabbedPane.navForward();
        }
    };
    forwardAction.putValue(Action.SHORT_DESCRIPTION, NLS.str("nav.forward"));
    forwardAction.putValue(Action.ACCELERATOR_KEY, getKeyStroke(KeyEvent.VK_RIGHT, KeyEvent.CTRL_DOWN_MASK | KeyEvent.ALT_DOWN_MASK));
    JMenu file = new JMenu(NLS.str("menu.file"));
    file.setMnemonic(KeyEvent.VK_F);
    file.add(openAction);
    file.add(saveAllAction);
    file.add(exportAction);
    file.addSeparator();
    file.add(recentFiles);
    file.addSeparator();
    file.add(prefsAction);
    file.addSeparator();
    file.add(exitAction);
    JMenu view = new JMenu(NLS.str("menu.view"));
    view.setMnemonic(KeyEvent.VK_V);
    view.add(flatPkgMenuItem);
    view.add(syncAction);
    JMenu nav = new JMenu(NLS.str("menu.navigation"));
    nav.setMnemonic(KeyEvent.VK_N);
    nav.add(textSearchAction);
    nav.add(clsSearchAction);
    nav.addSeparator();
    nav.add(backAction);
    nav.add(forwardAction);
    JMenu tools = new JMenu(NLS.str("menu.tools"));
    tools.setMnemonic(KeyEvent.VK_T);
    tools.add(deobfMenuItem);
    tools.add(logAction);
    JMenu help = new JMenu(NLS.str("menu.help"));
    help.setMnemonic(KeyEvent.VK_H);
    help.add(aboutAction);
    JMenuBar menuBar = new JMenuBar();
    menuBar.add(file);
    menuBar.add(view);
    menuBar.add(nav);
    menuBar.add(tools);
    menuBar.add(help);
    setJMenuBar(menuBar);
    flatPkgButton = new JToggleButton(ICON_FLAT_PKG);
    flatPkgButton.setSelected(isFlattenPackage);
    ActionListener flatPkgAction = new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e) {
            toggleFlattenPackage();
        }
    };
    flatPkgMenuItem.addActionListener(flatPkgAction);
    flatPkgButton.addActionListener(flatPkgAction);
    flatPkgButton.setToolTipText(NLS.str("menu.flatten"));
    updateLink = new Link("", JadxUpdate.JADX_RELEASES_URL);
    updateLink.setVisible(false);
    JToolBar toolbar = new JToolBar();
    toolbar.setFloatable(false);
    toolbar.add(openAction);
    toolbar.add(saveAllAction);
    toolbar.add(exportAction);
    toolbar.addSeparator();
    toolbar.add(syncAction);
    toolbar.add(flatPkgButton);
    toolbar.addSeparator();
    toolbar.add(textSearchAction);
    toolbar.add(clsSearchAction);
    toolbar.addSeparator();
    toolbar.add(backAction);
    toolbar.add(forwardAction);
    toolbar.addSeparator();
    toolbar.add(deobfToggleBtn);
    toolbar.addSeparator();
    toolbar.add(logAction);
    toolbar.addSeparator();
    toolbar.add(prefsAction);
    toolbar.addSeparator();
    toolbar.add(Box.createHorizontalGlue());
    toolbar.add(updateLink);
    mainPanel.add(toolbar, BorderLayout.NORTH);
}
Also used : AbstractAction(javax.swing.AbstractAction) Action(javax.swing.Action) ActionEvent(java.awt.event.ActionEvent) JadxSettingsWindow(jadx.gui.settings.JadxSettingsWindow) JToolBar(javax.swing.JToolBar) JCheckBoxMenuItem(javax.swing.JCheckBoxMenuItem) JToggleButton(javax.swing.JToggleButton) ActionListener(java.awt.event.ActionListener) AbstractAction(javax.swing.AbstractAction) JMenu(javax.swing.JMenu) JMenuBar(javax.swing.JMenuBar) Link(jadx.gui.utils.Link)

Example 15 with JToggleButton

use of javax.swing.JToggleButton in project jgnash by ccavanaugh.

the class DynamicJasperReportPanel method initializeUI.

private void initializeUI() {
    GridBagConstraints gridBagConstraints;
    JToolBar toolBar = new JToolBar();
    firstButton = new JButton();
    previousButton = new JButton();
    nextButton = new JButton();
    lastButton = new JButton();
    actualSizeButton = new JToggleButton();
    fitPageButton = new JToggleButton();
    fitWidthButton = new JToggleButton();
    zoomInButton = new JButton();
    DefaultComboBoxModel<String> zoomModel = new DefaultComboBoxModel<>();
    for (int z : ZOOM) {
        zoomModel.addElement(z + "%");
    }
    zoomComboBox = new JComboBox<>(zoomModel);
    DefaultComboBoxModel<Integer> fontModel = new DefaultComboBoxModel<>();
    for (int i = 0; i <= 10; i++) {
        fontModel.addElement(5 + i);
    }
    fontSizeComboBox = new JComboBox<>(fontModel);
    fontSizeComboBox.setToolTipText(ResourceUtils.getString("ToolTip.FontSize"));
    fontSizeComboBox.setSelectedItem(report.getBaseFontSize());
    fontSizeComboBox.addActionListener(this);
    zoomOutButton = new JButton();
    mainPanel = new JPanel();
    JScrollPane scrollPane = new JScrollPane();
    scrollPanePanel = new JPanel();
    pageGluePanel = new JPanel();
    JPanel pagePanel = new JPanel();
    JPanel shadowPanel1 = new JPanel();
    JPanel shadowPanel2 = new JPanel();
    JPanel shadowPanel3 = new JPanel();
    JPanel shadowPanel4 = new JPanel();
    JPanel shadowPanel5 = new JPanel();
    setLayout(new BorderLayout());
    toolBar.setFloatable(false);
    toolBar.setRollover(true);
    saveButton = new JButton(new ImageIcon(getClass().getResource("/jgnash/resource/document-save-as.png")));
    saveButton.setToolTipText(resourceBundle.getString("save"));
    saveButton.setFocusable(false);
    saveButton.addActionListener(this);
    toolBar.add(saveButton);
    printButton = new JButton(new ImageIcon(getClass().getResource("/jgnash/resource/document-print.png")));
    printButton.setToolTipText(resourceBundle.getString("print"));
    printButton.setFocusable(false);
    printButton.addActionListener(this);
    toolBar.add(printButton);
    toolBar.add(new JToolBar.Separator());
    pageSetupButton = new JButton(new ImageIcon(getClass().getResource("/jgnash/resource/document-properties.png")));
    pageSetupButton.setToolTipText(ResourceUtils.getString("ToolTip.PageSetup"));
    pageSetupButton.setFocusable(false);
    pageSetupButton.addActionListener(this);
    toolBar.add(pageSetupButton);
    fontSizeComboBox.setMaximumSize(new Dimension(50, pageSetupButton.getMinimumSize().height));
    fontSizeComboBox.setMinimumSize(new Dimension(50, pageSetupButton.getMinimumSize().height));
    fontSizeComboBox.setPreferredSize(new Dimension(50, pageSetupButton.getPreferredSize().height));
    toolBar.add(fontSizeComboBox);
    toolBar.add(new JToolBar.Separator());
    firstButton.setIcon(new ImageIcon(getClass().getResource("/jgnash/resource/go-first.png")));
    firstButton.setToolTipText(resourceBundle.getString("first.page"));
    firstButton.setFocusable(false);
    firstButton.setEnabled(false);
    firstButton.addActionListener(this);
    toolBar.add(firstButton);
    previousButton.setIcon(new ImageIcon(getClass().getResource("/jgnash/resource/go-previous.png")));
    previousButton.setToolTipText(resourceBundle.getString("previous.page"));
    previousButton.setFocusable(false);
    previousButton.setEnabled(false);
    previousButton.addActionListener(this);
    toolBar.add(previousButton);
    nextButton.setIcon(new ImageIcon(getClass().getResource("/jgnash/resource/go-next.png")));
    nextButton.setToolTipText(resourceBundle.getString("next.page"));
    nextButton.setFocusable(false);
    nextButton.setEnabled(false);
    nextButton.addActionListener(this);
    toolBar.add(nextButton);
    lastButton.setIcon(new ImageIcon(getClass().getResource("/jgnash/resource/go-last.png")));
    lastButton.setToolTipText(resourceBundle.getString("last.page"));
    lastButton.setFocusable(false);
    lastButton.setEnabled(false);
    lastButton.addActionListener(this);
    toolBar.add(lastButton);
    toolBar.add(new JToolBar.Separator());
    actualSizeButton.setIcon(new ImageIcon(getClass().getResource("/net/sf/jasperreports/view/images/actualsize.GIF")));
    actualSizeButton.setToolTipText(resourceBundle.getString("actual.size"));
    actualSizeButton.setFocusable(false);
    actualSizeButton.addActionListener(this);
    toolBar.add(actualSizeButton);
    fitPageButton.setIcon(new ImageIcon(getClass().getResource("/net/sf/jasperreports/view/images/fitpage.GIF")));
    fitPageButton.setToolTipText(resourceBundle.getString("fit.page"));
    fitPageButton.setFocusable(false);
    fitPageButton.addActionListener(this);
    toolBar.add(fitPageButton);
    fitWidthButton.setIcon(new ImageIcon(getClass().getResource("/net/sf/jasperreports/view/images/fitwidth.GIF")));
    fitWidthButton.setToolTipText(resourceBundle.getString("fit.width"));
    fitWidthButton.setFocusable(false);
    fitWidthButton.addActionListener(this);
    toolBar.add(fitWidthButton);
    toolBar.add(new JToolBar.Separator());
    zoomInButton.setIcon(new ImageIcon(getClass().getResource("/jgnash/resource/zoom-in.png")));
    zoomInButton.setToolTipText(resourceBundle.getString("zoom.in"));
    zoomInButton.setFocusable(false);
    zoomInButton.addActionListener(this);
    toolBar.add(zoomInButton);
    zoomComboBox.setEditable(true);
    zoomComboBox.setToolTipText(resourceBundle.getString("zoom.ratio"));
    zoomComboBox.setMaximumSize(new Dimension(90, zoomInButton.getMinimumSize().height));
    zoomComboBox.setMinimumSize(new Dimension(90, zoomInButton.getMinimumSize().height));
    zoomComboBox.setPreferredSize(new Dimension(90, zoomInButton.getPreferredSize().height));
    zoomComboBox.addItemListener(evt -> zoomStateChange());
    zoomComboBox.addActionListener(this);
    toolBar.add(zoomComboBox);
    zoomOutButton.setIcon(new ImageIcon(getClass().getResource("/jgnash/resource/zoom-out.png")));
    zoomOutButton.setToolTipText(resourceBundle.getString("zoom.out"));
    zoomOutButton.setFocusable(false);
    zoomOutButton.addActionListener(this);
    toolBar.add(zoomOutButton);
    JPanel reportController = report.getReportController();
    if (reportController != null) {
        JPanel panel = new JPanel(new BorderLayout());
        panel.add(toolBar, BorderLayout.NORTH);
        panel.add(reportController, BorderLayout.CENTER);
        add(panel, BorderLayout.NORTH);
    } else {
        add(toolBar, BorderLayout.NORTH);
    }
    mainPanel.addComponentListener(new ComponentAdapter() {

        @Override
        public void componentResized(final ComponentEvent evt) {
            pnlMainComponentResized();
        }
    });
    mainPanel.setLayout(new BorderLayout());
    scrollPane.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_ALWAYS);
    scrollPane.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS);
    scrollPanePanel.setLayout(new GridBagLayout());
    pageGluePanel.setLayout(new BorderLayout());
    pagePanel.setLayout(new GridBagLayout());
    spaceHoldPanel = new JPanel();
    spaceHoldPanel.setMinimumSize(new Dimension(5, 5));
    spaceHoldPanel.setOpaque(false);
    spaceHoldPanel.setPreferredSize(new Dimension(5, 5));
    spaceHoldPanel.setLayout(null);
    gridBagConstraints = new GridBagConstraints();
    gridBagConstraints.gridx = 0;
    gridBagConstraints.gridy = 0;
    gridBagConstraints.gridwidth = 2;
    gridBagConstraints.gridheight = 2;
    gridBagConstraints.fill = GridBagConstraints.BOTH;
    pagePanel.add(spaceHoldPanel, gridBagConstraints);
    shadowPanel1.setBackground(java.awt.Color.gray);
    shadowPanel1.setMinimumSize(new Dimension(5, 5));
    shadowPanel1.setPreferredSize(new Dimension(5, 5));
    gridBagConstraints = new GridBagConstraints();
    gridBagConstraints.gridx = 2;
    gridBagConstraints.gridy = 1;
    gridBagConstraints.fill = GridBagConstraints.VERTICAL;
    pagePanel.add(shadowPanel1, gridBagConstraints);
    shadowPanel2.setMinimumSize(new Dimension(5, 5));
    shadowPanel2.setPreferredSize(new Dimension(5, 5));
    gridBagConstraints = new GridBagConstraints();
    gridBagConstraints.gridx = 0;
    gridBagConstraints.gridy = 2;
    pagePanel.add(shadowPanel2, gridBagConstraints);
    shadowPanel3.setBackground(Color.gray);
    shadowPanel3.setMinimumSize(new Dimension(5, 5));
    shadowPanel3.setPreferredSize(new Dimension(5, 5));
    gridBagConstraints = new GridBagConstraints();
    gridBagConstraints.gridx = 1;
    gridBagConstraints.gridy = 2;
    gridBagConstraints.fill = GridBagConstraints.HORIZONTAL;
    pagePanel.add(shadowPanel3, gridBagConstraints);
    shadowPanel4.setBackground(Color.gray);
    shadowPanel4.setMinimumSize(new Dimension(5, 5));
    shadowPanel4.setPreferredSize(new Dimension(5, 5));
    gridBagConstraints = new GridBagConstraints();
    gridBagConstraints.gridx = 2;
    gridBagConstraints.gridy = 2;
    pagePanel.add(shadowPanel4, gridBagConstraints);
    shadowPanel5.setMinimumSize(new Dimension(5, 5));
    shadowPanel5.setPreferredSize(new Dimension(5, 5));
    gridBagConstraints = new GridBagConstraints();
    gridBagConstraints.gridx = 2;
    gridBagConstraints.gridy = 0;
    pagePanel.add(shadowPanel5, gridBagConstraints);
    pageRenderer = new PageRenderer(this);
    pageRenderer.setBackground(Color.white);
    pageRenderer.setBorder(BorderFactory.createLineBorder(new Color(0, 0, 0)));
    pageRenderer.setOpaque(true);
    gridBagConstraints = new GridBagConstraints();
    gridBagConstraints.gridx = 0;
    gridBagConstraints.gridy = 0;
    gridBagConstraints.gridwidth = 2;
    gridBagConstraints.gridheight = 2;
    gridBagConstraints.fill = GridBagConstraints.BOTH;
    gridBagConstraints.weightx = 1.0;
    gridBagConstraints.weighty = 1.0;
    pagePanel.add(pageRenderer, gridBagConstraints);
    pageGluePanel.add(pagePanel, BorderLayout.CENTER);
    gridBagConstraints = new GridBagConstraints();
    gridBagConstraints.insets = new Insets(5, 5, 5, 5);
    scrollPanePanel.add(pageGluePanel, gridBagConstraints);
    scrollPane.setViewportView(scrollPanePanel);
    mainPanel.add(scrollPane, BorderLayout.CENTER);
    add(mainPanel, BorderLayout.CENTER);
    zoomComboBox.setSelectedIndex(DEFAULT_ZOOM_INDEX);
}
Also used : JScrollPane(javax.swing.JScrollPane) JPanel(javax.swing.JPanel) ImageIcon(javax.swing.ImageIcon) GridBagConstraints(java.awt.GridBagConstraints) Insets(java.awt.Insets) GridBagLayout(java.awt.GridBagLayout) Color(java.awt.Color) JButton(javax.swing.JButton) JToolBar(javax.swing.JToolBar) DefaultComboBoxModel(javax.swing.DefaultComboBoxModel) Dimension(java.awt.Dimension) JasperPrint(net.sf.jasperreports.engine.JasperPrint) JToggleButton(javax.swing.JToggleButton) BorderLayout(java.awt.BorderLayout) ComponentEvent(java.awt.event.ComponentEvent) ComponentAdapter(java.awt.event.ComponentAdapter)

Aggregations

JToggleButton (javax.swing.JToggleButton)59 ActionEvent (java.awt.event.ActionEvent)21 ActionListener (java.awt.event.ActionListener)21 ImageIcon (javax.swing.ImageIcon)20 JPanel (javax.swing.JPanel)19 JLabel (javax.swing.JLabel)16 Dimension (java.awt.Dimension)14 JButton (javax.swing.JButton)13 Insets (java.awt.Insets)11 JScrollPane (javax.swing.JScrollPane)8 ChangeEvent (javax.swing.event.ChangeEvent)8 ChangeListener (javax.swing.event.ChangeListener)8 GridBagLayout (java.awt.GridBagLayout)7 BoxLayout (javax.swing.BoxLayout)7 GridBagConstraints (java.awt.GridBagConstraints)6 JCheckBox (javax.swing.JCheckBox)6 JSlider (javax.swing.JSlider)6 JTabbedPane (javax.swing.JTabbedPane)6 Component (java.awt.Component)5 GridLayout (java.awt.GridLayout)5