List of usage examples for java.awt.event ComponentAdapter ComponentAdapter
ComponentAdapter
From source file:de.mprengemann.intellij.plugin.androidicons.forms.MaterialIconsImporter.java
public MaterialIconsImporter(@Nullable final Project project, Module module) { super(project, true); this.project = project; setTitle("Material Icons Importer"); setResizable(false);/* ww w. ja v a 2s . c om*/ AndroidResourcesHelper.initResourceBrowser(project, module, "Select res root", this.resRoot); assetRoot = SettingsHelper.getAssetPath(IconPack.MATERIAL_ICONS); getHelpAction().setEnabled(true); fillCategories(); fillAssets(); fillSizes(); fillColors(); categorySpinner.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent actionEvent) { fillAssets(); updateImage(); } }); AssetSpinnerRenderer renderer = new AssetSpinnerRenderer(); //noinspection GtkPreferredJComboBoxRenderer assetSpinner.setRenderer(renderer); assetSpinner.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent event) { fillSizes(); updateImage(); } }); sizeSpinner.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent actionEvent) { String size = (String) sizeSpinner.getSelectedItem(); if (size != null) { lastSelectedSize = size; } fillColors(); updateImage(); } }); colorSpinner.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent event) { String color = (String) colorSpinner.getSelectedItem(); if (color != null) { lastSelectedColor = color; } updateImage(); } }); resExportName.addKeyListener(new KeyAdapter() { @Override public void keyTyped(KeyEvent keyEvent) { super.keyTyped(keyEvent); if (!exportNameChanged && keyEvent != null && keyEvent.getKeyCode() > -1) { exportNameChanged = true; } } @Override public void keyPressed(KeyEvent keyEvent) { super.keyPressed(keyEvent); } @Override public void keyReleased(KeyEvent keyEvent) { super.keyReleased(keyEvent); } }); imageContainer.addComponentListener(new ComponentAdapter() { @Override public void componentResized(ComponentEvent e) { super.componentResized(e); updateImage(); } }); init(); }
From source file:de.mprengemann.intellij.plugin.androidicons.dialogs.VectorImporter.java
public VectorImporter(Project project, Module module) { super(project, true); this.project = project; this.module = module; final IconApplication container = ApplicationManager.getApplication().getComponent(IconApplication.class); materialIconsController = container.getControllerFactory().getMaterialIconsController(); settingsController = container.getControllerFactory().getSettingsController(); defaultsController = container.getControllerFactory().getDefaultsController(); controller = new IconsImporterController(defaultsController, materialIconsController); initResRoot();//from w w w. java2 s. c o m setTitle("Vector Drawable Importer"); getHelpAction().setEnabled(true); AssetSpinnerRenderer renderer = new AssetSpinnerRenderer(); //noinspection GtkPreferredJComboBoxRenderer assetSpinner.setRenderer(renderer); imageContainer.addComponentListener(new ComponentAdapter() { @Override public void componentResized(ComponentEvent e) { super.componentResized(e); updateImage(); } }); initSearch(); controller.addObserver(this); init(); pack(); }
From source file:org.ayound.js.debug.ui.DebugMainFrame.java
private void initMainLayout() { final JSplitPane bottomSplit = new JSplitPane(JSplitPane.VERTICAL_SPLIT, createMainPane(), createDebugPane());/*from www .jav a2 s .c o m*/ bottomSplit.setDividerLocation(0.7); final JSplitPane totalSplit = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, createDebugContextPane(), bottomSplit); totalSplit.setDividerLocation(0.25); this.addComponentListener(new ComponentAdapter() { public void componentResized(ComponentEvent e) { bottomSplit.setDividerLocation(0.7); totalSplit.setDividerLocation(0.25); } }); add(totalSplit); }
From source file:nl.tudelft.goal.SimpleIDE.SimpleIDE.java
/** * Creates the IDE interface and related services. *//* w ww. j a v a 2 s .co m*/ public SimpleIDE() throws InstantiationException, IllegalAccessException { // Do not use InfoLog; nothing is subscribed yet. System.out.println("Launching IDE"); //$NON-NLS-1$ /** * Checks whether logs should be rerouted to console as well. Set to * false by default. Only to be used for debugging purposes by * developers; change via settings file. */ if (LoggingPreferences.getShowLogsInConsole()) { Loggers.addConsoleLogger(); } // Initialize the action factory. ActionFactory.getFactory(this, new IDETempState()); // Set look and feel. setLookAndFeel(); /** * Set size first, otherwise it is not clear how the fractional values * e.g. for setDividerLocation work out. */ setSize(IDEPreferences.getWinWidth(), IDEPreferences.getWinHeight()); if (IDEPreferences.getRememberWinPos()) { setLocation(IDEPreferences.getWinX(), IDEPreferences.getWinY()); } setTitle("GOAL IDE"); //$NON-NLS-1$ setLayout(new BorderLayout()); // Add center panel; do this before adding tool bar which depends on it // for initialization of buttons. this.mainPanel = new IDEMainPanel(this); add(this.mainPanel, BorderLayout.CENTER); this.statusBar = new StatusBar(); add(this.statusBar, BorderLayout.SOUTH); // Add menu. setJMenuBar(new IDEMenuBar()); // Add tool bar. add(new ToolBar(), BorderLayout.PAGE_START); setVisible(true); if (System.getProperty("os.name").equals("Mac OS X")) { //$NON-NLS-1$ //$NON-NLS-2$ OSXAdapter.setQuitHandler(new Runnable() { @Override public void run() { try { ActionFactory.getAction(QuitAction.class).Execute(null, null); } catch (IllegalAccessException | InstantiationException | GOALException e) { e.printStackTrace(); } } }); } // Disable default close operation and install quit "button" handler. setDefaultCloseOperation(WindowConstants.DO_NOTHING_ON_CLOSE); addWindowListener(new WindowAdapter() { @Override public void windowClosing(WindowEvent e) { try { ActionFactory.getAction(QuitAction.class).Execute(null, null); } catch (Exception er) { System.out.println("BUG: QUIT FAILED"); //$NON-NLS-1$ er.printStackTrace(); } } }); addComponentListener(new ComponentAdapter() { @Override public void componentMoved(ComponentEvent e) { IDEPreferences.setLastWinPos(getLocation()); } @Override public void componentResized(ComponentEvent e) { IDEPreferences.setLastWinSize(getSize()); } }); // Set initial content of file panel. // TODO move application logic to platform manager. if (IDEPreferences.getReopenMASs()) { reopenMASs(); } if (IDEPreferences.getReopenSpurious()) { reopenSpurious(); } // IDE state has been configured. Broadcast the info. ActionFactory.broadcastStateChange(this); }
From source file:ar.edu.uns.cs.vyglab.arq.rockar.gui.JFrameControlPanel.java
private void initGUI() { try {/* www .j a v a2 s .c o m*/ setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE); this.setIconImage(new ImageIcon(getClass().getClassLoader() .getResource("ar/edu/uns/cs/vyglab/arq/rockar/resources/images/splash/purple-monkey32.png")) .getImage()); this.setTitle("Rock.AR v2.0"); this.addComponentListener(new ComponentAdapter() { public void componentResized(ComponentEvent evt) { thisComponentResized(evt); } }); this.addWindowListener(new WindowAdapter() { public void windowClosed(WindowEvent evt) { thisWindowClosed(evt); } }); { jPanelSouth = new JPanel(); BorderLayout jPanelSouthLayout = new BorderLayout(); getContentPane().add(jPanelSouth, BorderLayout.SOUTH); jPanelSouth.setLayout(jPanelSouthLayout); { jLabelInformation = new JLabel(); jPanelSouth.add(jLabelInformation, BorderLayout.CENTER); jLabelInformation.setText(DataCenter.langResource.getString("control_information_label")); jLabelInformation.setOpaque(true); jLabelInformation.setBackground(new java.awt.Color(241, 191, 101)); } } { jPanelCenter = new JPanel(); GridLayout jPanelCenterLayout = new GridLayout(1, 1); jPanelCenterLayout.setHgap(5); jPanelCenterLayout.setVgap(5); jPanelCenterLayout.setColumns(1); getContentPane().add(jPanelCenter, BorderLayout.CENTER); jPanelCenter.setLayout(jPanelCenterLayout); { jPanelWest = new JPanel(); BorderLayout jPanelWestLayout = new BorderLayout(); jPanelCenter.add(jPanelWest); jPanelWest.setLayout(jPanelWestLayout); jPanelWest.setBorder(new LineBorder(new java.awt.Color(0, 0, 0), 1, false)); { jToolBarMineralTable = new JToolBar(); jToolBarMineralTable.setLayout(new FlowLayout(FlowLayout.LEFT)); jPanelWest.add(jToolBarMineralTable, BorderLayout.NORTH); jToolBarMineralTable.setFloatable(false); jToolBarMineralTable.setFocusable(false); { jButtonNew = new JButton(); jToolBarMineralTable.add(jButtonNew); jButtonNew.setIcon(new ImageIcon(getClass().getClassLoader().getResource( "ar/edu/uns/cs/vyglab/arq/rockar/resources/images/Actions-tab-new-icon.png"))); jButtonNew.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { jButtonNewActionPerformed(evt); } }); } { jButtonOpen = new JButton(); jToolBarMineralTable.add(jButtonOpen); jButtonOpen.setIcon(new ImageIcon(getClass().getClassLoader() .getResource("ar/edu/uns/cs/vyglab/arq/rockar/resources/images/open.png"))); jButtonOpen.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { jButtonOpenActionPerformed(evt); } }); } { jButtonSave = new JButton(); jToolBarMineralTable.add(jButtonSave); jButtonSave.setIcon(new ImageIcon(getClass().getClassLoader() .getResource("ar/edu/uns/cs/vyglab/arq/rockar/resources/images/save.png"))); jButtonSave.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { jButtonSaveActionPerformed(evt); } }); } { jSeparator1 = new JSeparator(); jToolBarMineralTable.add(jSeparator1); jSeparator1.setOrientation(SwingConstants.VERTICAL); jSeparator1.setSize(5, 44); jSeparator1.setPreferredSize(new java.awt.Dimension(5, 44)); } { jButtonAdd = new JButton(); jToolBarMineralTable.add(jButtonAdd); jButtonAdd.setIcon(new ImageIcon(getClass().getClassLoader() .getResource("ar/edu/uns/cs/vyglab/arq/rockar/resources/images/add.png"))); jButtonAdd.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { jButtonAddActionPerformed(evt); } }); } { jButtonEdit = new JButton(); jToolBarMineralTable.add(jButtonEdit); jButtonEdit.setIcon(new ImageIcon(getClass().getClassLoader() .getResource("ar/edu/uns/cs/vyglab/arq/rockar/resources/images/modify.png"))); jButtonEdit.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { jButtonEditActionPerformed(evt); } }); } { jButtonRemove = new JButton(); jToolBarMineralTable.add(jButtonRemove); jButtonRemove.setIcon(new ImageIcon(getClass().getClassLoader() .getResource("ar/edu/uns/cs/vyglab/arq/rockar/resources/images/remove.png"))); jButtonRemove.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { jButtonRemoveActionPerformed(evt); } }); } } { jLabelMineralTableInformation = new JLabel(); jPanelWest.add(jLabelMineralTableInformation, BorderLayout.SOUTH); jLabelMineralTableInformation .setText(DataCenter.langResource.getString("total_counted_table")); jLabelMineralTableInformation.setHorizontalAlignment(SwingConstants.LEFT); jLabelMineralTableInformation.setBackground(new java.awt.Color(255, 212, 133)); jLabelMineralTableInformation.setOpaque(true); } { jScrollPaneMineralTable = new JScrollPane(); jPanelWest.add(jScrollPaneMineralTable, BorderLayout.CENTER); { jTableMineralsModel = new RockTableModel( new String[] { DataCenter.langResource.getString("keyvalue_table"), DataCenter.langResource.getString("name_table"), DataCenter.langResource.getString("color_table"), DataCenter.langResource.getString("counted_table"), DataCenter.langResource.getString("area_table") }, 0); // jTableMineralsModel.addRow(new Object[] { // 0, "x?", Color.gray, 0, // "0.00" }); jTableMinerals = new JReadOnlyTable(); jScrollPaneMineralTable.setViewportView(jTableMinerals); jTableMinerals.setModel(jTableMineralsModel); jTableMinerals.setDefaultRenderer(Color.class, new ColorRenderer(true)); TableCellRenderer centerRenderer = new CenterRenderer(); TableColumn column = jTableMinerals.getColumnModel().getColumn(0); column.setCellRenderer(centerRenderer); column = jTableMinerals.getColumnModel().getColumn(1); column.setCellRenderer(centerRenderer); column = jTableMinerals.getColumnModel().getColumn(3); column.setCellRenderer(centerRenderer); column = jTableMinerals.getColumnModel().getColumn(4); column.setCellRenderer(centerRenderer); } } } { jPanelEast = new JPanel(); jPanelCenter.add(jPanelEast); GridLayout jPanelEastLayout = new GridLayout(2, 1); jPanelEastLayout.setHgap(5); jPanelEastLayout.setVgap(5); jPanelEastLayout.setColumns(1); jPanelEast.setLayout(jPanelEastLayout); { jPanelTop = new JPanel(); BorderLayout jPanelTopLayout = new BorderLayout(); jPanelEast.add(jPanelTop); jPanelTop.setLayout(jPanelTopLayout); jPanelTop.setBorder(new LineBorder(new java.awt.Color(0, 0, 0), 1, false)); { jToolBarStats = new JToolBar(); jPanelTop.add(jToolBarStats, BorderLayout.NORTH); jToolBarStats.setFloatable(false); jToolBarStats.setFocusable(false); { jButtonExportStats = new JButton(); jButtonExportStats.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent arg0) { saveChartAsImage(); } }); //jToolBarStats.add(jButtonExportStats); jButtonExportStats.setIcon(new ImageIcon(getClass().getClassLoader().getResource( "ar/edu/uns/cs/vyglab/arq/rockar/resources/images/export-graph.png"))); } { jButtonExportExcel = new JButton(); //jToolBarStats.add(jButtonExportExcel); //jToolBarMineralTable.add(jButtonExportExcel); jButtonExportExcel.setIcon(new ImageIcon(getClass().getClassLoader().getResource( "ar/edu/uns/cs/vyglab/arq/rockar/resources/images/excel-icon.png"))); jButtonExportExcel.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent arg0) { exportToExcel(); } }); } { jButtonExportAll = new JButton(); //jToolBarStats.add(jButtonExportAll); jButtonExportAll.setIcon(new ImageIcon(getClass().getClassLoader().getResource( "ar/edu/uns/cs/vyglab/arq/rockar/resources/images/Mimetypes-application-vnd-ms-excel-icon.png"))); } } { } } { jPanelBottom = new JPanel(); BorderLayout jPanelBottomLayout = new BorderLayout(); jPanelEast.add(jPanelBottom); jPanelBottom.setLayout(jPanelBottomLayout); jPanelBottom.setBorder(new LineBorder(new java.awt.Color(0, 0, 0), 1, false)); { jToolBarOverview = new JToolBar(); jPanelBottom.add(jToolBarOverview, BorderLayout.NORTH); jToolBarOverview.setFloatable(false); jToolBarOverview.setFocusable(false); { jButtonExportOverview = new JButton(); jToolBarOverview.add(jButtonExportOverview); jButtonExportOverview.setIcon(new ImageIcon(getClass().getClassLoader().getResource( "ar/edu/uns/cs/vyglab/arq/rockar/resources/images/export-graph.png"))); jButtonExportOverview.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent arg0) { exportOverview(); } }); } } { jPanelOverviewContent = new JPanel(); jPanelBottom.add(jPanelOverviewContent, BorderLayout.CENTER); jPanelOverviewContent.setLayout(new GridBagLayout()); this.jLabelOverview = new JLabel(); jPanelOverviewContent.add(this.jLabelOverview); } } } } pack(); this.setSize(800, 600); } catch (Exception e) { //add your error handling code here e.printStackTrace(); } }
From source file:de.codesourcery.jasm16.ide.ui.views.HexDumpView.java
protected JPanel createPanel() { textArea.setEditable(false);/*from w ww . j a va 2 s. c o m*/ setColors(textArea); textArea.setFont(getMonospacedFont()); textArea.setEditable(false); // dump panel final JPanel dumpPanel = new JPanel(); setColors(dumpPanel); dumpPanel.setLayout(new GridBagLayout()); GridBagConstraints cnstrs = constraints(0, 0, true, true, GridBagConstraints.BOTH); dumpPanel.add(textArea, cnstrs); // toolbar panel final JPanel toolbarPanel = new JPanel(); setColors(toolbarPanel); toolbarPanel.setLayout(new GridBagLayout()); cnstrs = constraints(0, 0, false, false, GridBagConstraints.NONE); toolbarPanel.add(new JLabel("Goto"), cnstrs); final JTextField gotoTextfield = new JTextField(); gotoTextfield.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { final String val = gotoTextfield.getText(); Address adr; if (StringUtils.isBlank(val)) { gotoTextfield.setText("0000"); adr = Address.wordAddress(0); } else { try { adr = Address.wordAddress(Misc.parseHexString(val)); } catch (NumberFormatException e1) { gotoTextfield.setText("0000"); adr = Address.wordAddress(0); } } dumpStartAddress = adr; refreshDisplay(); } }); cnstrs = constraints(0, 1, true, true, GridBagConstraints.HORIZONTAL); toolbarPanel.add(gotoTextfield, cnstrs); // create result panel final JPanel result = new JPanel(); setColors(result); result.setLayout(new GridBagLayout()); cnstrs = constraints(0, 0, false, true, GridBagConstraints.BOTH); result.add(dumpPanel, cnstrs); cnstrs = constraints(1, 0, true, true, GridBagConstraints.VERTICAL); result.add(toolbarPanel, cnstrs); textArea.addKeyListener(new PagingKeyAdapter() { @Override protected void onePageUp() { HexDumpView.this.onePageUp(); } @Override protected void onePageDown() { HexDumpView.this.onePageDown(); } @Override protected void oneLineUp() { HexDumpView.this.oneLineUp(); } @Override protected void oneLineDown() { HexDumpView.this.oneLineDown(); } }); result.addComponentListener(new ComponentAdapter() { @Override public void componentResized(ComponentEvent e) { refreshDisplay(); } }); return result; }
From source file:savant.view.swing.Frame.java
/** * Construct a new Frame for holding a track. * * @param df the DataFormat, so the frame can do any format-specific * initialisation (e.g. smaller height for sequence tracks) *//*from w w w.j av a 2 s.co m*/ public Frame(DataFormat df) { super(SavantIconFactory.getInstance().getIcon(SavantIconFactory.StandardIcon.TRACK)); sequence = df == DataFormat.SEQUENCE; // Component which displays the legend component. legend = new JComponent() { @Override public Dimension getPreferredSize() { for (Track t : tracks) { Dimension d = t.getRenderer().getLegendSize(t.getDrawingMode()); if (d != null) { return d; } } return new Dimension(0, 0); } @Override public Dimension getMinimumSize() { return getPreferredSize(); } @Override public void paintComponent(Graphics g) { for (Track t : tracks) { Dimension d = t.getRenderer().getLegendSize(t.getDrawingMode()); if (d != null) { Graphics2D g2 = (Graphics2D) g; GradientPaint gp = new GradientPaint(0, 0, Color.WHITE, 0, 60, new Color(230, 230, 230)); g2.setPaint(gp); g2.fillRect(0, 0, d.width, d.height); g2.setColor(Color.BLACK); g2.draw(new Rectangle2D.Double(0, 0, d.width - 1, d.height - 1)); t.getRenderer().drawLegend(g2, t.getDrawingMode()); return; } } } }; legend.setVisible(false); frameLandscape = new JLayeredPane(); //add graphPane -> jlp -> scrollPane jlp = new JLayeredPane(); jlp.setLayout(new GridBagLayout()); GridBagConstraints gbc = new GridBagConstraints(); gbc.fill = GridBagConstraints.BOTH; gbc.weightx = 1.0; gbc.weighty = 1.0; gbc.gridx = 0; gbc.gridy = 0; //scrollpane JScrollPane scrollPane = new JScrollPane(); scrollPane.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER); scrollPane.setWheelScrollingEnabled(false); scrollPane.setBorder(null); graphPane = new GraphPane(this); jlp.add(graphPane, gbc, 0); scrollPane.getViewport().add(jlp); //GRID FRAMEWORK AND COMPONENT ADDING... frameLandscape.setLayout(new GridBagLayout()); GridBagConstraints c = new GridBagConstraints(); c.fill = GridBagConstraints.HORIZONTAL; //add sidepanel sidePanel = new JPanel() { @Override public Dimension getMinimumSize() { return new Dimension(0, 0); } }; sidePanel.setLayout(new GridBagLayout()); sidePanel.setOpaque(false); sidePanel.setVisible(false); c.weightx = 1.0; c.weighty = 1.0; c.fill = GridBagConstraints.BOTH; c.gridx = 1; c.gridy = 0; c.insets = new Insets(0, 0, 0, 16); // Leave 16 pixels so that we don't sit on top of the scroll-bar. frameLandscape.setLayer(sidePanel, JLayeredPane.PALETTE_LAYER); frameLandscape.add(sidePanel, c); addComponentListener(new ComponentAdapter() { @Override public void componentResized(ComponentEvent e) { Dimension dim = getSize(); if (dim != null) { // TODO: The following shouldn't be necessary, but it seems to be. int expectedWidth = frameLandscape.getWidth(); if (expectedWidth != graphPane.getWidth()) { Dimension goodSize = new Dimension(expectedWidth, graphPane.getHeight()); graphPane.setPreferredSize(goodSize); graphPane.setSize(goodSize); } setLegendVisible(true); } } }); //add graphPane to all cells c.fill = GridBagConstraints.BOTH; c.weightx = 1.0; c.weighty = 1.0; c.gridx = 0; c.gridy = 0; c.gridwidth = 2; c.gridheight = 1; c.insets = new Insets(0, 0, 0, 0); frameLandscape.setLayer(scrollPane, JLayeredPane.DEFAULT_LAYER); frameLandscape.add(scrollPane, c); // Add our progress-panel. If setTracks is called promptly, it will be cleared // away before it ever has a chance to draw. getContentPane().add(new ProgressPanel(null), BorderLayout.CENTER); }
From source file:ro.nextreports.designer.datasource.ConnectionDialog.java
private void create() { this.getContentPane().setLayout(new GridBagLayout()); this.addComponentListener(new ComponentAdapter() { public void componentResized(ComponentEvent e) { resize();// w ww . j a v a 2 s .c o m } }); JPanel p = new JPanel(new GridBagLayout()); backColor = p.getBackground(); mName = new JTextField(); mDriver = new JTextField(); //mDriver.setBackground(backColor); mURL = new JTextField(); //mURL.setBackground(backColor); mUser = new JTextField(); //mUser.setBackground(backColor); mPassword = new JPasswordField(); mPassword.setEchoChar('*'); //mPassword.setBackground(backColor); txaStatus = new JTextArea(); txaStatus.setEditable(false); txaStatus.setBackground(backColor); scr = new JScrollPane(txaStatus); scr.setSize(220, 50); scr.setBorder(new TitledBorder(STATUS)); types = new JComboBox(); types.addItemListener(this); urlFormatLabel = new JLabel(); Font font = urlFormatLabel.getFont().deriveFont(Font.BOLD, 10); urlFormatLabel.setFont(font); urlButton = new JButton(); urlButton.setPreferredSize(buttonDim); urlButton.setMinimumSize(buttonDim); urlButton.setMaximumSize(buttonDim); urlButton.setIcon(ImageUtil.getImageIcon("url_edit")); urlButton.setToolTipText(I18NSupport.getString("connection.dialog.tags.tooltip")); urlButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { editUrl(); } }); for (DriverTemplate template : templates) { types.addItem(template.getType()); } types.setSelectedItem(DEFAULT_DRIVER_TYPE); auto = new JCheckBox(I18NSupport.getString("connection.dialog.auto")); if (viewOnly) { mName.setEditable(false); types.setEnabled(false); mDriver.setEditable(false); mURL.setEditable(false); mUser.setEditable(false); mPassword.setEditable(false); urlButton.setEnabled(false); } p.add(new JLabel(I18NSupport.getString("connection.dialog.name")), new GridBagConstraints(0, 0, 1, 1, 0.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(5, 5, 5, 0), 0, 0)); p.add(mName, new GridBagConstraints(1, 0, 2, 1, 1.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(5, 5, 5, 5), 0, 0)); p.add(new JLabel(I18NSupport.getString("connection.dialog.type")), new GridBagConstraints(0, 1, 1, 1, 0.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(5, 5, 5, 0), 0, 0)); p.add(types, new GridBagConstraints(1, 1, 2, 1, 1.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(5, 5, 5, 5), 0, 0)); p.add(new JLabel(I18NSupport.getString("connection.dialog.driver")), new GridBagConstraints(0, 2, 1, 1, 0.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(5, 5, 5, 0), 0, 0)); p.add(mDriver, new GridBagConstraints(1, 2, 2, 1, 1.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(5, 5, 5, 5), 0, 0)); p.add(new JLabel(I18NSupport.getString("connection.dialog.url")), new GridBagConstraints(0, 3, 1, 1, 0.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(5, 5, 5, 0), 0, 0)); p.add(mURL, new GridBagConstraints(1, 3, 1, 1, 1.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(5, 5, 5, 0), 0, 0)); p.add(urlButton, new GridBagConstraints(2, 3, 1, 1, 0.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(5, 5, 5, 5), 0, 0)); if (!viewOnly) { p.add(urlFormatLabel, new GridBagConstraints(1, 4, 2, 1, 1.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(0, 5, 5, 5), 0, 0)); } p.add(new JLabel(I18NSupport.getString("connection.dialog.user")), new GridBagConstraints(0, 5, 1, 1, 0.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(5, 5, 5, 0), 0, 0)); p.add(mUser, new GridBagConstraints(1, 5, 2, 1, 1.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(5, 5, 5, 5), 0, 0)); p.add(new JLabel(I18NSupport.getString("connection.dialog.password")), new GridBagConstraints(0, 6, 1, 1, 0.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(5, 5, 5, 0), 0, 0)); p.add(mPassword, new GridBagConstraints(1, 6, 2, 1, 1.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(5, 5, 5, 5), 0, 0)); if (!viewOnly) { p.add(auto, new GridBagConstraints(1, 7, 2, 1, 1.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(5, 5, 5, 5), 0, 0)); } JButton okBtn, disBtn, drvBtn, addBtn, propBtn; okBtn = new JButton(I18NSupport.getString("connection.dialog.test"), ImageUtil.getImageIcon("database_connect")); okBtn.setMnemonic('T'); okBtn.setActionCommand("ConnectOk"); okBtn.setToolTipText(I18NSupport.getString("connection.dialog.test.tooltip")); okBtn.addActionListener(this); disBtn = new JButton(I18NSupport.getString("connection.dialog.disconnect"), ImageUtil.getImageIcon("database")); disBtn.setMnemonic('D'); disBtn.setActionCommand("Disconnect"); disBtn.setToolTipText(I18NSupport.getString("connection.dialog.disconnect")); disBtn.addActionListener(this); drvBtn = new JButton(I18NSupport.getString("connection.dialog.add.driver"), ImageUtil.getImageIcon("add_driver")); drvBtn.setMnemonic('A'); drvBtn.setActionCommand("AddDriver"); drvBtn.setToolTipText(I18NSupport.getString("connection.dialog.add.driver.tooltip")); drvBtn.addActionListener(this); propBtn = new JButton(I18NSupport.getString("connection.dialog.properties"), ImageUtil.getImageIcon("properties")); propBtn.setMnemonic('P'); propBtn.setActionCommand("Properties"); propBtn.setToolTipText(I18NSupport.getString("connection.dialog.properties.tooltip")); propBtn.addActionListener(this); addBtn = new JButton(ImageUtil.getImageIcon("database_export")); if (oldDataSource == null) { addBtn.setText(I18NSupport.getString("connection.dialog.save")); addBtn.setToolTipText(I18NSupport.getString("connection.dialog.save.tooltip")); addBtn.setMnemonic('S'); } else { addBtn.setText(I18NSupport.getString("connection.dialog.modify")); addBtn.setToolTipText(I18NSupport.getString("connection.dialog.modify.tooltip")); addBtn.setMnemonic('M'); } addBtn.setActionCommand("AddDataSource"); addBtn.addActionListener(this); JPanel btnPanel = new JPanel(); btnPanel.setLayout(new BoxLayout(btnPanel, BoxLayout.X_AXIS)); btnPanel.add(Box.createHorizontalGlue()); btnPanel.add(propBtn); btnPanel.add(Box.createRigidArea(new Dimension(5, 5))); btnPanel.add(okBtn); btnPanel.add(Box.createRigidArea(new Dimension(5, 5))); //btnPanel.add(disBtn); //btnPanel.add(Box.createRigidArea(new Dimension(5, 5))); btnPanel.add(addBtn); // btnPanel.add(Box.createRigidArea(new Dimension(5, 5))); // btnPanel.add(drvBtn); SwingUtil.equalizeButtonSizes(btnPanel); if (!viewOnly) { p.add(btnPanel, new GridBagConstraints(0, 8, 3, 1, 1.0, 0.0, GridBagConstraints.EAST, GridBagConstraints.HORIZONTAL, new Insets(5, 5, 5, 5), 0, 0)); p.add(scr, new GridBagConstraints(0, 9, 3, 1, 1.0, 1.0, GridBagConstraints.EAST, GridBagConstraints.BOTH, new Insets(5, 5, 5, 5), 0, 0)); } this.getContentPane().add(p, new GridBagConstraints(0, 0, 1, 1, 1.0, 1.0, GridBagConstraints.EAST, GridBagConstraints.BOTH, new Insets(5, 5, 5, 5), 0, 0)); if (oldDataSource != null) { mName.setText(oldDataSource.getName()); types.setSelectedItem(oldDataSource.getType()); mDriver.setText(oldDataSource.getDriver()); mURL.setText(oldDataSource.getUrl()); mUser.setText(oldDataSource.getUser()); mPassword.setText(oldDataSource.getPassword()); } }
From source file:org.metacsp.utility.UI.FiniteStateAutomatonFrame.java
public FiniteStateAutomatonFrame(ObservableGraph<String[], Interval> graph) { super("Constraint Network"); g = graph;/*from w w w .j a v a 2 s . co m*/ g.addGraphEventListener(new GraphEventListener<String[], Interval>() { public void handleGraphEvent(GraphEvent<String[], Interval> evt) { System.err.println("got " + evt); /****/ vv.getRenderContext().getPickedVertexState().clear(); vv.getRenderContext().getPickedEdgeState().clear(); try { layout.initialize(); try { Relaxer relaxer = new VisRunner((IterativeContext) layout); relaxer.stop(); relaxer.prerelax(); } catch (java.lang.ClassCastException e) { } StaticLayout<String[], Interval> staticLayout = new StaticLayout<String[], Interval>(g, layout); LayoutTransition<String[], Interval> lt = new LayoutTransition<String[], Interval>(vv, vv.getGraphLayout(), staticLayout); Animator animator = new Animator(lt); animator.start(); // vv.getRenderContext().getMultiLayerTransformer().setToIdentity(); vv.repaint(); } catch (Exception e) { System.out.println(e); } /****/ } }); //create a graphdraw //layout = new FRLayout<State,Interval>(g); //layout = new SpringLayout<State,Interval>(g); //layout = new StaticLayout<State,Interval>(g,new STNTransformer()); layout = new FRLayout2<String[], Interval>(g); //layout = new CircleLayout<State,Interval>(g); //layout = new ISOMLayout<State,Interval>(g); //layout = new KKLayout<State,Interval>(g); layout.setSize(new Dimension(600, 600)); try { Relaxer relaxer = new VisRunner((IterativeContext) layout); relaxer.stop(); relaxer.prerelax(); } catch (java.lang.ClassCastException e) { } Layout<String[], Interval> staticLayout = new StaticLayout<String[], Interval>(g, layout); vv = new VisualizationViewer<String[], Interval>(staticLayout, new Dimension(600, 600)); 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, 12)); vv.setGraphMouse(new DefaultModalGraphMouse<String[], Interval>()); vv.getRenderer().getVertexLabelRenderer().setPosition(Renderer.VertexLabel.Position.S); vv.getRenderContext().setVertexLabelTransformer(new ToStringLabeller<String[]>()); vv.setForeground(Color.black); //draw edge labels Transformer<Interval, String> stringer = new Transformer<Interval, String>() { public String transform(Interval e) { return e.toString(); } }; vv.getRenderContext().setEdgeLabelTransformer(stringer); vv.getRenderContext().setEdgeDrawPaintTransformer( new PickableEdgePaintTransformer<Interval>(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); System.err.println("resized"); layout.setSize(arg0.getComponent().getSize()); } }); getContentPane().add(vv); switchLayout = new JButton("Switch to SpringLayout"); switchLayout.addActionListener(new ActionListener() { @SuppressWarnings("unchecked") public void actionPerformed(ActionEvent ae) { Dimension d = vv.getSize();//new Dimension(600,600); if (switchLayout.getText().indexOf("Spring") > 0) { switchLayout.setText("Switch to FRLayout"); //layout = new SpringLayout<State,Interval>(g, new ConstantTransformer(EDGE_LENGTH)); layout = new SpringLayout<String[], Interval>(g); layout.setSize(d); try { Relaxer relaxer = new VisRunner((IterativeContext) layout); relaxer.stop(); relaxer.prerelax(); } catch (java.lang.ClassCastException e) { } StaticLayout<String[], Interval> staticLayout = new StaticLayout<String[], Interval>(g, layout); LayoutTransition<String[], Interval> lt = new LayoutTransition<String[], Interval>(vv, vv.getGraphLayout(), staticLayout); Animator animator = new Animator(lt); animator.start(); // vv.getRenderContext().getMultiLayerTransformer().setToIdentity(); vv.repaint(); } else { switchLayout.setText("Switch to SpringLayout"); layout = new FRLayout<String[], Interval>(g, d); layout.setSize(d); try { Relaxer relaxer = new VisRunner((IterativeContext) layout); relaxer.stop(); relaxer.prerelax(); } catch (java.lang.ClassCastException e) { } StaticLayout<String[], Interval> staticLayout = new StaticLayout<String[], Interval>(g, layout); LayoutTransition<String[], Interval> lt = new LayoutTransition<String[], Interval>(vv, vv.getGraphLayout(), staticLayout); Animator animator = new Animator(lt); animator.start(); // vv.getRenderContext().getMultiLayerTransformer().setToIdentity(); vv.repaint(); } } }); getContentPane().add(switchLayout, BorderLayout.SOUTH); this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); this.pack(); this.setVisible(true); }
From source file:tvbrowser.extras.favoritesplugin.wizards.TypeWizardStep.java
public JPanel createContent(final WizardHandler handler) { LinkButton expertBtn = new LinkButton(mLocalizer.msg("advancedView", "Switch to expert view"), null); CellConstraints cc = new CellConstraints(); PanelBuilder panelBuilder = new PanelBuilder( new FormLayout("5dlu, pref, default:grow", "pref, 5dlu, pref, 5dlu, pref, 5dlu, pref, 5dlu, pref")); panelBuilder.add(new JLabel(mMainQuestion), cc.xyw(1, 1, 3)); panelBuilder.add(mTitleRb = new JRadioButton(mLocalizer.msg("option.title", "I like this program:")), cc.xy(2, 3));//from w w w .j a va 2 s .co m panelBuilder.add(mProgramNameTf = new JTextField(), cc.xy(3, 3)); panelBuilder.add(mTopicRb = new JRadioButton(mLocalizer.msg("option.topic", "I like this subject:")), cc.xy(2, 5)); panelBuilder.add(mTopicTf = new JTextField(), cc.xy(3, 5)); panelBuilder.add(mActorsRb = new JRadioButton(mLocalizer.msg("option.actors", "I like these actors:")), cc.xy(2, 7)); mActorsCb = new JComboBox(); mActorsCb.setEditable(true); panelBuilder.add(mActorsCb, cc.xy(3, 7)); panelBuilder.setBorder(Borders.DLU4_BORDER); panelBuilder.add(expertBtn, cc.xyw(1, 9, 3)); ButtonGroup group = new ButtonGroup(); group.add(mTitleRb); group.add(mTopicRb); group.add(mActorsRb); mTitleRb.setSelected(true); updateTextfields(); mTitleRb.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { updateTextfields(); } }); mTopicRb.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { updateTextfields(); } }); mActorsRb.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { updateTextfields(); } }); expertBtn.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { handler.closeCurrentStep(); String title; if (mProgram != null) { title = mProgram.getTitle(); } else { title = ""; } AdvancedFavorite favorite = new AdvancedFavorite(title); Window parent = UiUtilities.getLastModalChildOf(MainFrame.getInstance()); EditFavoriteDialog dlg = new EditFavoriteDialog(parent, favorite); UiUtilities.centerAndShow(dlg); if (dlg.getOkWasPressed()) { FavoriteTreeModel.getInstance().addFavorite(favorite, mParentNode); FavoritesPlugin.getInstance().updateRootNode(true); if (ManageFavoritesDialog.getInstance() != null) { ManageFavoritesDialog.getInstance().addFavorite(favorite, false); } } } }); if (mProgram != null) { mProgramNameTf.setText(mProgram.getTitle()); String[] actors = ProgramUtilities.getActorNames(mProgram); if (actors != null) { for (String actor : actors) { mActorsCb.addItem(actor); } } } mContent = panelBuilder.getPanel(); mContent.addComponentListener(new ComponentAdapter() { public void componentResized(ComponentEvent e) { handleFocusEvent(); } }); mContent.addFocusListener(new FocusAdapter() { public void focusGained(FocusEvent e) { handleFocusEvent(); } }); if (mTopic != null) { mTopicRb.setSelected(true); updateTextfields(); mTopicTf.setText(mTopic); // the topic might also be an actor name if (mActor == null && ProgramUtilities.getActorNames(mProgram) == null) { mActorsCb.setSelectedItem(mTopic); } } else if (mActor != null) { mActorsRb.setSelected(true); updateTextfields(); mActorsCb.setSelectedItem(mActor); } return mContent; }