public IndicatorToolbox() { super(JToolBar.HORIZONTAL); setOpaque(false); setBorder(BorderFactory.createEmptyBorder(2, 2, 2, 2)); indicatorLabel = new JLabel(indicator.getLabel()); indicatorLabel.setHorizontalTextPosition(SwingConstants.LEFT); indicatorLabel.setVerticalTextPosition(SwingConstants.CENTER); indicatorLabel.setOpaque(false); add(indicatorLabel); container = new JPanel(); container.setOpaque(false); container.setLayout(new BoxLayout(container, BoxLayout.X_AXIS)); add(container); update(); addMouseListener( new MouseAdapter() { public @Override void mouseEntered(MouseEvent e) { mouseOver = true; validate(); repaint(); } public @Override void mouseExited(MouseEvent e) { setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR)); mouseOver = false; validate(); repaint(); } }); }
/** * Start layout determining. If it is needed, a dummy component will be created as first row. This * will be done, if the IzPack guiprefs modifier with the key "layoutAnchor" has the value "SOUTH" * or "SOUTHWEST". The earlier used value "BOTTOM" and the declaration via the IzPack variable * <code>IzPanel.LayoutType</code> are also supported. */ private void startGridBagLayout() { if (layoutStarted) { return; } layoutStarted = true; if (izPanelLayout == null || !(izPanelLayout instanceof GridBagLayout)) { izPanelLayout = new GridBagLayout(); } GridBagConstraints dgbc = new GridBagConstraints(); dgbc.insets = new Insets(0, 0, getYGap(LABEL_GAP), 0); dgbc.anchor = GridBagConstraints.WEST; defaultConstraints = dgbc; parent.setLayout(izPanelLayout); switch (getAnchor()) { case SOUTH: case SOUTH_WEST: // Make a header to push the rest to the bottom. IzPanel.Filler dummy = new IzPanel.Filler(); GridBagConstraints gbConstraint = (GridBagConstraints) getNextYConstraints(); gbConstraint.weighty = 1.0; gbConstraint.fill = GridBagConstraints.BOTH; gbConstraint.anchor = GridBagConstraints.WEST; parent.add(dummy, gbConstraint); break; default: break; } // TODO: impl for layout type CENTER, ... }
/** * Creates a layout manager for special purpose. * * @param parent for which this layout manager will be used * @param installData the installation data */ public LayoutHelper(JComponent parent, InstallData installData) { this(installData); this.parent = parent; izPanelLayout = new GridBagLayout(); parent.setLayout(izPanelLayout); gridyCounter++; }
@Override public JComponent createForm() { JComponent component = super.createForm(); annotationComboBox.setRenderer( new DefaultListCellRenderer() { @Override public Component getListCellRendererComponent( JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) { super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus); if (value != null) { Annotation annotation = (Annotation) value; this.setText(annotation.getBrief()); } else { this.setText("-- select annotation --"); } return this; } }); component.setLayout(new FormLayout("right:p, 4dlu, left:p", "p, 4dlu, p, 4dlu, p, 4dlu, p")); CellConstraints cc = new CellConstraints(); component.add(getLabel("annotationLabel"), cc.xy(1, 1)); component.add(annotationComboBox, cc.xy(3, 1)); component.add(getLabel("patternLabel"), cc.xy(1, 3)); component.add(patternField, cc.xy(3, 3)); component.add(getLabel("ciLabel"), cc.xy(1, 5)); component.add(caseInsensitive, cc.xy(3, 5)); component.add(getLabel("remove"), cc.xy(1, 7)); component.add(removeMatched, cc.xy(3, 7)); patternField.setEnabled(false); caseInsensitive.setSelected(true); caseInsensitive.setEnabled(false); // action listener will fill out a suggested pattern for selected annotation types annotationComboBox.addActionListener( new ActionListener() { @Override public void actionPerformed(ActionEvent e) { Object obj = annotationComboBox.getSelectedItem(); if (obj == null) { patternField.setEnabled(false); caseInsensitive.setEnabled(false); setEnabled(false); } else { patternField.setEnabled(true); caseInsensitive.setEnabled(true); patternField.setText(getDefault(obj.getClass())); patternField.setCaretPosition(0); setEnabled(true); } } }); return component; }
public ResultProperties(int i, int i0, ArrayList<String[]> result, TransferContainer tc) { w = i; h = i0; setBackground(java.awt.Color.getHSBColor(tc.c1[0], tc.c1[1], tc.c1[2])); searchedProperties = new ResultUnit[result.size()]; amount = result.size(); for (int a = 0; a < searchedProperties.length; a++) { searchedProperties[a] = new ResultUnit(w, this); searchedProperties[a].propertyID = Integer.parseInt(result.get(a)[0]); searchedProperties[a].duchy = result.get(a)[2]; switch (result.get(a)[4]) { case "Poor": searchedProperties[a].quality = 1; break; case "Fine": searchedProperties[a].quality = 2; break; default: searchedProperties[a].quality = 3; break; } searchedProperties[a].size = Integer.parseInt(result.get(a)[3]); searchedProperties[a].tiles = tc.rdb.convertFromArray(result.get(a)[5]); searchedProperties[a].buildings = tc.rdb.convertFromArray(result.get(a)[6]); searchedProperties[a].init(tc); } JComponent panel1 = makePanel("Panel #1", 1); GridLayout experimentLayout = new GridLayout(0, 1); panel1.setLayout(experimentLayout); panel1.setBackground(java.awt.Color.getHSBColor(tc.c1[0], tc.c1[1], tc.c1[2])); add(panel1); }
static JComponent createENV() { pp = new EnvelopeDisplay(); JComponent pan = new JPanel(); pan.setLayout(new BorderLayout()); pan.add(pp, BorderLayout.CENTER); JComponent panC = new JPanel(); pan.add(new JScrollPane(panC), BorderLayout.SOUTH); panC.setLayout(new GridLayout(0, 1)); panC.add(new JLabel("time:")); panC.add(lblPan(1, new ResonanceChanger())); panC.add(lblPan(2, new CutOffChanger())); panC.add(lblPan(3, new TypeChanger())); // panC.add(lblPan(4,new ReleaseChanger())); // panC.add(new JLabel("curve:")); // for (int i=0;i<sh.getSegmentCount()-1;i++) // panC.add(lblPan(i,new CurveTypeChange(i))); // // JCheckBox cb = new JCheckBox("inverse"); // panC.add(cb); // cb.addActionListener(new ActionListener(){ // // public void actionPerformed( ActionEvent e ) // { // sh.setIsInverse( ((JCheckBox)e.getSource()).isSelected()); // pp.repaint(); // }}); // JCheckBox cf = new JCheckBox("fill"); // panC.add(cf); // cf.addActionListener(new ActionListener(){ // // public void actionPerformed( ActionEvent e ) // { // doFill = ((JCheckBox)e.getSource()).isSelected(); // pp.repaint(); // }}); return pan; }
/** Special start method for IzPanelLayout. Called from <code>startLayout</code>. */ private void startIzPanelLayout() { IzPanelLayout.setAnchor(getAnchor()); IzPanelLayout.setXStretchType(getXStretchType()); IzPanelLayout.setYStretchType(getYStretchType()); IzPanelLayout.setFullLineStretch(getFullLineStretch()); IzPanelLayout.setFullColumnStretch(getFullColumnStretch()); getXGap(LABEL_GAP); // This call triggers resolving external setting if not already done. getYGap(LABEL_GAP); // This call triggers resolving external setting if not already done. parent.setLayout(izPanelLayout); // parent.add(IzPanelLayout.createGap(TOP_GAP, VERTICAL)); }
/** * DOCUMENT ME! * * @param vali DOCUMENT ME! */ public void reSetValidator(final Validatable vali) { if (vali == null) { log.warn("VALI == NULL"); iconContainer.setVisible(false); } else { this.vali = vali; comp.remove(iconContainer); iconContainer.setVisible(true); comp.setLayout(new java.awt.BorderLayout()); comp.add(iconContainer, java.awt.BorderLayout.EAST); vali.addValidationStateChangedListener(this); // TODO SIGNATURE CHANGED -- UGLY better possibilites ?? validationStateChanged(null); } }
@Inject public AllocatableEditUI(RaplaContext context) throws RaplaException { super(context); classificationField = new ClassificationField<Allocatable>(context); permissionField = new PermissionListField(context, getString("permissions")); permissionField.setPermissionLevels( Permission.DENIED, Permission.READ_NO_ALLOCATION, Permission.READ, Permission.ALLOCATE, Permission.ALLOCATE_CONFLICTS, Permission.EDIT, Permission.ADMIN); final JComponent permissionPanel = permissionField.getComponent(); editPanel.setLayout(new BorderLayout()); editPanel.add(classificationField.getComponent(), BorderLayout.CENTER); holdBackConflictsField = new BooleanField(context, getString("holdbackconflicts")); holdBackConflictPanel = new JPanel(); holdBackConflictPanel.setLayout(new BorderLayout()); holdBackConflictPanel.add( new JLabel(holdBackConflictsField.getFieldName() + ": "), BorderLayout.WEST); holdBackConflictPanel.add(holdBackConflictsField.getComponent(), BorderLayout.CENTER); classificationField.addChangeListener( new ChangeListener() { @Override public void stateChanged(ChangeEvent e) { final boolean mainTabSelected = classificationField.isMainTabSelected(); permissionPanel.setVisible(!mainTabSelected); if (!mainTabSelected && !editPanel.isAncestorOf(permissionPanel)) { editPanel.remove(holdBackConflictPanel); editPanel.add(permissionPanel, BorderLayout.SOUTH); editPanel.repaint(); } if (mainTabSelected && (!editPanel.isAncestorOf(holdBackConflictPanel))) { editPanel.remove(permissionPanel); editPanel.add(holdBackConflictPanel, BorderLayout.SOUTH); editPanel.repaint(); } AllocatableEditUI.this.stateChanged(e); } }); editPanel.setPreferredSize(new Dimension(800, 600)); }
@edu.umd.cs.findbugs.annotations.SuppressWarnings( value = "ST_WRITE_TO_STATIC_FROM_INSTANCE_METHOD", justification = "only one application at a time") protected void setJynstrumentSpace() { _jynstrumentSpace = new JPanel(); _jynstrumentSpace.setLayout(new FlowLayout()); new FileDrop( _jynstrumentSpace, new Listener() { @Override public void filesDropped(File[] files) { for (int i = 0; i < files.length; i++) { ynstrument(files[i].getPath()); } } }); }
/** * Constructs a popup using the specified settings. * * @param content The component that represents the popup content. * @param hideOnClick If <code>true</code> then the popup will hide when any area outside of it is * clicked (rather like a popup menu). If <code>false</code> the popup will not hide when any * area outside of it is clicked. * @param timerDelay The number of milliseconds after which the the popup will automatically hide * itself. If a value of zero is specified, then the popup will remain displayed indefinitely. * @param isModal If <code>true</code>, mouse listener events that occur outside the component * area are forwarded to the appropriate component in the content pane i.e other components * may be interacted with whilst the popup is displayed. If <code>false</code> then the popup * behaves rather like a modal dialog, so that no other components can receive mouse events * until the component has closed. */ public PopupComponent(JComponent content, boolean hideOnClick, int timerDelay, boolean isModal) { glassPane = new JPanel(null); glassPane.setLayout(null); glassPane.add(content); glassPane.setOpaque(false); listeners = new ArrayList<PopupComponentListener>(); setupListeners(); setContent(content); this.HIDE_ON_CLICK = hideOnClick; this.POPUP_IS_MODAL = isModal; // Check to see if a timer delay has been // specified. If so, set up the timer. if (timerDelay > 0) { HIDE_ON_TIMER = true; HIDE_TIMER_DELAY = timerDelay; timer = new Timer( HIDE_TIMER_DELAY, new ActionListener() { public void actionPerformed(ActionEvent e) { // Hide the popup if the mouse is outside // the content if (mouseOverGlassPane == true) { hidePopup(); timer.stop(); } else { timer.stop(); timer.start(); } } }); } }
/** * Creates a new instance of Validator. * * @param comp DOCUMENT ME! */ public Validator(final javax.swing.JComponent comp) { this.comp = comp; // comp.setBackground(Color.red); iconContainer.setHorizontalAlignment(javax.swing.SwingConstants.RIGHT); iconContainer.setVerticalAlignment(javax.swing.SwingConstants.TOP); iconContainer.setCursor(java.awt.Cursor.getPredefinedCursor(java.awt.Cursor.DEFAULT_CURSOR)); // iconContainer.setText("LALAL"); comp.setLayout(new java.awt.BorderLayout()); comp.add(iconContainer, java.awt.BorderLayout.EAST); iconContainer.setVisible(true); iconContainer.addMouseListener( new java.awt.event.MouseAdapter() { @Override public void mouseClicked(final java.awt.event.MouseEvent evt) { iconContainerMouseClicked(evt); } }); }
private void initProblemDefinition() { this.m_Mocco.m_JPanelParameters.removeAll(); this.m_ProblemChooser = new JComboBox(); JComponent tmpC = new JPanel(); tmpC.setLayout(new BorderLayout()); Class[] altern = null; try { altern = ReflectPackage.getAssignableClassesInPackage( "eva2.server.go.problems", Class.forName("eva2.server.go.problems.InterfaceMultiObjectiveDeNovoProblem"), true, true); } catch (ClassNotFoundException e) { // TODO Auto-generated catch block e.printStackTrace(); } this.m_ProblemChooser.setModel(new DefaultComboBoxModel(altern)); String objectName = (this.m_Mocco.m_State.m_OriginalProblem.getClass().getName()); this.m_ProblemChooser.getModel().setSelectedItem(objectName); this.m_ProblemChooser.addActionListener(problemChanged); JPanel tmpP = new JPanel(); tmpP.setLayout(new GridBagLayout()); GridBagConstraints gbc = new GridBagConstraints(); gbc.fill = GridBagConstraints.HORIZONTAL; gbc.gridx = 0; gbc.gridy = 0; tmpP.add( this.makeHelpText( "Choose and parameterize the optimization problem to solve by means of MOCCO. " + "Please note that it is not necessary to include MOSO converters yet and that only problems complying " + "with the InterfaceMultiObjectiveDeNovoProblem can be optimized using the MOCCO approach."), gbc); gbc.gridx = 0; gbc.gridy = 1; tmpP.add(this.m_ProblemChooser, gbc); this.m_Mocco.m_JPanelParameters.setLayout(new BorderLayout()); this.m_Mocco.m_JPanelParameters.add(tmpP, BorderLayout.NORTH); JParaPanel paraPanel = new JParaPanel(this.m_Mocco.m_State.m_OriginalProblem, "MyGUI"); this.m_Mocco.m_JPanelParameters.add(paraPanel.makePanel(), BorderLayout.CENTER); }
/** Creates the panel where the criteria list will be shown */ private JComponent createCriteriaPanel() { JPanel criteriaPanel = new JPanel(); criteriaPanel.setLayout(null); criteriaPanel.setPreferredSize(new Dimension(360, 125)); criteriaPanel.setBorder( BorderFactory.createTitledBorder( I18N.getString("AttributeResearchPanel.attributeBasedCriteria"))); criteriaPanel.setBounds(LEFT_MARGIN, 70, 360, 125); attLabel = new JLabel(I18N.getString("AttributeResearchPanel.attribute")); attLabel.setBounds(LEFT_MARGIN, 18, SECOND_COL - LEFT_MARGIN, STD_HEIGHT); criteriaPanel.add(attLabel); operLabel = new JLabel(I18N.getString("AttributeResearchPanel.operator")); operLabel.setBounds(LEFT_MARGIN + SECOND_COL + 5, 18, THIRD_COL - SECOND_COL, STD_HEIGHT); criteriaPanel.add(operLabel); valLabel = new JLabel(I18N.getString("AttributeResearchPanel.comparisonValue")); valLabel.setBounds(LEFT_MARGIN + THIRD_COL + 5, 18, SECOND_COL - LEFT_MARGIN, STD_HEIGHT); criteriaPanel.add(valLabel); setHeadersEnabled(false); criteriaListPanel = new JPanel() { private static final long serialVersionUID = -7342449173372211027L; @Override public Dimension getPreferredSize() { return new Dimension(300, 400); } }; criteriaListPanel.setBounds(LEFT_MARGIN, 40, 360, 400); criteriaListPanel.setOpaque(false); criteriaListPanel.setLayout(null); criteriaPanel.add(criteriaListPanel); return criteriaPanel; }
public EditSemester_Gui(String s) { super(new GridLayout(2, 1)); frame.setIconImage( Toolkit.getDefaultToolkit().getImage(getClass().getResource("/images/icon.png"))); Dimension d1 = new Dimension(400, 800); Dimension d2 = new Dimension(900, 800); Dimension d3 = new Dimension(200, 800); Dimension d4 = new Dimension(1500, 800); tabbedPane1 = new MainPanel1_EditSemester_Gui(s); tabbedPane2 = new MainPanel2_EditSemester_Gui(s); tabbedPane3 = new MainPanel3_EditSemester_Gui(s); pnlAll = new JPanel(); pnlAll.setPreferredSize(d4); pnlAll.setLayout(new BoxLayout(pnlAll, BoxLayout.X_AXIS)); pnlTreeContainer = new JPanel(); pnlTreeContainer.setPreferredSize(d3); pnlTreeContainer.add(tabbedPane3); pnlSettings = new JPanel(); pnlSettings.setPreferredSize(d1); pnlSettings.add(tabbedPane1); pnlSemester = new JPanel(); pnlSemester.setPreferredSize(d2); pnlSemester.add(tabbedPane2); // Add the tabbed pane to this panel. initTabComponent(0); initTabComponent2(0); initTabComponent3(0); pnlAll.add(pnlTreeContainer); pnlAll.add(pnlSemester); pnlAll.add(pnlSettings); add(pnlAll); }
@Override public void setParent(final JComponent parent) { SwingUtilities.invokeLater( () -> { final JScrollPane scrollPane = new JScrollPane(tree); scrollPane.setAutoscrolls(true); scrollPane.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER); parent.setVisible(false); parent.setLayout(new MigLayout("ins 0, fill")); parent.add(scrollPane, "grow"); parent.setFocusable(false); parent.setVisible(true); setColours(); eventBus.subscribe(this); swingEventBus.subscribe(this); redoTreeView(); }); }
private void initComponents() { buttonsPanel = new JPanel(); buttonsPanel.setLayout(new GridLayout(0, 1, 3, 3)); Action action; action = new ManageBookmarksAction( VFSResources.getMessage("VFSJFileChooser.bookmarksLabelText"), getIcon("book.png")); bookmarksButton = new JButton(action); bookmarksButton.setHorizontalAlignment(SwingConstants.LEFT); action = new ConnectionWizardAction( VFSResources.getMessage("VFSJFileChooser.connectionButtonText"), getIcon("connect.png")); connectionsButton = new JButton(action); connectionsButton.setHorizontalAlignment(SwingConstants.LEFT); action = new LocalFilesAction( VFSResources.getMessage("VFSJFileChooser.localFilesButtonText"), getIcon("drive.png")); localFSButton = new JButton(action); localFSButton.setHorizontalAlignment(SwingConstants.LEFT); buttonsPanel.add(bookmarksButton); buttonsPanel.add(Box.createVerticalStrut(20)); buttonsPanel.add(connectionsButton); buttonsPanel.add(Box.createVerticalStrut(20)); buttonsPanel.add(localFSButton); add(buttonsPanel, BorderLayout.NORTH); add(new JPanel(), BorderLayout.CENTER); final Frame c = (Frame) SwingUtilities.getWindowAncestor(fileChooser); bookmarksDialog = new BookmarksDialog(c, fileChooser); connectionDialog = new ConnectionDialog(c, bookmarksDialog, fileChooser); }
public static void main(String args[]) { JComponent ch = new JComponent() {}; ch.getAccessibleContext(); ch.isFocusTraversable(); ch.setEnabled(false); ch.setEnabled(true); ch.requestFocus(); ch.requestFocusInWindow(); ch.getPreferredSize(); ch.getMaximumSize(); ch.getMinimumSize(); ch.contains(1, 2); Component c1 = ch.add(new Component() {}); Component c2 = ch.add(new Component() {}); Component c3 = ch.add(new Component() {}); Insets ins = ch.getInsets(); ch.getAlignmentY(); ch.getAlignmentX(); ch.getGraphics(); ch.setVisible(false); ch.setVisible(true); ch.setForeground(Color.red); ch.setBackground(Color.red); for (String font : Toolkit.getDefaultToolkit().getFontList()) { for (int j = 8; j < 17; j++) { Font f1 = new Font(font, Font.PLAIN, j); Font f2 = new Font(font, Font.BOLD, j); Font f3 = new Font(font, Font.ITALIC, j); Font f4 = new Font(font, Font.BOLD | Font.ITALIC, j); ch.setFont(f1); ch.setFont(f2); ch.setFont(f3); ch.setFont(f4); ch.getFontMetrics(f1); ch.getFontMetrics(f2); ch.getFontMetrics(f3); ch.getFontMetrics(f4); } } ch.enable(); ch.disable(); ch.reshape(10, 10, 10, 10); ch.getBounds(new Rectangle(1, 1, 1, 1)); ch.getSize(new Dimension(1, 2)); ch.getLocation(new Point(1, 2)); ch.getX(); ch.getY(); ch.getWidth(); ch.getHeight(); ch.isOpaque(); ch.isValidateRoot(); ch.isOptimizedDrawingEnabled(); ch.isDoubleBuffered(); ch.getComponentCount(); ch.countComponents(); ch.getComponent(1); ch.getComponent(2); Component[] cs = ch.getComponents(); ch.getLayout(); ch.setLayout(new FlowLayout()); ch.doLayout(); ch.layout(); ch.invalidate(); ch.validate(); ch.remove(0); ch.remove(c2); ch.removeAll(); ch.preferredSize(); ch.minimumSize(); ch.getComponentAt(1, 2); ch.locate(1, 2); ch.getComponentAt(new Point(1, 2)); ch.isFocusCycleRoot(new Container()); ch.transferFocusBackward(); ch.setName("goober"); ch.getName(); ch.getParent(); ch.getGraphicsConfiguration(); ch.getTreeLock(); ch.getToolkit(); ch.isValid(); ch.isDisplayable(); ch.isVisible(); ch.isShowing(); ch.isEnabled(); ch.enable(false); ch.enable(true); ch.enableInputMethods(false); ch.enableInputMethods(true); ch.show(); ch.show(false); ch.show(true); ch.hide(); ch.getForeground(); ch.isForegroundSet(); ch.getBackground(); ch.isBackgroundSet(); ch.getFont(); ch.isFontSet(); Container c = new Container(); c.add(ch); ch.getLocale(); for (Locale locale : Locale.getAvailableLocales()) ch.setLocale(locale); ch.getColorModel(); ch.getLocation(); boolean exceptions = false; try { ch.getLocationOnScreen(); } catch (IllegalComponentStateException e) { exceptions = true; } if (!exceptions) throw new RuntimeException("IllegalComponentStateException did not occur when expected"); ch.location(); ch.setLocation(1, 2); ch.move(1, 2); ch.setLocation(new Point(1, 2)); ch.getSize(); ch.size(); ch.setSize(1, 32); ch.resize(1, 32); ch.setSize(new Dimension(1, 32)); ch.resize(new Dimension(1, 32)); ch.getBounds(); ch.bounds(); ch.setBounds(10, 10, 10, 10); ch.setBounds(new Rectangle(10, 10, 10, 10)); ch.isLightweight(); ch.setCursor(new Cursor(Cursor.CROSSHAIR_CURSOR)); ch.getCursor(); ch.isCursorSet(); ch.inside(1, 2); ch.contains(new Point(1, 2)); ch.isFocusable(); ch.setFocusable(true); ch.setFocusable(false); ch.transferFocus(); ch.getFocusCycleRootAncestor(); ch.nextFocus(); ch.transferFocusUpCycle(); ch.hasFocus(); ch.isFocusOwner(); ch.toString(); ch.setComponentOrientation(ComponentOrientation.LEFT_TO_RIGHT); ch.setComponentOrientation(ComponentOrientation.RIGHT_TO_LEFT); ch.setComponentOrientation(ComponentOrientation.UNKNOWN); ch.getComponentOrientation(); }
/** Initialize the contents of the frame. */ private void initialize() { frame = new JFrame(); frame.setResizable(false); frame.setBounds(100, 100, 505, 467); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.getContentPane().setLayout(null); frame.setLocationRelativeTo(null); JTabbedPane tabbedPane = new JTabbedPane(JTabbedPane.TOP); tabbedPane.setBounds(0, 0, 500, 442); /*Camera Report Panel*/ CameraReportPanel = new JPanel(); tabbedPane.add("Camera Report", CameraReportPanel); tabbedPane.setEnabledAt(0, true); CameraReportPanel.setLayout(null); JLabel label = new JLabel("Insert First Part of IP (xxx.xxx.xxx):"); label.setFont(new Font("Tahoma", Font.PLAIN, 14)); label.setBounds(36, 40, 232, 25); CameraReportPanel.add(label); JLabel label_1 = new JLabel("Insert Starting Host Number:"); label_1.setFont(new Font("Tahoma", Font.PLAIN, 14)); label_1.setBounds(36, 72, 181, 17); CameraReportPanel.add(label_1); JLabel label_2 = new JLabel("Insert Ending Host Number:"); label_2.setFont(new Font("Tahoma", Font.PLAIN, 14)); label_2.setBounds(36, 112, 181, 17); CameraReportPanel.add(label_2); sOctet = new JTextField(); sOctet.setFont(new Font("Dialog", Font.PLAIN, 20)); sOctet.addFocusListener(this); sOctet.setColumns(10); sOctet.setBounds(278, 70, 40, 25); CameraReportPanel.add(sOctet); eOctet = new JTextField(); eOctet.setFont(new Font("Dialog", Font.PLAIN, 20)); eOctet.addFocusListener(this); eOctet.setColumns(10); eOctet.setBounds(278, 110, 40, 25); CameraReportPanel.add(eOctet); JLabel label_3 = new JLabel("Enter Username:"******"Tahoma", Font.PLAIN, 14)); label_3.setBounds(36, 205, 106, 14); CameraReportPanel.add(label_3); JLabel label_4 = new JLabel("Enter Password:"******"Tahoma", Font.PLAIN, 14)); label_4.setBounds(36, 249, 106, 14); CameraReportPanel.add(label_4); uName = new JTextField(); uName.setFont(new Font("Tahoma", Font.PLAIN, 19)); uName.addFocusListener(this); uName.setText("root"); uName.setColumns(10); uName.setBounds(143, 195, 149, 32); CameraReportPanel.add(uName); passwordField = new JPasswordField(); passwordField.setFont(new Font("Tahoma", Font.PLAIN, 19)); passwordField.addFocusListener(this); passwordField.setText("p@ssw0rd"); passwordField.setBounds(143, 239, 149, 32); CameraReportPanel.add(passwordField); checkBoxPing = new JCheckBox("Ping Address"); checkBoxPing.setFont(new Font("Tahoma", Font.PLAIN, 14)); checkBoxPing.setSelected(true); checkBoxPing.setBounds(36, 144, 125, 23); CameraReportPanel.add(checkBoxPing); progressBar = new JProgressBar(); progressBar.setString(""); progressBar.setStringPainted(true); progressBar.setBounds(68, 331, 374, 32); CameraReportPanel.add(progressBar); CamReportBtn = new JButton("Run"); CamReportBtn.addActionListener(this); CamReportBtn.setBounds(201, 282, 104, 38); CameraReportPanel.add(CamReportBtn); firstOctet = new JTextField(); firstOctet.addFocusListener(this); firstOctet.setFont(new Font("Tahoma", Font.PLAIN, 20)); firstOctet.setText("10"); firstOctet.setColumns(3); firstOctet.setBounds(278, 38, 40, 25); CameraReportPanel.add(firstOctet); secondOctet = new JTextField(); secondOctet.addFocusListener(this); secondOctet.setFont(new Font("Dialog", Font.PLAIN, 20)); secondOctet.setColumns(3); secondOctet.setBounds(328, 37, 40, 25); CameraReportPanel.add(secondOctet); thirdOctet = new JTextField(); thirdOctet.addFocusListener(this); thirdOctet.setFont(new Font("Dialog", Font.PLAIN, 20)); thirdOctet.setColumns(3); thirdOctet.setBounds(378, 37, 40, 25); CameraReportPanel.add(thirdOctet); JLabel label_5 = new JLabel("."); label_5.setFont(new Font("Dialog", Font.BOLD, 17)); label_5.setBounds(320, 50, 4, 14); CameraReportPanel.add(label_5); JLabel label_6 = new JLabel("."); label_6.setFont(new Font("Dialog", Font.BOLD, 17)); label_6.setBounds(370, 50, 4, 14); CameraReportPanel.add(label_6); /*Host Uploader Panel*/ frame.getContentPane().add(tabbedPane); JComponent HostUploaderPanel = new JPanel(); tabbedPane.add("Host Uploader", HostUploaderPanel); tabbedPane.setEnabledAt(1, true); HostUploaderPanel.setLayout(null); hostUploaderBrowseBtn = new JButton("Browse"); hostUploaderBrowseBtn.addActionListener(this); hostUploaderBrowseBtn.setBounds(23, 82, 117, 29); HostUploaderPanel.add(hostUploaderBrowseBtn); filePath = new JTextField(); filePath.addFocusListener(this); filePath.setFont(new Font("Tahoma", Font.PLAIN, 10)); filePath.setBounds(150, 86, 318, 20); HostUploaderPanel.add(filePath); filePath.setColumns(10); hostUploaderRunBtn = new JButton("Run"); hostUploaderRunBtn.setFont(new Font("Tahoma", Font.PLAIN, 15)); hostUploaderRunBtn.addActionListener(this); hostUploaderRunBtn.setBounds(157, 334, 186, 60); hostUploaderRunBtn.setEnabled(false); HostUploaderPanel.add(hostUploaderRunBtn); JLabel label_7 = new JLabel("Insert First Part of IP (xxx.xxx.xxx):"); label_7.setFont(new Font("Tahoma", Font.PLAIN, 14)); label_7.setBounds(23, 125, 232, 25); HostUploaderPanel.add(label_7); textField_7 = new JTextField(); textField_7.addFocusListener(this); textField_7.setText("10"); textField_7.setFont(new Font("Tahoma", Font.PLAIN, 20)); textField_7.setColumns(3); textField_7.setBounds(265, 123, 40, 25); HostUploaderPanel.add(textField_7); textField_8 = new JTextField(); textField_8.addFocusListener(this); textField_8.setFont(new Font("Dialog", Font.PLAIN, 20)); textField_8.setColumns(3); textField_8.setBounds(315, 122, 40, 25); HostUploaderPanel.add(textField_8); textField_9 = new JTextField(); textField_9.addFocusListener(this); textField_9.setFont(new Font("Dialog", Font.PLAIN, 20)); textField_9.setColumns(3); textField_9.setBounds(365, 122, 40, 25); HostUploaderPanel.add(textField_9); JLabel label_8 = new JLabel("Insert Starting Host Number:"); label_8.setFont(new Font("Tahoma", Font.PLAIN, 14)); label_8.setBounds(23, 157, 181, 17); HostUploaderPanel.add(label_8); textField_10 = new JTextField(); textField_10.addFocusListener(this); textField_10.setFont(new Font("Dialog", Font.PLAIN, 20)); textField_10.setColumns(10); textField_10.setBounds(265, 155, 40, 25); HostUploaderPanel.add(textField_10); JLabel label_9 = new JLabel("Insert Ending Host Number:"); label_9.setFont(new Font("Tahoma", Font.PLAIN, 14)); label_9.setBounds(23, 197, 181, 17); HostUploaderPanel.add(label_9); textField_11 = new JTextField(); textField_11.addFocusListener(this); textField_11.setFont(new Font("Dialog", Font.PLAIN, 20)); textField_11.setColumns(10); textField_11.setBounds(265, 195, 40, 25); HostUploaderPanel.add(textField_11); JLabel label_10 = new JLabel("Enter Username:"******"Tahoma", Font.PLAIN, 14)); label_10.setBounds(23, 265, 106, 14); HostUploaderPanel.add(label_10); textField_12 = new JTextField(); textField_12.addFocusListener(this); textField_12.setText("root"); textField_12.setFont(new Font("Tahoma", Font.PLAIN, 19)); textField_12.setColumns(10); textField_12.setBounds(130, 255, 149, 32); HostUploaderPanel.add(textField_12); JLabel label_11 = new JLabel("Enter Password:"******"Tahoma", Font.PLAIN, 14)); label_11.setBounds(23, 309, 106, 14); HostUploaderPanel.add(label_11); passwordField_1 = new JPasswordField(); passwordField_1.addFocusListener(this); passwordField_1.setText("p@ssw0rd"); passwordField_1.setFont(new Font("Tahoma", Font.PLAIN, 19)); passwordField_1.setBounds(130, 291, 149, 32); HostUploaderPanel.add(passwordField_1); JLabel lblNewLabel = new JLabel("NOTE: Running this program REBOOTS the Camera(s)"); lblNewLabel.setForeground(Color.RED); lblNewLabel.setFont(new Font("Tahoma", Font.PLAIN, 18)); lblNewLabel.setBounds(23, 17, 445, 54); HostUploaderPanel.add(lblNewLabel); JLabel label_12 = new JLabel("."); label_12.setFont(new Font("Dialog", Font.BOLD, 17)); label_12.setBounds(308, 132, 4, 14); HostUploaderPanel.add(label_12); JLabel label_13 = new JLabel("."); label_13.setFont(new Font("Dialog", Font.BOLD, 17)); label_13.setBounds(358, 132, 4, 14); HostUploaderPanel.add(label_13); JComponent snmpReportPanel = new JPanel(); tabbedPane.add("SNMP Report", snmpReportPanel); tabbedPane.setEnabledAt(2, true); }
/** * Creates a window for reporting progress. The window will not appears immediately. It will * appears only when the {@link #started} method will be invoked. * * @param parent The parent component, or {@code null} if none. */ public ProgressWindow(final Component parent) { /* * Creates the window containing the components. */ Dimension parentSize; final Vocabulary resources = Vocabulary.getResources(parent != null ? parent.getLocale() : null); final String title = resources.getString(VocabularyKeys.PROGRESSION); final JDesktopPane desktop = JOptionPane.getDesktopPaneForComponent(parent); if (desktop != null) { final JInternalFrame frame; frame = new JInternalFrame(title); window = frame; content = new JPanel(); // Pour avoir un fond opaque parentSize = desktop.getSize(); frame.setContentPane(content); frame.setDefaultCloseOperation(JInternalFrame.HIDE_ON_CLOSE); desktop.add(frame, JLayeredPane.PALETTE_LAYER); } else { final JDialog dialog; dialog = new JDialog((Frame) null, title); window = dialog; content = (JComponent) dialog.getContentPane(); parentSize = Toolkit.getDefaultToolkit().getScreenSize(); dialog.setDefaultCloseOperation(JDialog.HIDE_ON_CLOSE); dialog.setResizable(false); } window.setBounds( (parentSize.width - WIDTH) / 2, (parentSize.height - HEIGHT) / 2, WIDTH, HEIGHT); /* * Creates the label that is going to display the undergoing operation. * This label is initially empty. */ description = new JLabel(); description.setHorizontalAlignment(JLabel.CENTER); /* * Creates the progress bar. */ progressBar = new JProgressBar(); progressBar.setIndeterminate(true); progressBar.setBorder( BorderFactory.createCompoundBorder( BorderFactory.createEmptyBorder(6, 9, 6, 9), progressBar.getBorder())); /* * Creates the cancel button. */ cancel = new JButton(resources.getString(VocabularyKeys.CANCEL)); cancel.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { setCanceled(true); } }); final Box cancelBox = Box.createHorizontalBox(); cancelBox.add(Box.createGlue()); cancelBox.add(cancel); cancelBox.add(Box.createGlue()); cancelBox.setBorder(BorderFactory.createEmptyBorder(0, 0, 6, 0)); /* * Layout the elements inside the window. An empty border is created in * order to put some space between the window content and the window border. */ final JPanel panel = new JPanel(new GridLayout(2, 1)); panel.setBorder( BorderFactory.createCompoundBorder( BorderFactory.createEmptyBorder(VMARGIN, HMARGIN, VMARGIN, HMARGIN), BorderFactory.createEtchedBorder())); panel.add(description); panel.add(progressBar); content.setLayout(new BorderLayout()); content.add(panel, BorderLayout.NORTH); content.add(cancelBox, BorderLayout.SOUTH); }
public BundleOptionsFrame(String displayName, String instanceName, List<OptionGroup> options) { setResizable(false); this.displayName = displayName; content = (JComponent) getContentPane(); content.setLayout(new GridBagLayout()); final BundleOptionsFrame frame = this; // Close button Action closeAction = new AbstractAction("Close") { @Override public void actionPerformed(ActionEvent e) { frame.setVisible(false); } }; JButton close_button = new JButton(closeAction); GridBagConstraints c = new GridBagConstraints(); c.gridx = 0; c.gridy = currentRow++; c.anchor = GridBagConstraints.LINE_START; c.insets = new Insets(2, 2, 2, 2); content.add(close_button, c); // Escape key binding JComponent root = frame.getRootPane(); root.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW) .put(KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0), "close"); root.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW) .put(KeyStroke.getKeyStroke("ctrl W"), "close"); root.getActionMap().put("close", closeAction); if (instanceName != null) { // Predicate name StringOption opt = new StringOption(); opt.setDisplayName("Predicate name"); opt.setDefault(instanceName); instanceNameField = new StringField(opt); instanceNameField.addChangeListener( new ChangeListener() { @Override public void stateChanged(ChangeEvent e) { updateTitle(); } }); addField(instanceNameField); JTextField tf = (JTextField) instanceNameField.getComponent(); tf.selectAll(); tf.requestFocusInWindow(); } else { // We're a codec; no instance name instanceNameField = null; } updateTitle(); // Options ExampleField example = null; for (OptionGroup group : options) { addSeparator(group.getDisplayName()); for (Option option : group.getOptions()) { OptionField field; if (option instanceof BooleanOption) { field = new BooleanField((BooleanOption) option); } else if (option instanceof StringOption) { field = new StringField((StringOption) option); } else if (option instanceof NumberOption) { field = new NumberField((NumberOption) option); } else if (option instanceof ChoiceOption) { field = new ChoiceField((ChoiceOption) option); } else if (option instanceof ExampleOption) { if (example != null) { throw new IllegalArgumentException("Cannot display more than one ExampleOption"); } example = new ExampleField((ExampleOption) option); field = example; } else { throw new IllegalArgumentException("Unknown option type"); } addField(field); optionFields.add(field); } } this.exampleField = example; pack(); }
@SuppressWarnings("deprecation") public RanglistenDialog(final Vector<Runde> runden, JFrame parent) { super(parent); setModalExclusionType(ModalExclusionType.TOOLKIT_EXCLUDE); setBackground(new Color(0x00000000, true)); try { obenLinks = loadImage(new File("obenLinks.png")); obenRechts = loadImage(new File("obenRechts.png")); } catch (Exception e) { e.printStackTrace(); } Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize(); setBounds(50, 50, (int) screenSize.getWidth() - 100, (int) screenSize.getHeight() - 100); GridBagLayout gridBagLayout = new GridBagLayout(); gridBagLayout.columnWidths = new int[] {0, 0, 0, 0}; gridBagLayout.rowHeights = new int[] {0, 0, 0, 0}; gridBagLayout.columnWeights = new double[] {0.0, 1.0, 0.0, Double.MIN_VALUE}; gridBagLayout.rowWeights = new double[] {0.0, 1.0, 0.0, Double.MIN_VALUE}; getContentPane().setLayout(gridBagLayout); { Font font = new Font("SansSerif", Font.PLAIN, 37); JComponent compontent = new JComponent() { @Override public void paint(Graphics g) { super.paint(g); setSize(RanglistenDialog.this.getWidth(), 44); g.drawImage(obenLinks, 0, 0, obenLinks.getWidth(), obenLinks.getHeight(), this); g.drawImage( obenRechts, getWidth() - obenRechts.getWidth(), 0, obenRechts.getWidth(), obenRechts.getHeight(), this); g.setColor(new Color(Farben.ANZEIGE_RAND)); g.fillRect( obenLinks.getWidth(), 0, getWidth() - 2 * obenLinks.getWidth(), obenLinks.getHeight()); g.fillRect( obenLinks.getWidth(), getWidth() - 6, getWidth() - 2 * obenLinks.getWidth(), 6); g.fillRect(0, obenLinks.getWidth(), 6, getWidth() - 2 * obenLinks.getHeight()); g.fillRect( getWidth() - 6, obenLinks.getHeight(), 6, getWidth() - 2 * obenLinks.getHeight()); g.fillRect(6, obenLinks.getHeight(), getWidth() - 12, 44 - obenLinks.getHeight()); paintComponents(g); } }; compontent.setLayout(null); compontent.setBounds(0, 0, getWidth(), 44); compontent.setMinimumSize(new Dimension(44, 44)); JLabel label = new JLabel("Rangliste"); label.setBounds(22, 0, getWidth() - 24, 44); label.setFont(font); label.setForeground(Color.WHITE); JButton button = new JButton("Close"); button.setBounds(getWidth() - 120, 12, 100, 20); compontent.add(button); button.addActionListener( new ActionListener() { @Override public void actionPerformed(ActionEvent e) { ((Startmenu) RanglistenDialog.this.getParent()).enable(); dispose(); } }); compontent.add(label); GridBagConstraints gbc_component = new GridBagConstraints(); gbc_component.gridwidth = 3; gbc_component.insets = new Insets(0, 0, 43, 5); gbc_component.anchor = GridBagConstraints.FIRST_LINE_START; gbc_component.fill = GridBagConstraints.BOTH; gbc_component.gridx = 0; gbc_component.gridy = 0; getContentPane().add(compontent, gbc_component); } { JComponent compontent = new JComponent() { @Override public void paint(Graphics g) { super.paint(g); setBackground(Color.BLACK); setSize(6, getHeight()); g.setColor(new Color(Farben.ANZEIGE_RAND)); g.fillRect(0, 0, getWidth(), getHeight()); } }; compontent.setLayout(null); GridBagConstraints gbc_component = new GridBagConstraints(); gbc_component.insets = new Insets(0, 0, 0, 5); gbc_component.fill = GridBagConstraints.BOTH; gbc_component.gridx = 0; gbc_component.gridy = 1; getContentPane().add(compontent, gbc_component); } { JComponent compontent = new JComponent() { @Override public void paint(Graphics g) { super.paint(g); setSize(6, getHeight()); g.setColor(new Color(Farben.ANZEIGE_RAND)); g.fillRect(0, 0, getWidth(), getHeight()); } }; compontent.setLayout(null); GridBagConstraints gbc_component2 = new GridBagConstraints(); gbc_component2.insets = new Insets(0, 0, 0, 5); gbc_component2.fill = GridBagConstraints.BOTH; gbc_component2.gridx = 2; gbc_component2.gridy = 1; getContentPane().add(compontent, gbc_component2); } { JScrollPane scrollPane = new JScrollPane(); GridBagConstraints gbc_scrollPane = new GridBagConstraints(); gbc_scrollPane.insets = new Insets(0, 0, 0, 0); gbc_scrollPane.fill = GridBagConstraints.BOTH; gbc_scrollPane.gridx = 1; gbc_scrollPane.gridy = 1; scrollPane.setBackground(new Color(Farben.ANZEIGE_KOERPER)); getContentPane().add(scrollPane, gbc_scrollPane); panel = new JPanel() { @Override public void paint(Graphics g) { super.paint(g); for (int i = 0; i < runden.size(); i++) { zeitLabels[i].setBounds(panel.getWidth() - 110, i * 40, 106, 40); nameLabels[i].setBounds(55, i * 40, panel.getWidth() - 210, 40); } } }; panel.setSize(new Dimension(scrollPane.getWidth(), runden.size() * 40)); panel.setLayout(null); panel.setPreferredSize(new Dimension(scrollPane.getWidth(), runden.size() * 40)); panel.setBackground(new Color(Farben.ANZEIGE_KOERPER)); scrollPane.setViewportView(panel); } { JComponent compontent = new JComponent() { @Override public void paint(Graphics g) { super.paint(g); setSize(getWidth(), 6); setBackground(Color.BLACK); g.setColor(new Color(Farben.ANZEIGE_RAND)); g.fillRect(0, 0, getWidth(), getHeight()); } }; compontent.setLayout(null); GridBagConstraints gbc_component2 = new GridBagConstraints(); gbc_component2.insets = new Insets(0, 0, 5, 0); gbc_component2.fill = GridBagConstraints.BOTH; gbc_component2.gridx = 0; gbc_component2.gridy = 2; gbc_component2.gridwidth = 3; getContentPane().add(compontent, gbc_component2); } Font font = new Font("SansSerif", Font.PLAIN, 24); zeitLabels = new JLabel[runden.size()]; nameLabels = new JLabel[runden.size()]; for (int i = 0; i < runden.size(); i++) { JLabel positionsLabel = new JLabel("" + i); positionsLabel.setFont(font); positionsLabel.setBounds(10, i * 40, 45, 40); panel.add(positionsLabel); zeitLabels[i] = new JLabel(Runde.zeitToString(runden.get(i).getEndzeit())); zeitLabels[i].setFont(font); zeitLabels[i].setBounds(panel.getWidth() - 110, i * 40, 106, 40); zeitLabels[i].setForeground(Color.WHITE); panel.add(zeitLabels[i]); nameLabels[i] = new JLabel(runden.get(i).getName()); nameLabels[i].setFont(font); nameLabels[i].setBounds(55, i * 40, panel.getWidth() - 210, 40); nameLabels[i].setForeground(Color.WHITE); panel.add(nameLabels[i]); } setVisible(true); requestFocus(); }
protected void initLayout() { super.setLayout(new GridLayout(1, 1)); super.add(_splitPane); _splitPane.setLayout(new SplitLayout(_orientation)); }
@Override protected void startup() { // set the window icon: { final Image img; if (true) img = getContext().getResourceMap().getImageIcon("Application.icon").getImage(); else { final ResourceMap r = getContext().getResourceMap(); if (true) try { img = ImageIO.read( this.getClass() .getResource( "/" + r.getResourcesDir() + "/" + r.getString("Application.icon"))); } catch (final IOException e) { throw new RuntimeException("Unhandled", e); } else img = Toolkit.getDefaultToolkit() .createImage( this.getClass() .getResource( "/" + r.getResourcesDir() + "/" + r.getString("Application.icon"))); } getMainFrame().setIconImage(img); // SystemTray tray = SystemTray.getSystemTray(); } // File Filter jcxzPat = gui.createFileFilter("fileFilterJcxz", "jcz", "jcx"); pngPat = gui.createFileFilter("fileFilterPng", "png"); svgPat = gui.createFileFilter("fileFilterSvg", "svgz", "svg"); getMainFrame().setJMenuBar(createMenuBar()); final JComponent c = new JPanel(); c.setLayout(new BorderLayout()); tactics.setPreferredSize(new Dimension(400, 600)); c.add(tactics, BorderLayout.CENTER); c.add(url, BorderLayout.NORTH); { final JPanel b = new JPanel(); b.setLayout(new BorderLayout()); final JTabbedPane t = new JTabbedPane(SwingConstants.TOP, JTabbedPane.SCROLL_TAB_LAYOUT); t.add("Rock", broomSwing); t.setMnemonicAt(0, 'R'); t.add("Ice", curlerSwing); t.setMnemonicAt(1, 'I'); t.add("Collission", new JLabel("TODO: Collission settings")); t.setMnemonicAt(2, 'C'); b.add(t, BorderLayout.NORTH); if (false) b.add(new JLabel("TODO: Bird's eye view"), BorderLayout.CENTER); else b.add(birdPiccolo, BorderLayout.CENTER); c.add(b, BorderLayout.EAST); } show(c); view12Foot(); }
@SuppressWarnings("unchecked") @Inject public AllocatableEditUI( ClientFacade facade, RaplaResources i18n, RaplaLocale raplaLocale, Logger logger, ClassificationFieldFactory classificationFieldFactory, PermissionListFieldFactory permissionListFieldFactory, BooleanFieldFactory booleanFieldFactory) throws RaplaInitializationException { super(facade, i18n, raplaLocale, logger); this.permissionController = facade.getRaplaFacade().getPermissionController(); classificationField = classificationFieldFactory.create(); try { this.permissionListField = permissionListFieldFactory.create(getString("permissions")); } catch (RaplaException e1) { throw new RaplaInitializationException(e1); } this.permissionListField.setPermissionLevels( Permission.DENIED, Permission.READ_NO_ALLOCATION, Permission.READ, Permission.ALLOCATE, Permission.ALLOCATE_CONFLICTS, Permission.EDIT, Permission.ADMIN); final JComponent permissionPanel = permissionListField.getComponent(); editPanel.setLayout(new BorderLayout()); editPanel.add(classificationField.getComponent(), BorderLayout.CENTER); holdBackConflictsField = booleanFieldFactory.create(getString("holdbackconflicts")); holdBackConflictPanel = new JPanel(); holdBackConflictPanel.setLayout(new BorderLayout()); holdBackConflictPanel.add( new JLabel(holdBackConflictsField.getFieldName() + ": "), BorderLayout.WEST); holdBackConflictPanel.add(holdBackConflictsField.getComponent(), BorderLayout.CENTER); classificationField.addChangeListener( new ChangeListener() { @Override public void stateChanged(ChangeEvent e) { final boolean mainTabSelected = classificationField.isMainTabSelected(); permissionPanel.setVisible(!mainTabSelected); if (!mainTabSelected && !editPanel.isAncestorOf(permissionPanel)) { editPanel.remove(holdBackConflictPanel); editPanel.add(permissionPanel, BorderLayout.SOUTH); editPanel.repaint(); } if (mainTabSelected && (!editPanel.isAncestorOf(holdBackConflictPanel))) { editPanel.remove(permissionPanel); editPanel.add(holdBackConflictPanel, BorderLayout.SOUTH); editPanel.repaint(); } AllocatableEditUI.this.stateChanged(e); } }); editPanel.setPreferredSize(new Dimension(800, 600)); }
private static JSheet createSheet(final JOptionPane pane, Component parentComponent, int style) { Window window = getWindowForComponent(parentComponent); final JSheet sheet; if (window instanceof Frame) { sheet = new JSheet((Frame) window); } else { sheet = new JSheet((Dialog) window); } JComponent contentPane = (JComponent) sheet.getContentPane(); contentPane.setLayout(new BorderLayout()); if (isNativeSheetSupported()) { contentPane.setBorder(new EmptyBorder(12, 0, 0, 0)); } contentPane.add(pane, BorderLayout.CENTER); sheet.setResizable(false); sheet.addWindowListener( new WindowAdapter() { private boolean gotFocus = false; @Override public void windowClosing(WindowEvent we) { pane.setValue(null); } @Override public void windowClosed(WindowEvent we) { if (pane.getValue() == JOptionPane.UNINITIALIZED_VALUE) { sheet.fireOptionSelected(pane); } } @Override public void windowGainedFocus(WindowEvent we) { // Once window gets focus, set initial focus if (!gotFocus) { // Ugly dirty hack: JOptionPane.selectInitialValue() is protected. // So we call directly into the UI. This may cause mayhem, // because we override the encapsulation. // pane.selectInitialValue(); OptionPaneUI ui = pane.getUI(); if (ui != null) { ui.selectInitialValue(pane); } gotFocus = true; } } }); sheet.addComponentListener( new ComponentAdapter() { @Override public void componentShown(ComponentEvent ce) { // reset value to ensure closing works properly pane.setValue(JOptionPane.UNINITIALIZED_VALUE); } }); pane.addPropertyChangeListener( new PropertyChangeListener() { public void propertyChange(PropertyChangeEvent event) { // Let the defaultCloseOperation handle the closing // if the user closed the window without selecting a button // (newValue = null in that case). Otherwise, close the sheet. if (sheet.isVisible() && event.getSource() == pane && (event.getPropertyName().equals(JOptionPane.VALUE_PROPERTY)) && event.getNewValue() != null && event.getNewValue() != JOptionPane.UNINITIALIZED_VALUE) { sheet.setVisible(false); sheet.fireOptionSelected(pane); } } }); sheet.pack(); return sheet; }
private About(final JFrame parent) { super(parent); setType(Type.POPUP); setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE); setTitle("About"); addWindowListener( new WindowAdapter() { @Override public void windowClosed(WindowEvent e) { parent.setEnabled(true); parent.requestFocus(); } @Override public void windowOpened(WindowEvent e) { parent.setEnabled(false); } }); Dimension dim = Toolkit.getDefaultToolkit().getScreenSize(); setBounds(dim.width / 3, dim.height / 3, 450, 300); GridBagLayout gridBagLayout = new GridBagLayout(); gridBagLayout.columnWidths = new int[] {434, 0}; gridBagLayout.rowHeights = new int[] {229, 33, 0}; gridBagLayout.columnWeights = new double[] {0.0, Double.MIN_VALUE}; gridBagLayout.rowWeights = new double[] {0.0, 0.0, Double.MIN_VALUE}; getContentPane().setLayout(gridBagLayout); JComponent tabAbout = new JPanel(); { JTabbedPane tabbedPane = new JTabbedPane(JTabbedPane.TOP); GridBagConstraints gbc_tabbedPane = new GridBagConstraints(); gbc_tabbedPane.fill = GridBagConstraints.BOTH; gbc_tabbedPane.insets = new Insets(0, 0, 5, 0); gbc_tabbedPane.gridx = 0; gbc_tabbedPane.gridy = 0; getContentPane().add(tabbedPane, gbc_tabbedPane); tabbedPane.addTab("About", null, tabAbout, null); tabAbout.setBorder(new EmptyBorder(5, 5, 5, 5)); { JPanel tabUsage = new JPanel(); tabbedPane.addTab("Usage", null, tabUsage, null); tabUsage.setLayout(new BorderLayout(0, 0)); { JLabel lblNewLabel = new JLabel("Usage"); lblNewLabel.setHorizontalAlignment(SwingConstants.CENTER); lblNewLabel.setFont(new Font("Tahoma", Font.BOLD, 16)); tabUsage.add(lblNewLabel, BorderLayout.NORTH); } { JLabel lblSda = new JLabel( "<html><ol>" + "<li>Run MCPatcher on the desired version of Minecraft.</li>" + "<li>In the repackager and click the <em>Select Jar</em> button and select your patched jar.</li>" + "<li>Click the <em>Repackage</em> button and wait for the program to finish.</li>" + "<br/> If any issues arrise, a dialog will pop up with a short description of what went wrong." + "</ol></html>"); lblSda.setVerticalAlignment(SwingConstants.TOP); lblSda.setFont(new Font("Tahoma", Font.PLAIN, 12)); tabUsage.add(lblSda, BorderLayout.CENTER); } } { JPanel tabCredits = new JPanel(); tabbedPane.addTab("Credits", null, tabCredits, null); tabCredits.setLayout(new BorderLayout(0, 0)); { JLabel lblLibrariesTitle = new JLabel("Credits"); lblLibrariesTitle.setHorizontalAlignment(SwingConstants.CENTER); lblLibrariesTitle.setFont(new Font("Tahoma", Font.BOLD, 16)); tabCredits.add(lblLibrariesTitle, BorderLayout.NORTH); } { JPanel panelLibs = new JPanel(); tabCredits.add(panelLibs, BorderLayout.CENTER); panelLibs.setLayout(null); { JLabel lblUsedLibraries = new JLabel("Used Libraries"); lblUsedLibraries.setBounds(36, 11, 80, 14); lblUsedLibraries.setFont(new Font("Tahoma", Font.BOLD, 11)); panelLibs.add(lblUsedLibraries); } { JPanel panelCommonsIo = new JPanel(); panelCommonsIo.setBounds(61, 30, 256, 24); panelLibs.add(panelCommonsIo); panelCommonsIo.setLayout(new FlowLayout(FlowLayout.CENTER, 5, 5)); JLabel lblCommonsIo = new JLabel("Apache Commons IO"); panelCommonsIo.add(lblCommonsIo); lblCommonsIo.addMouseListener(new LinkAdapter(lblCommonsIo, Constants.URI_COMMONS_IO)); JLabel lblCommonsIoDesc = new JLabel("(For reading and writing files)"); panelCommonsIo.add(lblCommonsIoDesc); } { JPanel panelGson = new JPanel(); panelGson.setBounds(61, 55, 184, 24); panelLibs.add(panelGson); panelGson.setLayout(new FlowLayout(FlowLayout.CENTER, 5, 5)); JLabel lblGson = new JLabel("Google Gson"); panelGson.add(lblGson); lblGson.addMouseListener(new LinkAdapter(lblGson, Constants.URI_GSON)); JLabel lblGsonDesc = new JLabel("(Reading version.json)"); panelGson.add(lblGsonDesc); } { JPanel panelLaunch = new JPanel(); panelLaunch.setBounds(61, 80, 191, 24); panelLibs.add(panelLaunch); panelLaunch.setLayout(new FlowLayout(FlowLayout.CENTER, 5, 5)); JLabel lblLaunch = new JLabel("Launch Wrapper"); panelLaunch.add(lblLaunch); lblLaunch.addMouseListener(new LinkAdapter(lblLaunch, Constants.URI_LAUNCH_WRAPPER)); JLabel lblLaunchDesc = new JLabel("(Loading MCPatcher)"); panelLaunch.add(lblLaunchDesc); } JLabel lblSpecialThanks = new JLabel("Special Thanks to:"); lblSpecialThanks.setFont(new Font("Tahoma", Font.BOLD, 11)); lblSpecialThanks.setBounds(36, 115, 102, 14); panelLibs.add(lblSpecialThanks); JPanel panel = new JPanel(); panel.setBounds(61, 129, 104, 24); panelLibs.add(panel); panel.setLayout(new FlowLayout(FlowLayout.CENTER, 5, 5)); JLabel lblMcpatcher = new JLabel("MCPatcher"); panel.add(lblMcpatcher); lblMcpatcher.addMouseListener(new LinkAdapter(lblMcpatcher, Constants.URI_MCPATCHER)); JLabel lblByKahr = new JLabel("by Kahr"); panel.add(lblByKahr); } } } tabAbout.setLayout(null); { JLabel lblTitle = new JLabel("MCPatcher Repackager v" + Constants.VERSION); lblTitle.setLabelFor(tabAbout); lblTitle.setBounds(100, 11, 229, 20); lblTitle.setFont(new Font("Tahoma", Font.BOLD, 16)); tabAbout.add(lblTitle); } { JLabel lblAuthor = new JLabel("(c) Matthew Messinger (killjoy1221)"); lblAuthor.setBounds(122, 42, 185, 14); tabAbout.add(lblAuthor); } { JLabel lblDesc = new JLabel(); lblDesc.setVerticalAlignment(SwingConstants.TOP); lblDesc.setFont(new Font("Tahoma", Font.PLAIN, 12)); lblDesc.setText( "<html>MCPatcher Repackager is a tool for repackaging an MCPatcher patched<br/>Minecraft into a separate jar file.<br/><br/>This is useful when using a mod loader, such as LiteLoader or FML,<br/>that supports loading Tweaker mods. In the case of FML, it won't<br/>complain if you don't add the right JVM arguments.<HTML>"); lblDesc.setBackground(SystemColor.menu); lblDesc.setBounds(10, 67, 413, 90); tabAbout.add(lblDesc); } { JPanel panelSource = new JPanel(); panelSource.setBounds(10, 168, 198, 24); tabAbout.add(panelSource); panelSource.setLayout(new FlowLayout(FlowLayout.CENTER, 5, 5)); JLabel lblSource = new JLabel("The source can be found on my"); panelSource.add(lblSource); JLabel lblLink = new JLabel("GitHub"); panelSource.add(lblLink); lblLink.addMouseListener(new LinkAdapter(lblLink, Constants.URI_SOURCE)); } { JPanel buttonPane = new JPanel(); buttonPane.setLayout(new FlowLayout(FlowLayout.RIGHT)); GridBagConstraints btnOK = new GridBagConstraints(); btnOK.anchor = GridBagConstraints.NORTH; btnOK.fill = GridBagConstraints.HORIZONTAL; btnOK.gridx = 0; btnOK.gridy = 1; getContentPane().add(buttonPane, btnOK); { JButton okButton = new JButton("OK"); okButton.addActionListener( new ActionListener() { @Override public void actionPerformed(ActionEvent e) { About.this.dispose(); } }); okButton.setActionCommand("OK"); buttonPane.add(okButton); getRootPane().setDefaultButton(okButton); } } }
public void init() { try { UIManager.setLookAndFeel("com.sun.java.swing.plaf.nimbus.NimbusLookAndFeel"); } catch (ClassNotFoundException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (InstantiationException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (IllegalAccessException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (UnsupportedLookAndFeelException e) { // TODO Auto-generated catch block e.printStackTrace(); } Window window = SwingUtilities.windowForComponent(this); if (window instanceof JFrame) { JFrame frame = (JFrame) window; if (!frame.isResizable()) frame.setResizable(true); } try { Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver"); String connectionUrl = "jdbc:sqlserver://130.208.252.230:1433;databaseName=PROD_UPG_DATA;user=limsadmin;password=starlims;"; con = DriverManager.getConnection(connectionUrl); List<Proj> folders = getProjects(); model = createModel(folders); } catch (ClassNotFoundException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (SQLException e) { // TODO Auto-generated catch block e.printStackTrace(); } table.setAutoCreateRowSorter(true); if (model != null) table.setModel(model); Set<TableColumn> remcol = new HashSet<TableColumn>(); Enumeration<TableColumn> taben = table.getColumnModel().getColumns(); while (taben.hasMoreElements()) { TableColumn tc = taben.nextElement(); if (tc.getIdentifier().toString().startsWith("_")) { remcol.add(tc); } } for (TableColumn tc : remcol) { table.removeColumn(tc); } table .getSelectionModel() .addListSelectionListener( new ListSelectionListener() { @Override public void valueChanged(ListSelectionEvent e) { if (currentSelection != null) { Proj project = orderMap.get(currentSelection); if (project != null) { project._OrderComment = textarea.getText(); project._ResultComment = rtextarea.getText(); } } int r = table.getSelectedRow(); if (r != -1) { currentSelection = (String) table.getValueAt(r, 0); r = table.convertRowIndexToModel(r); String t = (String) model.getValueAt(r, 1); if (t != null) textarea.setText(t); else { textarea.setText(""); } t = (String) model.getValueAt(r, 2); if (t != null) rtextarea.setText(t); else { rtextarea.setText(""); } } } }); scrollpane.setViewportView(table); scrollarea.setViewportView(textarea); rscrollarea.setViewportView(rtextarea); vista.setAction( new AbstractAction("Vista") { private static final long serialVersionUID = 1L; @Override public void actionPerformed(ActionEvent e) { try { Proj project = orderMap.get(currentSelection); if (project != null) save(project, rtextarea.getText(), textarea.getText()); } catch (SQLException e1) { // TODO Auto-generated catch block e1.printStackTrace(); } } }); for (String s : fset) { combo.addItem(s); } combo.addItemListener( new ItemListener() { @Override public void itemStateChanged(ItemEvent e) { String s = (String) combo.getSelectedItem(); TableRowSorter<TableModel> trs = (TableRowSorter<TableModel>) table.getRowSorter(); String filterText = "(?i).*" + s + ".*"; trs.setRowFilter(RowFilter.regexFilter(filterText)); } }); JComponent comp = new JComponent() {}; comp.setLayout(new BorderLayout()); comp.add(scrollarea); comp.add(vista, BorderLayout.SOUTH); JComponent comp2 = new JComponent() {}; comp2.setLayout(new BorderLayout()); comp2.add(scrollpane); comp2.add(combo, BorderLayout.NORTH); rsplitpane.setTopComponent(rscrollarea); rsplitpane.setBottomComponent(comp); splitpane.setLeftComponent(comp2); splitpane.setRightComponent(rsplitpane); splitpane.setDividerLocation(0.33); this.add(splitpane); }
private void initializeComponent(final Frame owner) { this.addWindowListener( new WindowAdapter() { @Override public void windowClosing(WindowEvent e) { if (owner == null) { System.exit(0); } owner.setEnabled(true); dispose(); } }); serverLabel = new JLabel("Server name"); serverField = new JTextField(ClientGameConfiguration.get("DEFAULT_SERVER")); serverField.setEditable(true); serverPortLabel = new JLabel("Server port"); serverPortField = new JTextField(ClientGameConfiguration.get("DEFAULT_PORT")); usernameLabel = new JLabel("Choose a username"); usernameField = new JTextField(); usernameField.setDocument(new LowerCaseLetterDocument()); passwordLabel = new JLabel("Choose a password"); passwordField = new JPasswordField(); passwordretypeLabel = new JLabel("Retype password"); passwordretypeField = new JPasswordField(); emailLabel = new JLabel("E-mail address (optional)"); emailField = new JTextField(); // createAccountButton // createAccountButton = new JButton(); createAccountButton.setText("Create Account"); createAccountButton.setMnemonic(KeyEvent.VK_C); this.rootPane.setDefaultButton(createAccountButton); createAccountButton.addActionListener( new ActionListener() { public void actionPerformed(final ActionEvent e) { createAccountButton_actionPerformed(e, false); } }); // // contentPane // int padding = SBoxLayout.COMMON_PADDING; contentPane = (JPanel) this.getContentPane(); contentPane.setLayout(new SBoxLayout(SBoxLayout.VERTICAL, padding)); contentPane.setBorder(BorderFactory.createEmptyBorder(padding, padding, padding, padding)); JComponent grid = new JComponent() { private static final long serialVersionUID = 1L; }; grid.setLayout(new GridLayout(6, 2, padding, padding)); contentPane.add(grid, SBoxLayout.constraint(SLayout.EXPAND_X, SLayout.EXPAND_Y)); // row 0 grid.add(serverLabel); grid.add(serverField); // row 1 grid.add(serverPortLabel); grid.add(serverPortField); // row 2 grid.add(usernameLabel); grid.add(usernameField); // row 3 grid.add(passwordLabel); grid.add(passwordField); // row 4 grid.add(passwordretypeLabel); grid.add(passwordretypeField); // row 5 grid.add(emailLabel); grid.add(emailField); // Warning label JLabel logLabel = new JLabel( "<html><body><p><font size=\"-2\">On login information which identifies your computer on <br>the internet will be logged to prevent abuse (like many <br>attempts to guess a password in order to hack an <br>account or creation of many accounts to cause trouble). <br>Furthermore all events and actions that happen within <br>the game-world (like solving quests, attacking monsters) <br>are logged. This information is used to analyse bugs and <br>in rare cases for abuse handling.</font></p></body></html>"); // Add a bit more empty space around it logLabel.setBorder(BorderFactory.createEmptyBorder(padding, padding, padding, padding)); logLabel.setAlignmentX(CENTER_ALIGNMENT); contentPane.add(logLabel, SBoxLayout.constraint(SLayout.EXPAND_X, SLayout.EXPAND_Y)); createAccountButton.setAlignmentX(RIGHT_ALIGNMENT); contentPane.add(createAccountButton); // CreateAccountDialog this.setTitle("Create New Account"); this.setResizable(false); // required on Compiz this.pack(); usernameField.requestFocusInWindow(); if (owner != null) { owner.setEnabled(false); this.setLocationRelativeTo(owner); } }
/** * @ÃèÊö£º. * * <p> * * @author ÀîÍþ @Date£º2011-3-12 * @param args */ public static void main(String[] args) { FlexLayoutTest frame = new FlexLayoutTest(); frame.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE); frame.setSize(1000, 600); frame.setPreferredSize(new Dimension(1000, 600)); // Container contentPane = frame.getContentPane(); JComponent contentPane = (JComponent) frame.getContentPane(); contentPane.setLayout(new FlexLayout()); contentPane.putClientProperty( LayoutProperty.LAYOUT_PARENT_PROPERTY, new LayoutProperty(0, 0, 1000, 600)); JButton btn1 = new JButton("AAA"); btn1.setBorder(new JButtonBorder()); JButton btn2 = new JButton("BBB"); JButton btn3 = new JButton("CCC"); JButton btn4 = new JButton("DDD"); JButton btn5 = new JButton("EEE"); JButton btn6 = new JButton("FFF"); JTextArea area = new JTextArea(); btn1.putClientProperty( LayoutProperty.LAYOUT_CHILD_PROPERTY, new LayoutProperty( 10, 10, 300, 30, LayoutProperty.TOP | LayoutProperty.LEFT | LayoutProperty.RIGHT_RESIZE)); btn2.putClientProperty( LayoutProperty.LAYOUT_CHILD_PROPERTY, new LayoutProperty( 350, 10, 300, 30, LayoutProperty.TOP | LayoutProperty.LEFT_RESIZE | LayoutProperty.RIGHT_RESIZE)); btn3.putClientProperty( LayoutProperty.LAYOUT_CHILD_PROPERTY, new LayoutProperty( 690, 10, 300, 30, LayoutProperty.TOP | LayoutProperty.LEFT_RESIZE | LayoutProperty.RIGHT)); btn4.putClientProperty( LayoutProperty.LAYOUT_CHILD_PROPERTY, new LayoutProperty( 10, 560, 300, 30, LayoutProperty.BOTTOM | LayoutProperty.LEFT | LayoutProperty.RIGHT_RESIZE)); btn5.putClientProperty( LayoutProperty.LAYOUT_CHILD_PROPERTY, new LayoutProperty( 350, 560, 300, 30, LayoutProperty.BOTTOM | LayoutProperty.LEFT_RESIZE | LayoutProperty.RIGHT_RESIZE)); btn6.putClientProperty( LayoutProperty.LAYOUT_CHILD_PROPERTY, new LayoutProperty( 690, 560, 300, 30, LayoutProperty.BOTTOM | LayoutProperty.LEFT_RESIZE | LayoutProperty.RIGHT)); area.putClientProperty( LayoutProperty.LAYOUT_CHILD_PROPERTY, new LayoutProperty( 10, 52, 980, 498, LayoutProperty.TOP | LayoutProperty.LEFT | LayoutProperty.RIGHT | LayoutProperty.BOTTOM)); area.setBackground(Color.DARK_GRAY); area.setForeground(Color.RED); frame.add(btn1); frame.add(btn2); frame.add(btn3); frame.add(btn4); frame.add(btn5); frame.add(btn6); frame.add(area); JMenu menu = new JMenu("File"); JMenuItem menuItem = new JMenuItem("Exit Application"); menuItem.setBorder(new JMenuItemBorder()); menu.add(menuItem); JMenuItem menuItem1 = new JMenuItem("Exit Application"); menuItem1.setBorder(new JMenuItemBorder()); menu.add(menuItem1); JMenuItem menuItem2 = new JMenuItem("Exit Application"); menuItem2.setBorder(new JMenuItemBorder()); menu.add(menuItem2); JMenuBar bar = new JMenuBar(); bar.add(menu); frame.setJMenuBar(bar); frame.setVisible(true); }