Example usage for javax.swing.border EtchedBorder RAISED

List of usage examples for javax.swing.border EtchedBorder RAISED

Introduction

In this page you can find the example usage for javax.swing.border EtchedBorder RAISED.

Prototype

int RAISED

To view the source code for javax.swing.border EtchedBorder RAISED.

Click Source Link

Document

Raised etched type.

Usage

From source file:ffx.ui.MainPanel.java

/**
 * <p>/*from w  w  w  .j a va  2s .c om*/
 * initialize</p>
 */
public void initialize() {
    if (init) {
        return;
    }
    init = true;
    String dir = System.getProperty("user.dir",
            FileSystemView.getFileSystemView().getDefaultDirectory().getAbsolutePath());
    setCWD(new File(dir));
    locale = new FFXLocale("en", "US");
    JDialog splashScreen = null;
    ClassLoader loader = getClass().getClassLoader();
    if (!GraphicsEnvironment.isHeadless()) {
        // Splash Screen
        JFrame.setDefaultLookAndFeelDecorated(true);
        splashScreen = new JDialog(frame, false);
        ImageIcon logo = new ImageIcon(loader.getResource("ffx/ui/icons/splash.png"));
        JLabel ffxLabel = new JLabel(logo);
        ffxLabel.setBorder(BorderFactory.createEtchedBorder(EtchedBorder.RAISED));
        Container contentpane = splashScreen.getContentPane();
        contentpane.setLayout(new BorderLayout());
        contentpane.add(ffxLabel, BorderLayout.CENTER);
        splashScreen.setUndecorated(true);
        splashScreen.pack();
        Dimension screenDimension = getToolkit().getScreenSize();
        Dimension splashDimension = splashScreen.getSize();
        splashScreen.setLocation((screenDimension.width - splashDimension.width) / 2,
                (screenDimension.height - splashDimension.height) / 2);
        splashScreen.setResizable(false);
        splashScreen.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
        splashScreen.setVisible(true);
        // Make all pop-up Menus Heavyweight so they play nicely with Java3D
        JPopupMenu.setDefaultLightWeightPopupEnabled(false);
    }
    // Create the Root Node
    dataRoot = new MSRoot();
    Border bb = BorderFactory.createEtchedBorder(EtchedBorder.RAISED);
    statusLabel = new JLabel("  ");
    JLabel stepLabel = new JLabel("  ");
    stepLabel.setHorizontalAlignment(JLabel.RIGHT);
    JLabel energyLabel = new JLabel("  ");
    energyLabel.setHorizontalAlignment(JLabel.RIGHT);
    JPanel statusPanel = new JPanel(new GridLayout(1, 3));
    statusPanel.setBorder(bb);
    statusPanel.add(statusLabel);
    statusPanel.add(stepLabel);
    statusPanel.add(energyLabel);
    if (!GraphicsEnvironment.isHeadless()) {
        GraphicsConfigTemplate3D template3D = new GraphicsConfigTemplate3D();
        template3D.setDoubleBuffer(GraphicsConfigTemplate.PREFERRED);
        GraphicsConfiguration gc = GraphicsEnvironment.getLocalGraphicsEnvironment().getDefaultScreenDevice()
                .getBestConfiguration(template3D);
        graphicsCanvas = new GraphicsCanvas(gc, this);
        graphicsPanel = new GraphicsPanel(graphicsCanvas, statusPanel);
    }
    // Initialize various Panels
    hierarchy = new Hierarchy(this);
    hierarchy.setStatus(statusLabel, stepLabel, energyLabel);
    keywordPanel = new KeywordPanel(this);
    modelingPanel = new ModelingPanel(this);
    JPanel treePane = new JPanel(new BorderLayout());
    JScrollPane scrollPane = new JScrollPane(hierarchy, JScrollPane.VERTICAL_SCROLLBAR_ALWAYS,
            JScrollPane.HORIZONTAL_SCROLLBAR_ALWAYS);
    treePane.add(scrollPane, BorderLayout.CENTER);
    tabbedPane = new JTabbedPane();

    ImageIcon graphicsIcon = new ImageIcon(loader.getResource("ffx/ui/icons/monitor.png"));
    ImageIcon keywordIcon = new ImageIcon(loader.getResource("ffx/ui/icons/key.png"));
    ImageIcon modelingIcon = new ImageIcon(loader.getResource("ffx/ui/icons/cog.png"));
    tabbedPane.addTab(locale.getValue("Graphics"), graphicsIcon, graphicsPanel);
    tabbedPane.addTab(locale.getValue("KeywordEditor"), keywordIcon, keywordPanel);
    tabbedPane.addTab(locale.getValue("ModelingCommands"), modelingIcon, modelingPanel);
    tabbedPane.addChangeListener(this);
    splitPane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, false, treePane, tabbedPane);

    /* splitPane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, false,
     treePane, graphicsPanel); */
    splitPane.setResizeWeight(0.25);
    splitPane.setOneTouchExpandable(true);
    setLayout(new BorderLayout());
    add(splitPane, BorderLayout.CENTER);
    if (!GraphicsEnvironment.isHeadless()) {
        mainMenu = new MainMenu(this);
        add(mainMenu.getToolBar(), BorderLayout.NORTH);
        getModelingShell();
        loadPrefs();
        SwingUtilities.updateComponentTreeUI(SwingUtilities.getRoot(this));
        splashScreen.dispose();
    }
}

From source file:de.bwravencl.controllerbuddy.gui.Main.java

private Main() {
    Singleton.start(this, SINGLETON_ID);

    frame = new JFrame();
    frame.addWindowListener(new WindowAdapter() {

        @Override//  w w  w.  ja  va2 s  .co  m
        public void windowClosing(final WindowEvent e) {
            super.windowClosing(e);

            if (showMenuItem != null)
                showMenuItem.setEnabled(true);
        }

        @Override
        public void windowDeiconified(final WindowEvent e) {
            super.windowDeiconified(e);

            if (showMenuItem != null)
                showMenuItem.setEnabled(false);
        }

        @Override
        public void windowIconified(final WindowEvent e) {
            super.windowIconified(e);

            if (showMenuItem != null)
                showMenuItem.setEnabled(true);
        }

        @Override
        public void windowOpened(final WindowEvent e) {
            super.windowOpened(e);

            if (showMenuItem != null)
                showMenuItem.setEnabled(false);
        }

    });

    frame.setBounds(DIALOG_BOUNDS_X, DIALOG_BOUNDS_Y, DIALOG_BOUNDS_WIDTH, DIALOG_BOUNDS_HEIGHT);
    frame.setDefaultCloseOperation(WindowConstants.HIDE_ON_CLOSE);

    final var icons = new ArrayList<Image>();
    for (final var path : ICON_RESOURCE_PATHS) {
        final var icon = new ImageIcon(Main.class.getResource(path));
        icons.add(icon.getImage());
    }
    frame.setIconImages(icons);

    frame.setJMenuBar(menuBar);

    menuBar.add(fileMenu);
    final QuitAction quitAction = new QuitAction();
    fileMenu.add(quitAction);
    menuBar.add(deviceMenu);

    if (windows) {
        menuBar.add(localMenu, 2);

        final var buttonGroupLocalState = new ButtonGroup();
        startLocalRadioButtonMenuItem = new JRadioButtonMenuItem(rb.getString("START_MENU_ITEM"));
        startLocalRadioButtonMenuItem.setAction(new StartLocalAction());
        buttonGroupLocalState.add(startLocalRadioButtonMenuItem);
        localMenu.add(startLocalRadioButtonMenuItem);

        stopLocalRadioButtonMenuItem = new JRadioButtonMenuItem(rb.getString("STOP_MENU_ITEM"));
        stopLocalRadioButtonMenuItem.setAction(new StopLocalAction());
        buttonGroupLocalState.add(stopLocalRadioButtonMenuItem);
        localMenu.add(stopLocalRadioButtonMenuItem);

        menuBar.add(clientMenu);

        final var buttonGroupClientState = new ButtonGroup();

        startClientRadioButtonMenuItem = new JRadioButtonMenuItem(rb.getString("START_MENU_ITEM"));
        startClientRadioButtonMenuItem.setAction(new StartClientAction());
        buttonGroupClientState.add(startClientRadioButtonMenuItem);
        clientMenu.add(startClientRadioButtonMenuItem);

        stopClientRadioButtonMenuItem = new JRadioButtonMenuItem(rb.getString("STOP_MENU_ITEM"));
        stopClientRadioButtonMenuItem.setAction(new StopClientAction());
        buttonGroupClientState.add(stopClientRadioButtonMenuItem);
        clientMenu.add(stopClientRadioButtonMenuItem);
    }

    final var buttonGroupServerState = new ButtonGroup();
    startServerRadioButtonMenuItem = new JRadioButtonMenuItem(rb.getString("START_MENU_ITEM"));
    startServerRadioButtonMenuItem.setAction(new StartServerAction());
    buttonGroupServerState.add(startServerRadioButtonMenuItem);
    serverMenu.add(startServerRadioButtonMenuItem);

    stopServerRadioButtonMenuItem = new JRadioButtonMenuItem(rb.getString("STOP_MENU_ITEM"));
    stopServerRadioButtonMenuItem.setAction(new StopServerAction());
    buttonGroupServerState.add(stopServerRadioButtonMenuItem);
    serverMenu.add(stopServerRadioButtonMenuItem);

    final var helpMenu = new JMenu(rb.getString("HELP_MENU"));
    menuBar.add(helpMenu);
    helpMenu.add(new ShowAboutDialogAction());

    frame.getContentPane().add(tabbedPane);

    settingsPanel = new JPanel();
    settingsPanel.setLayout(new GridBagLayout());

    settingsScrollPane.setViewportView(settingsPanel);
    tabbedPane.addTab(rb.getString("SETTINGS_TAB"), null, settingsScrollPane);

    final var panelGridBagConstraints = new GridBagConstraints(0, GridBagConstraints.RELATIVE, 1, 1, 0.0, 0.0,
            GridBagConstraints.FIRST_LINE_START, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 5);

    final var panelFlowLayout = new FlowLayout(FlowLayout.LEADING, 10, 10);

    final var pollIntervalPanel = new JPanel(panelFlowLayout);
    settingsPanel.add(pollIntervalPanel, panelGridBagConstraints);

    final var pollIntervalLabel = new JLabel(rb.getString("POLL_INTERVAL_LABEL"));
    pollIntervalLabel.setPreferredSize(new Dimension(120, 15));
    pollIntervalPanel.add(pollIntervalLabel);

    final var pollIntervalSpinner = new JSpinner(new SpinnerNumberModel(
            preferences.getInt(PREFERENCES_POLL_INTERVAL, OutputThread.DEFAULT_POLL_INTERVAL), 10, 500, 1));
    final JSpinner.DefaultEditor pollIntervalSpinnerEditor = new JSpinner.NumberEditor(pollIntervalSpinner,
            "#");
    ((DefaultFormatter) pollIntervalSpinnerEditor.getTextField().getFormatter()).setCommitsOnValidEdit(true);
    pollIntervalSpinner.setEditor(pollIntervalSpinnerEditor);
    pollIntervalSpinner.addChangeListener(
            e -> preferences.putInt(PREFERENCES_POLL_INTERVAL, (int) ((JSpinner) e.getSource()).getValue()));
    pollIntervalPanel.add(pollIntervalSpinner);

    if (windows) {
        final var vJoyDirectoryPanel = new JPanel(panelFlowLayout);
        settingsPanel.add(vJoyDirectoryPanel, panelGridBagConstraints);

        final var vJoyDirectoryLabel = new JLabel(rb.getString("VJOY_DIRECTORY_LABEL"));
        vJoyDirectoryLabel.setPreferredSize(new Dimension(120, 15));
        vJoyDirectoryPanel.add(vJoyDirectoryLabel);

        vJoyDirectoryLabel1 = new JLabel(
                preferences.get(PREFERENCES_VJOY_DIRECTORY, VJoyOutputThread.getDefaultInstallationPath()));
        vJoyDirectoryPanel.add(vJoyDirectoryLabel1);

        final var vJoyDirectoryButton = new JButton(new ChangeVJoyDirectoryAction());
        vJoyDirectoryPanel.add(vJoyDirectoryButton);

        final var vJoyDevicePanel = new JPanel(panelFlowLayout);
        settingsPanel.add(vJoyDevicePanel, panelGridBagConstraints);

        final var vJoyDeviceLabel = new JLabel(rb.getString("VJOY_DEVICE_LABEL"));
        vJoyDeviceLabel.setPreferredSize(new Dimension(120, 15));
        vJoyDevicePanel.add(vJoyDeviceLabel);

        final var vJoyDeviceSpinner = new JSpinner(new SpinnerNumberModel(
                preferences.getInt(PREFERENCES_VJOY_DEVICE, VJoyOutputThread.DEFAULT_VJOY_DEVICE), 1, 16, 1));
        final JSpinner.DefaultEditor vJoyDeviceSpinnerEditor = new JSpinner.NumberEditor(vJoyDeviceSpinner,
                "#");
        ((DefaultFormatter) vJoyDeviceSpinnerEditor.getTextField().getFormatter()).setCommitsOnValidEdit(true);
        vJoyDeviceSpinner.setEditor(vJoyDeviceSpinnerEditor);
        vJoyDeviceSpinner.addChangeListener(
                e -> preferences.putInt(PREFERENCES_VJOY_DEVICE, (int) ((JSpinner) e.getSource()).getValue()));
        vJoyDevicePanel.add(vJoyDeviceSpinner);

        final var hostPanel = new JPanel(panelFlowLayout);
        settingsPanel.add(hostPanel, panelGridBagConstraints);

        final var hostLabel = new JLabel(rb.getString("HOST_LABEL"));
        hostLabel.setPreferredSize(new Dimension(120, 15));
        hostPanel.add(hostLabel);

        hostTextField = new JTextField(preferences.get(PREFERENCES_HOST, ClientVJoyOutputThread.DEFAULT_HOST),
                10);
        final var setHostAction = new SetHostAction(hostTextField);
        hostTextField.addActionListener(setHostAction);
        hostTextField.addFocusListener(setHostAction);
        hostPanel.add(hostTextField);
    }

    final var portPanel = new JPanel(panelFlowLayout);
    settingsPanel.add(portPanel, panelGridBagConstraints);

    final var portLabel = new JLabel(rb.getString("PORT_LABEL"));
    portLabel.setPreferredSize(new Dimension(120, 15));
    portPanel.add(portLabel);

    final var portSpinner = new JSpinner(new SpinnerNumberModel(
            preferences.getInt(PREFERENCES_PORT, ServerOutputThread.DEFAULT_PORT), 1024, 65535, 1));
    final JSpinner.DefaultEditor portSpinnerEditor = new JSpinner.NumberEditor(portSpinner, "#");
    ((DefaultFormatter) portSpinnerEditor.getTextField().getFormatter()).setCommitsOnValidEdit(true);
    portSpinner.setEditor(portSpinnerEditor);
    portSpinner.addChangeListener(
            e -> preferences.putInt(PREFERENCES_PORT, (int) ((JSpinner) e.getSource()).getValue()));
    portPanel.add(portSpinner);

    final var timeoutPanel = new JPanel(panelFlowLayout);
    settingsPanel.add(timeoutPanel, panelGridBagConstraints);

    final var timeoutLabel = new JLabel(rb.getString("TIMEOUT_LABEL"));
    timeoutLabel.setPreferredSize(new Dimension(120, 15));
    timeoutPanel.add(timeoutLabel);

    final var timeoutSpinner = new JSpinner(new SpinnerNumberModel(
            preferences.getInt(PREFERENCES_TIMEOUT, ServerOutputThread.DEFAULT_TIMEOUT), 10, 60000, 1));
    final JSpinner.DefaultEditor timeoutSpinnerEditor = new JSpinner.NumberEditor(timeoutSpinner, "#");
    ((DefaultFormatter) timeoutSpinnerEditor.getTextField().getFormatter()).setCommitsOnValidEdit(true);
    timeoutSpinner.setEditor(timeoutSpinnerEditor);
    timeoutSpinner.addChangeListener(
            e -> preferences.putInt(PREFERENCES_TIMEOUT, (int) ((JSpinner) e.getSource()).getValue()));
    timeoutPanel.add(timeoutSpinner);

    final var alwaysOnTopSupported = Toolkit.getDefaultToolkit().isAlwaysOnTopSupported();
    if (alwaysOnTopSupported || preferences.getBoolean(PREFERENCES_SHOW_OVERLAY, alwaysOnTopSupported)) {
        final var overlaySettingsPanel = new JPanel(panelFlowLayout);
        settingsPanel.add(overlaySettingsPanel, panelGridBagConstraints);

        final var overlayLabel = new JLabel(rb.getString("OVERLAY_LABEL"));
        overlayLabel.setPreferredSize(new Dimension(120, 15));
        overlaySettingsPanel.add(overlayLabel);

        final var showOverlayCheckBox = new JCheckBox(rb.getString("SHOW_OVERLAY_CHECK_BOX"));
        showOverlayCheckBox.setSelected(preferences.getBoolean(PREFERENCES_SHOW_OVERLAY, true));
        showOverlayCheckBox.addActionListener(e -> {
            final boolean showOverlay = ((JCheckBox) e.getSource()).isSelected();

            preferences.putBoolean(PREFERENCES_SHOW_OVERLAY, showOverlay);
        });
        overlaySettingsPanel.add(showOverlayCheckBox);
    }

    if (windows) {
        if (preferences.getBoolean(PREFERENCES_SHOW_VR_OVERLAY, true)) {
            final var vrOverlaySettingsPanel = new JPanel(panelFlowLayout);
            settingsPanel.add(vrOverlaySettingsPanel, panelGridBagConstraints);

            final var vrOverlayLabel = new JLabel(rb.getString("VR_OVERLAY_LABEL"));
            vrOverlayLabel.setPreferredSize(new Dimension(120, 15));
            vrOverlaySettingsPanel.add(vrOverlayLabel);

            final var showVrOverlayCheckBox = new JCheckBox(rb.getString("SHOW_VR_OVERLAY_CHECK_BOX"));
            showVrOverlayCheckBox.setSelected(preferences.getBoolean(PREFERENCES_SHOW_VR_OVERLAY, true));
            showVrOverlayCheckBox.addActionListener(e -> {
                final var showVrOverlay = ((JCheckBox) e.getSource()).isSelected();

                preferences.putBoolean(PREFERENCES_SHOW_VR_OVERLAY, showVrOverlay);
            });
            vrOverlaySettingsPanel.add(showVrOverlayCheckBox);
        }

        final var preventPowerSaveModeSettingsPanel = new JPanel(panelFlowLayout);
        settingsPanel.add(preventPowerSaveModeSettingsPanel, panelGridBagConstraints);

        final var preventPowerSaveModeLabel = new JLabel(rb.getString("POWER_SAVE_MODE_LABEL"));
        preventPowerSaveModeLabel.setPreferredSize(new Dimension(120, 15));
        preventPowerSaveModeSettingsPanel.add(preventPowerSaveModeLabel);

        final var preventPowerSaveModeCheckBox = new JCheckBox(
                rb.getString("PREVENT_POWER_SAVE_MODE_CHECK_BOX"));
        preventPowerSaveModeCheckBox
                .setSelected(preferences.getBoolean(PREFERENCES_PREVENT_POWER_SAVE_MODE, true));
        preventPowerSaveModeCheckBox.addActionListener(e -> {
            final var preventPowerSaveMode = ((JCheckBox) e.getSource()).isSelected();

            preferences.putBoolean(PREFERENCES_PREVENT_POWER_SAVE_MODE, preventPowerSaveMode);
        });
        preventPowerSaveModeSettingsPanel.add(preventPowerSaveModeCheckBox);
    }

    if (SystemTray.isSupported()) {
        final var popupMenu = new PopupMenu();

        final var showAction = new ShowAction();
        showMenuItem = new MenuItem((String) showAction.getValue(Action.NAME));
        showMenuItem.addActionListener(showAction);
        popupMenu.add(showMenuItem);

        popupMenu.addSeparator();

        final var openMenuItem = new MenuItem((String) openAction.getValue(Action.NAME));
        openMenuItem.addActionListener(openAction);
        popupMenu.add(openMenuItem);

        popupMenu.addSeparator();

        final var quitMenuItem = new MenuItem((String) quitAction.getValue(Action.NAME));
        quitMenuItem.addActionListener(quitAction);
        popupMenu.add(quitMenuItem);

        trayIcon = new TrayIcon(frame.getIconImage());
        trayIcon.addActionListener(showAction);
        trayIcon.setPopupMenu(popupMenu);
        try {
            SystemTray.getSystemTray().add(trayIcon);
        } catch (final AWTException e) {
            log.log(Logger.Level.ERROR, e.getMessage(), e);
        }
    }

    updateTitleAndTooltip();

    settingsPanel.add(Box.createGlue(), new GridBagConstraints(0, GridBagConstraints.RELATIVE, 1, 1, 1.0, 1.0,
            GridBagConstraints.FIRST_LINE_START, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0));

    final var outsideBorder = BorderFactory.createEtchedBorder(EtchedBorder.RAISED);
    final var insideBorder = BorderFactory.createEmptyBorder(0, 5, 0, 5);
    statusLabel.setBorder(BorderFactory.createCompoundBorder(outsideBorder, insideBorder));
    frame.add(statusLabel, BorderLayout.SOUTH);

    final var glfwInitialized = glfwInit();
    if (!glfwInitialized)
        if (windows)
            JOptionPane.showMessageDialog(frame, rb.getString("COULD_NOT_INITIALIZE_GLFW_DIALOG_TEXT_WINDOWS"),
                    rb.getString("ERROR_DIALOG_TITLE"), JOptionPane.ERROR_MESSAGE);
        else {
            JOptionPane.showMessageDialog(frame, rb.getString("COULD_NOT_INITIALIZE_GLFW_DIALOG_TEXT"),
                    rb.getString("ERROR_DIALOG_TITLE"), JOptionPane.ERROR_MESSAGE);
            quit();
        }

    final var presentJids = new HashSet<Integer>();
    for (var jid = GLFW_JOYSTICK_1; jid <= GLFW_JOYSTICK_LAST; jid++)
        if (glfwJoystickPresent(jid) && glfwJoystickIsGamepad(jid))
            presentJids.add(jid);

    final var lastControllerGuid = preferences.get(PREFERENCES_LAST_CONTROLLER, null);
    for (final var jid : presentJids) {
        final var lastControllerFound = lastControllerGuid != null
                ? lastControllerGuid.equals(glfwGetJoystickGUID(jid))
                : false;

        if (!isSelectedJidValid() || lastControllerFound)
            selectedJid = jid;

        if (lastControllerFound)
            break;
    }

    newProfile();

    onControllersChanged(true);

    glfwSetJoystickCallback(new GLFWJoystickCallback() {

        @Override
        public void invoke(final int jid, final int event) {
            final var disconnected = event == GLFW_DISCONNECTED;
            if (disconnected || glfwJoystickIsGamepad(jid)) {
                if (disconnected && selectedJid == jid)
                    selectedJid = INVALID_JID;

                invokeOnEventDispatchThreadIfRequired(() -> onControllersChanged(false));
            }

        }
    });

    if (glfwInitialized && presentJids.isEmpty()) {
        if (windows)
            JOptionPane.showMessageDialog(frame, rb.getString("NO_CONTROLLER_CONNECTED_DIALOG_TEXT_WINDOWS"),
                    rb.getString("INFORMATION_DIALOG_TITLE"), JOptionPane.INFORMATION_MESSAGE);
        else
            JOptionPane.showMessageDialog(frame, rb.getString("NO_CONTROLLER_CONNECTED_DIALOG_TEXT"),
                    rb.getString("INFORMATION_DIALOG_TITLE"), JOptionPane.INFORMATION_MESSAGE);
    } else {
        final String path = preferences.get(PREFERENCES_LAST_PROFILE, null);
        if (path != null)
            loadProfile(new File(path));
    }
}

From source file:org.nuclos.client.layout.wysiwyg.LayoutMLGenerator.java

/**
 * Method converting Border(s) to LayoutML XML.
 *
 * @param blockDeep/*w  w  w .j  a  va2  s .c  o m*/
 * @param border
 * @return {@link StringBuffer} with the LayoutML
 */
private synchronized StringBuffer getLayoutMLBorderFromBorder(Border border, int blockDeep) {
    LayoutMLBlock block = new LayoutMLBlock(blockDeep);

    if (border instanceof TitledBorder) {
        block.append("<" + ELEMENT_TITLEDBORDER + " ");
        block.append(ATTRIBUTE_TITLE + "=\"");
        block.append(StringUtils.xmlEncode(((TitledBorder) border).getTitle()) + "\">");
        block.append(getLayoutMLTranslations(((TitledBorderWithTranslations) border).getTranslations(),
                blockDeep + 1));
        block.linebreak();
        block.append("</" + ELEMENT_TITLEDBORDER + ">");
    } else if (border instanceof LineBorder) {
        block.append("<" + ELEMENT_LINEBORDER);
        block.append(getLayoutMLColorAttributes(((LineBorder) border).getLineColor()));
        block.append(" " + ATTRIBUTE_THICKNESS + "=\"");
        block.append(((LineBorder) border).getThickness());
        block.append("\" />");
    } else if (border instanceof BevelBorder) {
        block.append("<" + ELEMENT_BEVELBORDER + " ");
        block.append(ATTRIBUTE_TYPE + "=\"");
        block.append(((BevelBorder) border).getBevelType() == BevelBorder.RAISED ? ATTRIBUTEVALUE_RAISED
                : ATTRIBUTEVALUE_LOWERED);
        block.append("\" />");
    } else if (border instanceof EtchedBorder) {
        block.append("<" + ELEMENT_ETCHEDBORDER + " ");
        block.append(ATTRIBUTE_TYPE + "=\"");
        block.append(((EtchedBorder) border).getEtchType() == EtchedBorder.RAISED ? ATTRIBUTEVALUE_RAISED
                : ATTRIBUTEVALUE_LOWERED);
        block.append("\" />");
    } else if (border instanceof EmptyBorder) {
        block.append("<" + ELEMENT_EMPTYBORDER + " ");
        block.append(ATTRIBUTE_TOP + "=\"");
        block.append(((EmptyBorder) border).getBorderInsets().top + "\" ");
        block.append(ATTRIBUTE_LEFT + "=\"");
        block.append(((EmptyBorder) border).getBorderInsets().left + "\" ");
        block.append(ATTRIBUTE_BOTTOM + "=\"");
        block.append(((EmptyBorder) border).getBorderInsets().bottom + "\" ");
        block.append(ATTRIBUTE_RIGHT + "=\"");
        block.append(((EmptyBorder) border).getBorderInsets().right + "\" ");
        block.append("/>");
    }
    return block.getStringBuffer();
}

From source file:org.zaproxy.zap.extension.customFire.TechnologyTreePanel.java

public TechnologyTreePanel(String nameRootNode) {
    setLayout(new BorderLayout());

    techToNodeMap = new HashMap<>();
    techTree = new JCheckBoxScriptsTree() {

        private static final long serialVersionUID = 1L;

        @Override//from  ww w.  j a v a  2s . c o m
        protected void setExpandedState(TreePath path, boolean state) {
            // Ignore all collapse requests; collapse events will not be fired
            if (state) {
                super.setExpandedState(path, state);
            }
        }

    };
    // Initialise the structure based on all the tech we know about
    TechSet ts = new TechSet(Tech.builtInTech);
    Iterator<Tech> iter = ts.getIncludeTech().iterator();

    DefaultMutableTreeNode root = new DefaultMutableTreeNode(nameRootNode);
    Tech tech;
    DefaultMutableTreeNode parent;
    DefaultMutableTreeNode node;
    while (iter.hasNext()) {
        tech = iter.next();
        if (tech.getParent() != null) {
            parent = techToNodeMap.get(tech.getParent());
        } else {
            parent = null;
        }
        if (parent == null) {
            parent = root;
        }
        node = new DefaultMutableTreeNode(tech.getUiName());
        parent.add(node);
        techToNodeMap.put(tech, node);
    }

    techTree.setModel(new DefaultTreeModel(root));
    techTree.expandAll();
    techTree.setCheckBoxEnabled(new TreePath(root), false);
    reset();

    JScrollPane scrollPane = new JScrollPane();
    scrollPane.setViewportView(techTree);
    scrollPane.setBorder(BorderFactory.createEtchedBorder(EtchedBorder.RAISED));

    add(scrollPane, BorderLayout.CENTER);
}

From source file:org.zaproxy.zap.extension.quickstart.QuickStartPanel.java

private void initialize() {
    this.setIcon(new ImageIcon(BreakPanel.class.getResource("/resource/icon/16/147.png"))); // 'lightning' icon
    this.setDefaultAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_Q,
            Toolkit.getDefaultToolkit().getMenuShortcutKeyMask() | Event.SHIFT_MASK, false));
    this.setMnemonic(Constant.messages.getChar("quickstart.panel.mnemonic"));
    this.setLayout(new BorderLayout());

    JPanel panelContent = new JPanel(new GridBagLayout());
    JScrollPane jScrollPane = new JScrollPane();
    jScrollPane.setFont(new java.awt.Font("Dialog", java.awt.Font.PLAIN, 11));
    jScrollPane.setHorizontalScrollBarPolicy(javax.swing.JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
    jScrollPane.setViewportView(panelContent);

    this.add(jScrollPane, BorderLayout.CENTER);

    panelContent.setBackground(Color.white);
    panelContent.setBorder(BorderFactory.createEtchedBorder(EtchedBorder.RAISED));

    /*// w  w  w.ja v a2  s.com
     * Layout:
     * Col            0                      1                      2                    3                       4
     * Row+----------------------+----------------------+----------------------+----------------------+----------------------+
     *  0 | Top welcome message                                                                       |    zap128x128.png    |
     *  1 | URL:                 | [ Url field                                                      ] |                      |
     *  2 |                      | [ Attack button ]    | [ Stop button ]      | padding              |                      |
     *  3 | Progress:            | Progress details                                                   |                      |
     *    | Bottom message                                                                                                   |
     *    | Show at start:       | [x]                  |                      |                      |                      |
     *    +----------------------+----------------------+----------------------+----------------------+----------------------+
     */

    panelContent.add(new JLabel(Constant.messages.getString("quickstart.panel.topmsg")),
            LayoutHelper.getGBC(0, 0, 4, 1.0D, new Insets(5, 5, 5, 5)));
    if (Constant.isDevBuild()) {
        panelContent.add(
                new JLabel(new ImageIcon(QuickStartPanel.class
                        .getResource("/org/zaproxy/zap/extension/quickstart/resources/zap128x128dark.png"))),
                LayoutHelper.getGBC(4, 0, 1, 0.0D, 0.0D, GridBagConstraints.NORTH));
    } else {
        panelContent.add(
                new JLabel(DisplayUtils.getScaledIcon(
                        new ImageIcon(SearchPanel.class.getResource("/resource/zap128x128.png")))),
                LayoutHelper.getGBC(4, 0, 1, 0.0D, 0.0D, GridBagConstraints.NORTH));
    }

    panelContent.add(new JLabel(Constant.messages.getString("quickstart.label.url")),
            LayoutHelper.getGBC(0, 1, 1, 0.0D, new Insets(5, 5, 5, 5)));

    JPanel urlSelectPanel = new JPanel(new GridBagLayout());
    JButton selectButton = new JButton(Constant.messages.getString("all.button.select"));
    selectButton.setIcon(
            DisplayUtils.getScaledIcon(new ImageIcon(View.class.getResource("/resource/icon/16/094.png")))); // Globe icon
    selectButton.addActionListener(new java.awt.event.ActionListener() {
        @Override
        public void actionPerformed(java.awt.event.ActionEvent e) {
            NodeSelectDialog nsd = new NodeSelectDialog(View.getSingleton().getMainFrame());
            SiteNode node = null;
            try {
                node = Model.getSingleton().getSession().getSiteTree()
                        .findNode(new URI(getUrlField().getText(), false));
            } catch (Exception e2) {
                // Ignore
            }
            node = nsd.showDialog(node);
            if (node != null && node.getHistoryReference() != null) {
                try {
                    getUrlField().setText(node.getHistoryReference().getURI().toString());
                } catch (Exception e1) {
                    // Ignore
                }
            }
        }
    });

    urlSelectPanel.add(this.getUrlField(), LayoutHelper.getGBC(0, 0, 1, 1.0D));
    urlSelectPanel.add(selectButton, LayoutHelper.getGBC(1, 0, 1, 0.0D));
    panelContent.add(urlSelectPanel, LayoutHelper.getGBC(1, 1, 3, 0.25D));

    panelContent.add(this.getAttackButton(), LayoutHelper.getGBC(1, 2, 1, 0.0D));
    panelContent.add(this.getStopButton(), LayoutHelper.getGBC(2, 2, 1, 0.0D));
    panelContent.add(new JLabel(""), LayoutHelper.getGBC(3, 2, 1, 0.75D, 0.0D)); // Padding to right of buttons

    progressLabel = new JLabel(
            Constant.messages.getString("quickstart.progress." + AttackThread.Progress.notstarted.name()));
    panelContent.add(new JLabel(Constant.messages.getString("quickstart.label.progress")),
            LayoutHelper.getGBC(0, 3, 1, 0.0D, new Insets(5, 5, 5, 5)));
    panelContent.add(this.progressLabel, LayoutHelper.getGBC(1, 3, 3, 0.0D));

    panelContent.add(new JLabel(Constant.messages.getString("quickstart.panel.proxymsg")),
            LayoutHelper.getGBC(0, 4, 5, 1.0D, new Insets(5, 5, 5, 5)));

    if (Control.getSingleton().getExtensionLoader().getExtension("ExtensionPlugNHack") != null) {
        // Plug-n-Hack extension has been installed - this makes configuration much easier :)
        if (DesktopUtils.canOpenUrlInBrowser()) {
            panelContent.add(new JLabel(Constant.messages.getString("quickstart.label.mitm")),
                    LayoutHelper.getGBC(0, 6, 1, 0.0D, new Insets(5, 5, 5, 5)));
            panelContent.add(this.getConfButton(), LayoutHelper.getGBC(1, 6, 1, 0.0D));

            panelContent.add(new JLabel(Constant.messages.getString("quickstart.label.mitmalt")),
                    LayoutHelper.getGBC(0, 7, 1, 0.0D, new Insets(5, 5, 5, 5)));
        } else {
            panelContent.add(new JLabel(Constant.messages.getString("quickstart.label.mitmurl")),
                    LayoutHelper.getGBC(0, 7, 1, 0.0D, new Insets(5, 5, 5, 5)));
        }
        panelContent.add(this.getConfField(), LayoutHelper.getGBC(1, 7, 3, 0.25D));

    } else {
        panelContent.add(new JLabel(Constant.messages.getString("quickstart.panel.helpmsg")),
                LayoutHelper.getGBC(0, 5, 5, 1.0D, new Insets(5, 5, 5, 5)));

    }

    panelContent.add(new JLabel(""), LayoutHelper.getGBC(0, 10, 4, 1.D, 1.0D)); // Padding at bottom

    this.setMode(Control.getSingleton().getMode());
}

From source file:org.zaproxy.zap.extension.tlsdebug.TlsDebugPanel.java

@SuppressWarnings("deprecation")
private void initialize() {

    this.setIcon(TLSDEBUG_ICON);
    this.setDefaultAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_D,
            // TODO Remove warn suppression and use View.getMenuShortcutKeyStroke with
            // newer ZAP (or use getMenuShortcutKeyMaskEx() with Java 10+)
            Toolkit.getDefaultToolkit().getMenuShortcutKeyMask() | KeyEvent.ALT_DOWN_MASK, false));
    this.setLayout(new BorderLayout());

    JPanel panelContent = new JPanel(new GridBagLayout());
    this.add(panelContent, BorderLayout.NORTH);

    panelContent.setBackground(Color.white);
    panelContent.setBorder(BorderFactory.createEtchedBorder(EtchedBorder.RAISED));

    panelContent.add(new JLabel(Constant.messages.getString("tlsdebug.label.url")),
            LayoutHelper.getGBC(0, 0, 1, 0.0D, new Insets(5, 5, 5, 5)));

    JPanel urlSelectPanel = new JPanel(new GridBagLayout());
    JButton selectButton = new JButton(Constant.messages.getString("all.button.select"));
    selectButton.setIcon(/*from   ww  w.ja v  a2s. co m*/
            DisplayUtils.getScaledIcon(new ImageIcon(View.class.getResource("/resource/icon/16/094.png")))); // Globe
    // icon
    selectButton.addActionListener(new java.awt.event.ActionListener() {
        @Override
        public void actionPerformed(java.awt.event.ActionEvent e) {
            NodeSelectDialog nsd = new NodeSelectDialog(View.getSingleton().getMainFrame());
            SiteNode node = null;
            try {
                node = Model.getSingleton().getSession().getSiteTree()
                        .findNode(new URI(getUrlField().getText(), false));
            } catch (Exception e2) {
                // Ignore
            }
            node = nsd.showDialog(node);
            if (node != null && node.getHistoryReference() != null) {
                try {
                    getUrlField().setText(node.getHistoryReference().getURI().toString());
                } catch (Exception e1) {
                    // Ignore
                }
            }
        }
    });

    urlSelectPanel.add(this.getUrlField(), LayoutHelper.getGBC(0, 0, 1, 1.0D));
    urlSelectPanel.add(selectButton, LayoutHelper.getGBC(1, 0, 1, 0.0D));
    panelContent.add(urlSelectPanel, LayoutHelper.getGBC(1, 0, 3, 0.25D));

    panelContent.add(this.getCheckButton(), LayoutHelper.getGBC(0, 1, 1, 0.0D));

    JPanel outputPanel = new JPanel(new BorderLayout());
    outputPanel.add(new JLabel(Constant.messages.getString("tlsdebug.label.console")), BorderLayout.NORTH);
    JScrollPane jScrollPane = new JScrollPane();
    jScrollPane.add(getOutputArea(), LayoutHelper.getGBC(0, 0, 4, 1.D, 1.0D)); // Padding
    // at
    // bottom
    jScrollPane.setFont(new java.awt.Font("Dialog", java.awt.Font.PLAIN, 11));
    jScrollPane.setHorizontalScrollBarPolicy(javax.swing.JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
    jScrollPane.setVerticalScrollBarPolicy(javax.swing.JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED);
    jScrollPane.setViewportView(getOutputArea());
    outputPanel.add(jScrollPane, BorderLayout.CENTER);

    this.add(outputPanel, BorderLayout.CENTER);
}

From source file:org.zaproxy.zap.view.TechnologyTreePanel.java

public TechnologyTreePanel(String nameRootNode) {
    setLayout(new BorderLayout());

    techToNodeMap = new HashMap<>();
    techTree = new JCheckBoxTree() {

        private static final long serialVersionUID = 1L;

        @Override//from   w  w w.j av  a 2  s  .  c o  m
        protected void setExpandedState(TreePath path, boolean state) {
            // Ignore all collapse requests; collapse events will not be fired
            if (state) {
                super.setExpandedState(path, state);
            }
        }
    };
    // Initialise the structure based on all the tech we know about
    TechSet ts = new TechSet(Tech.builtInTech);
    Iterator<Tech> iter = ts.getIncludeTech().iterator();

    DefaultMutableTreeNode root = new DefaultMutableTreeNode(nameRootNode);
    Tech tech;
    DefaultMutableTreeNode parent;
    DefaultMutableTreeNode node;
    while (iter.hasNext()) {
        tech = iter.next();
        if (tech.getParent() != null) {
            parent = techToNodeMap.get(tech.getParent());
        } else {
            parent = null;
        }
        if (parent == null) {
            parent = root;
        }
        node = new DefaultMutableTreeNode(tech.getUiName());
        parent.add(node);
        techToNodeMap.put(tech, node);
    }

    techTree.setModel(new DefaultTreeModel(root));
    techTree.expandAll();
    techTree.setCheckBoxEnabled(new TreePath(root), false);
    reset();

    JScrollPane scrollPane = new JScrollPane();
    scrollPane.setViewportView(techTree);
    scrollPane.setBorder(BorderFactory.createEtchedBorder(EtchedBorder.RAISED));

    add(scrollPane, BorderLayout.CENTER);
}