Example usage for java.awt.event ComponentAdapter ComponentAdapter

List of usage examples for java.awt.event ComponentAdapter ComponentAdapter

Introduction

In this page you can find the example usage for java.awt.event ComponentAdapter ComponentAdapter.

Prototype

ComponentAdapter

Source Link

Usage

From source file:org.spiderplan.tools.visulization.GraphFrame.java

/**
 * @param graph// w  w  w .  jav  a2  s .  com
 * @param history optional history of the graph
 * @param title 
 * @param lC the layout
 * @param edgeLabels map from edges to string labels
 * @param w width of the window
 * @param h height of the window
 */
@SuppressWarnings({ "rawtypes", "unchecked" })
public GraphFrame(AbstractTypedGraph<V, E> graph, Vector<AbstractTypedGraph<V, E>> history, String title,
        LayoutClass lC, Map<E, String> edgeLabels, int w, int h) {
    super(title);
    this.edgeLabels = edgeLabels;
    this.g = new ObservableGraph<V, E>(graph);
    this.g.addGraphEventListener(this);

    this.defaultEdgeType = this.g.getDefaultEdgeType();

    this.layoutClass = lC;

    this.history = history;

    this.setLayout(lC);

    layout.setSize(new Dimension(w, h));

    try {
        Relaxer relaxer = new VisRunner((IterativeContext) layout);
        relaxer.stop();
        relaxer.prerelax();
    } catch (java.lang.ClassCastException e) {
    }

    //      Layout<V,E> staticLayout = new StaticLayout<V,E>(g, layout);
    //      Layout<V,E> staticLayout = new SpringLayout<V, E>(g);

    vv = new VisualizationViewer<V, E>(layout, new Dimension(w, h));

    JRootPane rp = this.getRootPane();
    rp.putClientProperty("defeatSystemEventQueueCheck", Boolean.TRUE);

    getContentPane().setLayout(new BorderLayout());
    getContentPane().setBackground(java.awt.Color.lightGray);
    getContentPane().setFont(new Font("Serif", Font.PLAIN, 10));

    vv.getRenderer().getVertexLabelRenderer().setPosition(Renderer.VertexLabel.Position.S);
    vv.getRenderContext().setVertexLabelTransformer(new ToStringLabeller<V>());
    vv.setForeground(Color.black);

    graphMouse = new EditingModalGraphMouse<V, E>(vv.getRenderContext(), null, null);
    graphMouse.setMode(ModalGraphMouse.Mode.PICKING);
    vv.setGraphMouse(graphMouse);
    vv.addKeyListener(graphMouse.getModeKeyListener());

    //        vv.getRenderContext().setEd
    vv.getRenderContext().setEdgeLabelTransformer(this);
    vv.getRenderContext().setEdgeDrawPaintTransformer(
            new PickableEdgePaintTransformer<E>(vv.getPickedEdgeState(), Color.black, Color.cyan));

    vv.addComponentListener(new ComponentAdapter() {

        /**
         * @see java.awt.event.ComponentAdapter#componentResized(java.awt.event.ComponentEvent)
         */
        @Override
        public void componentResized(ComponentEvent arg0) {
            super.componentResized(arg0);
            layout.setSize(arg0.getComponent().getSize());
        }
    });

    getContentPane().add(vv);

    /**
     * Create simple container for stuff on SOUTH border of this JFrame
     */
    Container c = new Container();
    c.setLayout(new FlowLayout());
    c.setBackground(java.awt.Color.lightGray);
    c.setFont(new Font("Serif", Font.PLAIN, 10));

    /**
     * Button to dump jpeg
     */
    dumpJPEG = new JButton("Dump");
    dumpJPEG.addActionListener(this);
    dumpJPEG.setName("Dump");
    c.add(dumpJPEG);

    /**
     * Button that creates offspring frame for selected vertices
     */
    subGraphButton = new JButton("Subgraph");
    subGraphButton.addActionListener(this);
    subGraphButton.setName("Subgraph");
    c.add(subGraphButton);

    subGraphDepthLabel = new JLabel("Depth");
    c.add(subGraphDepthLabel);
    subGraphDepth = new JTextField("0", 2);
    subGraphDepth.setHorizontalAlignment(SwingConstants.CENTER);
    subGraphDepth.setToolTipText("Depth of sub-graph created from selected nodes.");
    c.add(subGraphDepth);

    /**
     * Button that switches mouse mode
     */
    switchMode = new JButton("Transformation");
    switchMode.addActionListener(this);
    switchMode.setName("SwitchMode");
    c.add(switchMode);

    /**
     * ComboBox for Layout selection:
     */
    JComboBox layoutList;
    if (graph instanceof Forest) {
        String[] layoutStrings = { "Static", "Circle", "DAG", "Spring", "Spring2", "FR", "FR2", "Baloon",
                "ISOM", "KK", "PolarPoint", "RadialTree", "Tree" };
        layoutList = new JComboBox(layoutStrings);
    } else {
        String[] layoutStrings = { "Static", "Circle", "DAG", "Spring", "Spring2", "FR", "FR2", "ISOM", "KK",
                "PolarPoint" };
        layoutList = new JComboBox(layoutStrings);
    }

    layoutList.setSelectedIndex(5);
    layoutList.addActionListener(this);
    layoutList.setName("SelectLayout");
    c.add(layoutList);

    /**
     * Add container to layout
     */
    c.setVisible(true);
    getContentPane().add(c, BorderLayout.SOUTH);

    /**
     * Setup history scroll bar
     */
    if (history != null) {
        historySlider = new JSlider(0, history.size() - 1, history.size() - 1);
        historySlider.addChangeListener(this);
        historySlider.setMajorTickSpacing(10);
        historySlider.setMinorTickSpacing(1);
        historySlider.setPaintTicks(true);
        historySlider.setPaintLabels(true);

        historySlider.setBorder(BorderFactory.createEmptyBorder(0, 0, 10, 0));
        Font font = new Font("Serif", Font.ITALIC, 15);
        historySlider.setFont(font);

        getContentPane().add(historySlider, BorderLayout.NORTH);

    }
    this.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
    this.pack();
    this.setVisible(true);
}

From source file:shuffle.fwk.service.roster.EditRosterService.java

@Override
protected void onLaunch() {
    d.addComponentListener(new ComponentAdapter() {
        @Override/*from  w w w  .  j a  v a2 s  .c  o m*/
        public void componentResized(ComponentEvent ev) {
            ConfigManager preferencesManager = getUser().getPreferencesManager();
            Dimension dim = d.getSize();
            preferencesManager.setEntry(EntryType.INTEGER, KEY_EDIT_ROSTER_WIDTH, dim.width);
            preferencesManager.setEntry(EntryType.INTEGER, KEY_EDIT_ROSTER_HEIGHT, dim.height);
        }
    });
}

From source file:com.diversityarrays.kdxplore.design.EntryFileImportDialog.java

public EntryFileImportDialog(Window owner, String title, File inputFile, Predicate<Role> entryHeadingFilter) {
    super(owner, title, ModalityType.APPLICATION_MODAL);

    this.entryHeadingFilter = entryHeadingFilter;
    setDefaultCloseOperation(DISPOSE_ON_CLOSE);

    setGlassPane(backgroundRunner.getBlockingPane());

    useScrollBarOption.addActionListener(new ActionListener() {
        @Override/* w w w  . j a v  a2s . com*/
        public void actionPerformed(ActionEvent e) {
            updateDataPreviewScrolling();
        }
    });

    headingRoleTableModel = createHeadingRoleTableModel();
    headingRoleTable = new HeadingRoleTable<>(headingRoleTableModel);
    headingTableScrollPane = new JScrollPane(headingRoleTable);
    GuiUtil.setVisibleRowCount(headingRoleTable, 10);

    JPanel roleAssignmentPanel = new JPanel(new BorderLayout());
    roleAssignmentPanel.add(headingTableScrollPane, BorderLayout.CENTER);

    headingRoleTable.setTransferHandler(flth);
    headingRoleTableModel.addChangeListener(headingRoleChangeListener);

    GuiUtil.setVisibleRowCount(dataPreviewTable, 10);
    dataPreviewTable.setTransferHandler(flth);
    dataPreviewScrollPane.setTransferHandler(flth);
    updateDataPreviewScrolling();

    dataPreviewScrollPane.addComponentListener(new ComponentAdapter() {
        @Override
        public void componentResized(ComponentEvent e) {
            //                boolean useScrollBar = useScrollBarOption.isSelected();
            GuiUtil.initialiseTableColumnWidths(dataPreviewTable, true);
        }
    });

    Box top = Box.createHorizontalBox();
    top.add(new JLabel("# rows to preview: "));
    top.add(new JSpinner(previewRowCountSpinnerModel));
    top.add(Box.createHorizontalGlue());
    top.add(useScrollBarOption);

    JPanel dataPreviewPanel = new JPanel(new BorderLayout());
    dataPreviewPanel.add(GuiUtil.createLabelSeparator("Data Preview", top), BorderLayout.NORTH);
    dataPreviewPanel.add(dataPreviewScrollPane, BorderLayout.CENTER);

    headingWarning.setForeground(Color.RED);
    JLabel instructions = new JLabel("<HTML>Please assign a <i>Role</i> for each of the headings in your data"
            + "<br>You must specify one as the <i>Entry Name</i>."
            + "<br>Click on one of the <i>Role</i> cells and select from the dropdown"
            + "<br>To assign multiple headings, select the rows for which you wish"
            + "<br>to set the <i>Role</i> then right-click and choose from the dropdown.");
    instructions.setHorizontalAlignment(JLabel.CENTER);
    instructions.setBackground(Toast.PALE_YELLOW);

    JScrollPane instScroll = new JScrollPane(instructions);
    instScroll.setBackground(Toast.PALE_YELLOW);

    normalEntryNameField.getDocument()
            .addDocumentListener(new DocumentChangeListener((e) -> updateAcceptButton()));
    normalEntryNameField.setText(TrialDesignPreferences.getInstance().getNormalEntryTypeName());

    JPanel rolesPanel = new JPanel();
    GBH gbh = new GBH(rolesPanel, 2, 2, 0, 0);
    int y = 0;
    gbh.add(0, y, 1, 1, GBH.NONE, 0, 1, GBH.EAST, "Entry Type Name for non-Checks:");
    gbh.add(1, y, 1, 1, GBH.NONE, 1, 1, GBH.WEST, normalEntryNameField);
    gbh.add(2, y, 1, 1, GBH.NONE, 1, 1, GBH.WEST, saveForFuture);
    ++y;

    gbh.add(0, y, 3, 1, GBH.BOTH, 2, 1, GBH.CENTER, roleAssignmentPanel);
    ++y;

    JSplitPane headingsAndInstructions = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, rolesPanel, instScroll);

    JPanel headingPanel = new JPanel(new BorderLayout());
    headingPanel.add(GuiUtil.createLabelSeparator("Assign Roles for Headings"), BorderLayout.NORTH);
    headingPanel.add(headingsAndInstructions, BorderLayout.CENTER);
    headingPanel.add(headingWarning, BorderLayout.SOUTH);

    errorMessage.setEditable(false);

    JSplitPane splitPane = new JSplitPane(JSplitPane.VERTICAL_SPLIT, dataPreviewPanel, headingPanel);
    splitPane.setResizeWeight(0.5);

    cardPanel.add(new JScrollPane(errorMessage), CARD_ERROR);
    cardPanel.add(splitPane, CARD_DATA);

    Box bot = Box.createHorizontalBox();
    bot.add(Box.createHorizontalGlue());
    bot.add(new JButton(cancelAction));
    bot.add(new JButton(acceptAction));
    acceptAction.setEnabled(false);

    Container cp = getContentPane();
    cp.add(cardPanel, BorderLayout.CENTER);
    cp.add(bot, BorderLayout.SOUTH);
    pack();

    sheetNamesComboBox.addActionListener(sheetNamesActionListener);

    Timer timer = new Timer(true);

    previewRowCountSpinnerModel.addChangeListener(new ChangeListener() {
        int nPreview;
        TimerTask timerTask = null;

        @Override
        public void stateChanged(ChangeEvent e) {
            nPreview = previewRowCountSpinnerModel.getNumber().intValue();

            if (timerTask == null) {
                timerTask = new TimerTask() {
                    int lastPreviewCount = nPreview;

                    @Override
                    public void run() {
                        if (lastPreviewCount == nPreview) {
                            System.err.println("Stable at " + lastPreviewCount);
                            // No change, do it now
                            cancel();
                            try {
                                updateDataPreview(lastPreviewCount);
                            } finally {
                                timerTask = null;
                            }
                        } else {
                            System.err.println("Changing from " + lastPreviewCount + " to " + nPreview);
                            lastPreviewCount = nPreview;
                        }
                    }
                };
                timer.scheduleAtFixedRate(timerTask, 500, 100);
            }
        }
    });

    sheetNamesComboBox.setVisible(false);

    addWindowListener(new WindowAdapter() {
        @Override
        public void windowOpened(WindowEvent e) {
            removeWindowListener(this);
            setFile(inputFile);
        }
    });
}

From source file:savant.view.swing.Savant.java

/**
 * Creates new form Savant/*from w w  w .j av a 2s  .co  m*/
 */
private Savant(boolean isStandalone, boolean pluginsEnabled) {

    this.isStandalone = isStandalone;

    try {
        basicService = (BasicService) ServiceManager.lookup("javax.jnlp.BasicService");
        webStart = true;
    } catch (UnavailableServiceException e) {
        //System.err.println("Lookup failed: " + e);
        webStart = false;
    }

    instance = this;

    Splash s = new Splash(instance, false);
    if (isStandalone()) {
        s.setVisible(true);
    }

    Authenticator.setDefault(new SavantHTTPAuthenticator());

    addComponentListener(new ComponentAdapter() {
        /**
         * Resize the form to the minimum size if the user has resized it to
         * something smaller.
         *
         * @param e The resize event
         */
        @Override
        public void componentResized(ComponentEvent e) {
            int width = getWidth();
            int height = getHeight();
            //we check if either the width
            //or the height are below minimum
            boolean resize = false;
            if (width < minimumFormWidth) {
                resize = true;
                width = minimumFormWidth;
            }
            if (height < minimumFormHeight) {
                resize = true;
                height = minimumFormHeight;
            }
            if (resize) {
                setSize(width, height);
            }
        }
    });

    GraphPaneController.getInstance().addListener(new Listener<GraphPaneEvent>() {
        @Override
        public void handleEvent(GraphPaneEvent event) {
            GraphPaneController controller = GraphPaneController.getInstance();
            switch (event.getType()) {
            case HIGHLIGHTING:
                plumblineItem.setSelected(controller.isPlumbing());
                spotlightItem.setSelected(controller.isSpotlight());
                crosshairItem.setSelected(controller.isAiming());
                break;
            case MOUSE:
                updateMousePosition(event.getMouseX(), event.getMouseY(), event.isYIntegral());
                break;
            case STATUS:
                updateStatus(event.getStatus());
                break;
            }
        }
    });

    ProjectController.getInstance().addListener(new Listener<ProjectEvent>() {
        @Override
        public void handleEvent(ProjectEvent event) {
            String activity;
            switch (event.getType()) {
            case LOADING:
                activity = "Loading " + event.getPath() + "...";
                setTitle("Savant Genome Browser - " + activity);
                break;
            case LOADED:
            case SAVED:
                MiscUtils.setUnsavedTitle(Savant.this, "Savant Genome Browser - " + event.getPath(), false);
                break;
            case SAVING:
                activity = "Saving " + event.getPath() + "...";
                setTitle("Savant Genome Browser - " + activity);
                break;
            case UNSAVED:
                MiscUtils.setUnsavedTitle(Savant.this, "Savant Genome Browser - " + event.getPath(), true);
                break;
            }
        }
    });

    GenomeController.getInstance().addListener(new Listener<GenomeChangedEvent>() {
        @Override
        public void handleEvent(GenomeChangedEvent event) {
            LOG.info("Genome changed from " + event.getOldGenome() + " to " + event.getNewGenome());
            loadGenomeItem.setText("Change genome...");
            showBrowserControls();
        }
    });

    s.setStatus("Initializing GUI");

    initComponents();
    customizeUI();
    init();
    initHiddenShortcuts();

    if (BrowserSettings.getCheckVersionOnStartup()) {
        s.setStatus("Checking version");
        checkVersion(false);
    }

    if (BrowserSettings.getCollectAnonymousUsage()) {
        logUsageStats();
    }

    if (pluginsEnabled) {

        s.setStatus("Loading plugins");

        PluginController pluginController = PluginController.getInstance();
        pluginController.addListener(new Listener<PluginEvent>() {
            @Override
            public void handleEvent(PluginEvent event) {
                SavantPlugin plugin = event.getPlugin();
                if (event.getType() == PluginEvent.Type.LOADED) {
                    if (plugin instanceof SavantPanelPlugin) {
                        DockableFrame f = DockableFrameFactory.createGUIPluginFrame(plugin.getTitle());
                        JPanel p = (JPanel) f.getContentPane();
                        p.setLayout(new BorderLayout());
                        p.add(event.getCanvas(), BorderLayout.CENTER);
                        auxDockingManager.addFrame(f);
                        addPluginToMenu(new PluginMenuItem((SavantPanelPlugin) plugin));
                    } else if (event.getPlugin() instanceof SavantDataSourcePlugin) {
                        loadFromDataSourcePluginItem.setText("Load Track from Other Datasource...");
                    }
                }
            }
        });
        pluginController.loadPlugins(DirectorySettings.getPluginsDirectory());
    }

    s.setStatus("Organizing layout");

    displayBookmarksPanel();

    if (turnExperimentalFeaturesOff) {
        disableExperimentalFeatures();
    }

    s.setVisible(false);

    if (isStandalone()) {
        makeGUIVisible();
    }
}

From source file:org.photovault.swingui.PhotoViewController.java

/** Creates a new instance of PhotoViewController */
public PhotoViewController(Container view, AbstractController parentController) {
    super(view, parentController);
    photoDAO = getDAOFactory().getPhotoInfoDAO();
    folderDAO = getDAOFactory().getPhotoFolderDAO();
    ImageIcon rotateCWIcon = getIcon("rotate_cw.png");
    ImageIcon rotateCCWIcon = getIcon("rotate_ccw.png");
    ImageIcon rotate180DegIcon = getIcon("rotate_180.png");

    registerAction("rotate_cw", new RotateSelectedPhotoAction(this, 90, "Rotate CW", rotateCWIcon,
            "Rotates the selected photo 90 degrees clockwise", KeyEvent.VK_R));
    registerAction("rotate_ccw", new RotateSelectedPhotoAction(this, 270, "Rotate CCW", rotateCCWIcon,
            "Rotates the selected photo 90 degrees counterclockwise", KeyEvent.VK_L));
    registerAction("rotate_180", new RotateSelectedPhotoAction(this, 180, "Rotate 180 degrees",
            rotate180DegIcon, "Rotates the selected photo 180 degrees counterclockwise", KeyEvent.VK_T));
    registerAction("rotate_180", new RotateSelectedPhotoAction(this, 180, "Rotate 180 degrees",
            rotate180DegIcon, "Rotates the selected photo 180 degrees counterclockwise", KeyEvent.VK_T));
    String qualityStrings[] = { "Unevaluated", "Top", "Good", "OK", "Poor", "Unusable" };
    String qualityIconnames[] = { "quality_unevaluated.png", "quality_top.png", "quality_good.png",
            "quality_ok.png", "quality_poor.png", "quality_unusable.png" };
    KeyStroke qualityAccelerators[] = { null,
            KeyStroke.getKeyStroke(KeyEvent.VK_5, Toolkit.getDefaultToolkit().getMenuShortcutKeyMask()),
            KeyStroke.getKeyStroke(KeyEvent.VK_4, Toolkit.getDefaultToolkit().getMenuShortcutKeyMask()),
            KeyStroke.getKeyStroke(KeyEvent.VK_3, Toolkit.getDefaultToolkit().getMenuShortcutKeyMask()),
            KeyStroke.getKeyStroke(KeyEvent.VK_2, Toolkit.getDefaultToolkit().getMenuShortcutKeyMask()),
            KeyStroke.getKeyStroke(KeyEvent.VK_1, Toolkit.getDefaultToolkit().getMenuShortcutKeyMask()), };
    ImageIcon[] qualityIcons = new ImageIcon[qualityStrings.length];
    for (int n = 0; n < qualityStrings.length; n++) {
        qualityIcons[n] = getIcon(qualityIconnames[n]);
        DataAccessAction qualityAction = new SetPhotoQualityAction(this, n, qualityStrings[n], qualityIcons[n],
                "Set quality of selected phots to \"" + qualityStrings[n] + "\"", null);
        qualityAction.putValue(AbstractAction.ACCELERATOR_KEY, qualityAccelerators[n]);
        registerAction("quality_" + n, qualityAction);

        registerEventListener(TaskFinishedEvent.class, new DefaultEventListener<BackgroundTask>() {

            public void handleEvent(DefaultEvent<BackgroundTask> event) {
                BackgroundTask task = event.getPayload();
                if (task instanceof IndexFileTask) {
                    IndexFileTask ifTask = (IndexFileTask) task;
                    if (ifTask.getResult() == IndexingResult.ERROR
                            || ifTask.getResult() == IndexingResult.NOT_IMAGE) {
                        return;
                    }//from  w w w.  jav  a 2  s .  c  o  m
                    UUID volId = ifTask.getVolume().getId();
                    FileLocation loc = ifTask.getFileLocation();
                    Set<PhotoInfo> photos = ifTask.getPhotosFound();
                    log.debug("Found file " + loc.getFile() + " in volume " + volId);
                    for (PhotoInfo p : photos) {
                        log.debug("   linked to photo " + p.getUuid());
                    }
                    if (collection instanceof ExtDirPhotos) {
                        ExtDirPhotos dir = (ExtDirPhotos) collection;
                        if (loc.getVolume().getId().equals(dir.getVolId())
                                && loc.getDirName().equals(dir.getDirPath())) {
                            addPhotos(photos);
                            updateThumbView();
                        }
                    }
                }
            }
        });
    }

    // Create the UI controls
    thumbPane = new PhotoCollectionThumbView(this, null);
    thumbPane.addSelectionChangeListener(new SelectionChangeListener() {

        public void selectionChanged(SelectionChangeEvent e) {
            thumbSelectionChanged(e);
        }
    });
    previewPane = new JAIPhotoViewer(this);
    previewPane.getActionMap().put("hide_fullwindow_preview", new HidePhotoPreviewAction(this));
    previewPane.getActionMap().put("move_next", thumbPane.getSelectNextAction());
    previewPane.getActionMap().put("move_prev", thumbPane.getSelectPreviousAction());

    // Create the split pane to display both of these components

    thumbScroll = new JScrollPane(thumbPane);
    thumbPane.setBackground(Color.WHITE);
    thumbScroll.getViewport().setBackground(Color.WHITE);
    thumbScroll.addComponentListener(new ComponentAdapter() {
        @Override
        public void componentResized(ComponentEvent e) {
            handleThumbAreaResize();
        }
    });

    scrollLayer = new JXLayer<JScrollPane>(thumbScroll);
    progressLayer = new ProgressIndicatorLayer();
    scrollLayer.setUI(progressLayer);

    collectionPane = new JPanel();
    splitPane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT);
    layeredPane = new JLayeredPane();
    layeredPane.setLayout(new StackLayout());
    collectionPane.add(splitPane);
    collectionPane.add(layeredPane);
    GridBagLayout layout = new GridBagLayout();
    collectionPane.setLayout(layout);

    GridBagConstraints c = new GridBagConstraints();
    c.fill = GridBagConstraints.BOTH;
    c.weighty = 1.0;
    c.weightx = 1.0;
    c.gridy = 0;
    // collectionPane.add( scrollLayer );
    layout.setConstraints(splitPane, c);
    layout.setConstraints(layeredPane, c);
    //        collectionPane.add( previewPane );
    thumbPane.setRowHeight(200);
    setLayout(Layout.ONLY_THUMBS);

    /*
    Register action so that we are notified of changes to currently
    displayed folder
     */
    registerEventListener(CommandExecutedEvent.class, new DefaultEventListener<DataAccessCommand>() {

        public void handleEvent(DefaultEvent<DataAccessCommand> event) {
            DataAccessCommand cmd = event.getPayload();
            if (cmd instanceof ChangePhotoInfoCommand) {
                photoChangeCommandExecuted((ChangePhotoInfoCommand) cmd);
            } else if (cmd instanceof CreateCopyImageCommand) {
                imageCreated((CreateCopyImageCommand) cmd);
            } else if (cmd instanceof ApplyChangeCommand) {
                changeApplied((ApplyChangeCommand) cmd);
            }
        }
    });
}

From source file:pcgen.gui2.PCGenFrame.java

private void initSettings() {
    final UIPropertyContext frameContext = UIPropertyContext.createContext("PCGenFrame");

    Rectangle screenBounds = getGraphicsConfiguration().getBounds();

    setSize(1060, 725); //this is the default frame dimensions
    setLocationRelativeTo(null); //center the frame
    if (!screenBounds.contains(getBounds())) {
        setSize((5 * screenBounds.width) / 6, (5 * screenBounds.height) / 6);
        setLocationRelativeTo(null); //center the frame
    }/*  w ww .  j  a va  2s.  com*/
    Rectangle frameBounds = getBounds();
    frameBounds.x = frameContext.initInt("bounds.x", frameBounds.x);
    frameBounds.y = frameContext.initInt("bounds.y", frameBounds.x);
    frameBounds.width = frameContext.initInt("bounds.width", frameBounds.width);
    frameBounds.height = frameContext.initInt("bounds.height", frameBounds.height);

    int extendedState = frameContext.initInt("extendedState", NORMAL);
    if (extendedState == ICONIFIED) {
        extendedState = NORMAL;
        frameContext.setInt("extendedState", NORMAL);
    }
    setExtendedState(extendedState);
    if (checkBounds(frameBounds)) {
        setBounds(frameBounds);
    }
    addPropertyChangeListener("extendedState", frameContext);
    addComponentListener(new ComponentAdapter() {

        @Override
        public void componentResized(ComponentEvent e) {
            updateBounds();
        }

        @Override
        public void componentMoved(ComponentEvent e) {
            updateBounds();
        }

        private void updateBounds() {
            Rectangle bounds = getBounds();
            frameContext.setInt("bounds.x", bounds.x);
            frameContext.setInt("bounds.y", bounds.y);
            frameContext.setInt("bounds.width", bounds.width);
            frameContext.setInt("bounds.height", bounds.height);
        }

    });
    setDefaultCloseOperation(WindowConstants.DO_NOTHING_ON_CLOSE);
    addWindowListener(new WindowAdapter() {

        @Override
        public void windowClosing(WindowEvent e) {
            PCGenUIManager.closePCGen();
        }

    });
}

From source file:jmemorize.gui.swing.panels.DeckChartPanel.java

private void initComponents() {
    // add the chart to a panel...
    m_chartPanel = new ChartPanel(createChart());
    m_chartPanel.addChartMouseListener(new MouseClicked());

    m_chartPanel.setMinimumDrawHeight(100);
    m_chartPanel.setMinimumDrawWidth(400);

    m_chartPanel.setMaximumDrawHeight(1600);
    m_chartPanel.setMaximumDrawWidth(10000);

    setLayout(new BorderLayout());
    setBorder(new EmptyBorder(10, 2, 2, 2));
    add(m_chartPanel);/*  w  w  w  . j a  va  2 s  .com*/

    addComponentListener(new ComponentAdapter() {
        public void componentResized(ComponentEvent e) {
            if (m_category != null)
                updateBars();
        }
    });
}

From source file:op.care.sysfiles.PnlFiles.java

/**
 * This method is called from within the constructor to
 * initialize the form.//from  ww w.jav a  2 s .c o  m
 * WARNING: Do NOT modify this code. The content of this method is
 * always regenerated by the PrinterForm Editor.
 */
@SuppressWarnings("unchecked")
// <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
private void initComponents() {
    pnlMain = new JPanel();
    jspFiles = new JScrollPane();
    tblFiles = new JTable();

    //======== this ========
    setLayout(new BoxLayout(this, BoxLayout.X_AXIS));

    //======== pnlMain ========
    {
        pnlMain.setLayout(new BoxLayout(pnlMain, BoxLayout.X_AXIS));

        //======== jspFiles ========
        {
            jspFiles.addComponentListener(new ComponentAdapter() {
                @Override
                public void componentResized(ComponentEvent e) {
                    jspFilesComponentResized(e);
                }
            });

            //---- tblFiles ----
            tblFiles.setModel(new DefaultTableModel(
                    new Object[][] { { null, null, null, null }, { null, null, null, null },
                            { null, null, null, null }, { null, null, null, null }, },
                    new String[] { "Title 1", "Title 2", "Title 3", "Title 4" }));
            tblFiles.setAutoResizeMode(JTable.AUTO_RESIZE_OFF);
            tblFiles.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
            tblFiles.addMouseListener(new MouseAdapter() {
                @Override
                public void mousePressed(MouseEvent e) {
                    tblFilesMousePressed(e);
                }
            });
            jspFiles.setViewportView(tblFiles);
        }
        pnlMain.add(jspFiles);
    }
    add(pnlMain);
}

From source file:net.sf.jabref.gui.FindUnlinkedFilesDialog.java

/**
 * Initializes action objects. <br>
 * Does not assign actions to components yet!
 *///from w w  w .  j  a  v a 2  s. co  m
private void initializeActions() {

    actionSelectAll = new AbstractAction(Localization.lang("Select all")) {

        @Override
        public void actionPerformed(ActionEvent e) {
            CheckableTreeNode rootNode = (CheckableTreeNode) tree.getModel().getRoot();
            rootNode.setSelected(true);
            tree.invalidate();
            tree.repaint();
        }
    };

    actionUnselectAll = new AbstractAction(Localization.lang("Unselect all")) {

        @Override
        public void actionPerformed(ActionEvent e) {
            CheckableTreeNode rootNode = (CheckableTreeNode) tree.getModel().getRoot();
            rootNode.setSelected(false);
            tree.invalidate();
            tree.repaint();
        }
    };

    actionExpandTree = new AbstractAction(Localization.lang("Expand all")) {

        @Override
        public void actionPerformed(ActionEvent e) {
            CheckableTreeNode rootNode = (CheckableTreeNode) tree.getModel().getRoot();
            expandTree(tree, new TreePath(rootNode), true);
        }
    };

    actionCollapseTree = new AbstractAction(Localization.lang("Collapse all")) {

        @Override
        public void actionPerformed(ActionEvent e) {
            CheckableTreeNode rootNode = (CheckableTreeNode) tree.getModel().getRoot();
            expandTree(tree, new TreePath(rootNode), false);
        }
    };

    dialogPositionListener = new ComponentAdapter() {

        /* (non-Javadoc)
         * @see java.awt.event.ComponentAdapter#componentResized(java.awt.event.ComponentEvent)
         */
        @Override
        public void componentResized(ComponentEvent e) {
            storeSizeOfDialog();
        }

        /* (non-Javadoc)
         * @see java.awt.event.ComponentAdapter#componentMoved(java.awt.event.ComponentEvent)
         */
        @Override
        public void componentMoved(ComponentEvent e) {
            storeSizeOfDialog();
        }
    };

}

From source file:org.roche.antibody.ui.components.AntibodyEditorPane.java

/**
 * initates swing component//from w w w .j  a  v  a2  s  . co  m
 */
private void initComponents() {
    abstractGraphLayouter = AbstractGraphLayoutService.createLayouter();
    this.abstractAntibodyView = new Graph2DView();
    this.abstractAntibodyView.setFitContentOnResize(true);
    editMode = new AntibodyEditMode(this);
    abstractAntibodyView.addViewMode(editMode);

    // enable bridges for PolyLineEdgeRealizer
    BridgeCalculator bridgeCalculator = new BridgeCalculator();
    bridgeCalculator.setCrossingMode(BridgeCalculator.CROSSING_MODE_HORIZONTAL_CROSSES_VERTICAL);
    ((DefaultGraph2DRenderer) abstractAntibodyView.getGraph2DRenderer()).setBridgeCalculator(bridgeCalculator);
    configureKeyboardActions();

    this.addComponentListener(new ComponentAdapter() {
        @Override
        public void componentShown(ComponentEvent e) {
            super.componentShown(e);
            LOG.debug("Call componentShown of: {}", this.getClass().getName());
            updateGraphLayout();
        }
    });
    this.setLayout(new BorderLayout());

    // --- START Graphical Representation of Antybody (Center Panel)
    JSplitPane pnlSplit = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT);
    pnlSplit.setOneTouchExpandable(true);
    this.add(pnlSplit, BorderLayout.CENTER);
    pnlSplit.setLeftComponent(abstractAntibodyView);
    pnlSplit.setResizeWeight(1);
    // --- START Property Table, HELM Notation etc. (Right Panel)
    pnlEast = new JSplitPane(JSplitPane.VERTICAL_SPLIT);
    pnlEast.setBorder(DEFAULT_BORDER);
    pnlEast.setResizeWeight(0.65);
    antibodyPropertyModel = new DomainTableModel();
    antibodyPropertyModel.addTableModelListener(new TableModelListener() {
        @Override
        public void tableChanged(TableModelEvent e) {
            abstractGraph.updateViews();
        }
    });
    propertyTable = new JTable(antibodyPropertyModel);
    propertyTable.setDefaultRenderer(Object.class, new DomainTableCellRenderer());

    JScrollPane spnlPropertyTable = new JScrollPane(propertyTable);
    pnlEast.setTopComponent(spnlPropertyTable);
    pnlSplit.setRightComponent(pnlEast);

    // graphical preview
    graphicsPane = new JPanel(new BorderLayout());
    anotherView = new Graph2DView();
    graphicsPane.add(anotherView, BorderLayout.CENTER);

    // Tabcontainer for graphic and helm notation preview
    tabbedPane = new JTabbedPane(JTabbedPane.TOP);

    // --- HELM notation Preview Panel
    helmPreviewPane = new JPanel();
    helmPreviewPane.setLayout(new BorderLayout());
    tabbedPane.addTab("HELM Notation Preview", null, helmPreviewPane, null);

    // --- Button Panel for HELM notation preview
    JPanel pnlButtons = new JPanel(new FlowLayout(FlowLayout.RIGHT));

    cmdSaveAsXml = new JButton("Save Antibody",
            new ImageIcon(ResourceProvider.getInstance().get(ResourceProvider.DISK_IMAGE)));
    cmdSaveAsXml.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e) {
            XmlFileChooser dialog = new XmlFileChooser();
            if (dialog.showSaveDialog(mainEditor.getFrame()) == JFileChooser.APPROVE_OPTION) {
                File abFile = dialog.getSelectedFile();
                String newPath = FilenameUtils.removeExtension(abFile.getAbsolutePath());
                abFile = new File(newPath + AntibodyFileChooser.XML_EXTENSION);
                AntibodyContainer abContainer = new AntibodyContainer();
                try {
                    antibody.setDomainLibraryPath(ConfigFileService.getInstance().getDomainLibFilename());
                    // PreferencesService.getInstance().getDomainLibraryFile().getAbsolutePath());

                    abContainer.setAntibody(antibody);
                    abContainer.setHelmCode(helmTextArea.getText());
                    xmlService.marshal(abContainer, abFile);
                } catch (JAXBException e1) {
                    JOptionPane.showMessageDialog(mainEditor.getFrame(),
                            "Could not save Antibody! Please try again", "Error", JOptionPane.ERROR_MESSAGE);
                    LOG.error("Could not save Antibody-XML to disk! {}", e1);
                }
            }
        }
    });
    pnlButtons.add(cmdSaveAsXml);

    cmdLoadFromXml = new JButton("Load Antibody",
            new ImageIcon(ResourceProvider.getInstance().get(ResourceProvider.OPEN_FOLDER)));
    cmdLoadFromXml.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e) {
            XmlFileChooser dialog = new XmlFileChooser();
            if (dialog.showOpenDialog(mainEditor.getFrame()) == JFileChooser.APPROVE_OPTION) {
                File abFile = dialog.getSelectedFile();
                try {
                    AntibodyContainer newAbContainer = xmlService.unmarshal(abFile);
                    setModel(newAbContainer.getAntibody());
                } catch (JAXBException e1) {
                    JOptionPane.showMessageDialog(mainEditor.getFrame(),
                            "Could not load Antibody! Please try again", "Error", JOptionPane.ERROR_MESSAGE);
                    LOG.error("Could not load Antibody-XML to disk! {}", e1);
                }
            }
        }
    });
    pnlButtons.add(cmdLoadFromXml);
    helmPreviewPane.add(pnlButtons, BorderLayout.SOUTH);

    pnlEast.setBottomComponent(tabbedPane);

    // --- HELM Notation Text Area
    helmTextArea = new JTextArea();
    helmTextArea.setLineWrap(true);
    JScrollPane spnlHELMTextArea = new JScrollPane(helmTextArea, JScrollPane.VERTICAL_SCROLLBAR_ALWAYS,
            JScrollPane.HORIZONTAL_SCROLLBAR_ALWAYS);
    helmPreviewPane.add(spnlHELMTextArea, BorderLayout.CENTER);
}