Java Code Examples for javax.swing.JPanel#setLayout()
The following examples show how to use
javax.swing.JPanel#setLayout() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ClientEditConfigPanel.java From logging-log4j2 with Apache License 2.0 | 6 votes |
private void createWidgets() { configTextArea = new JTextArea(CONFIG_TEXT_ROWS, CONFIG_TEXT_COLS); // configTextArea.setEditable(false); configTextArea.setBackground(Color.white); configTextArea.setForeground(Color.black); configTextArea.setFont(new Font(Font.MONOSPACED, Font.PLAIN, configTextArea.getFont().getSize())); final JScrollPane scrollConfig = new JScrollPane(configTextArea); locationTextField = new JTextField(LOCATION_TEXT_COLS); locationLabel = new JLabel("Location: "); locationLabel.setLabelFor(locationTextField); buttonSendLocation = new JButton(actionReconfigureFromLocation); buttonSendConfigText = new JButton(actionReconfigureFromText); final JPanel north = new JPanel(); north.setLayout(new BoxLayout(north, BoxLayout.LINE_AXIS)); north.add(locationLabel); north.add(locationTextField); north.add(buttonSendLocation); north.add(Box.createRigidArea(new Dimension(HORIZONTAL_GAP, 0))); north.add(buttonSendConfigText); this.setLayout(new BorderLayout()); this.add(north, BorderLayout.NORTH); this.add(scrollConfig, BorderLayout.CENTER); }
Example 2
Source File: Correlator.java From GpsPrune with GNU General Public License v2.0 | 6 votes |
/** * Make the second panel for the selection screen * @return JPanel object containing gui elements */ private JPanel makeSecondPanel() { JPanel card = new JPanel(); card.setLayout(new BorderLayout(10, 10)); JLabel introLabel = new JLabel(I18nManager.getText( "dialog.correlate." + getMediaTypeKey() + "select.intro")); introLabel.setBorder(BorderFactory.createEmptyBorder(6, 6, 6, 6)); card.add(introLabel, BorderLayout.NORTH); // table doesn't have model yet - that will be attached later _selectionTable = new JTable(); JScrollPane photoScrollPane = new JScrollPane(_selectionTable); photoScrollPane.setPreferredSize(new Dimension(400, 100)); card.add(photoScrollPane, BorderLayout.CENTER); return card; }
Example 3
Source File: RuleParametersView.java From hortonmachine with GNU General Public License v3.0 | 6 votes |
public JPanel createPanel() { JPanel jpanel1 = new JPanel(); FormLayout formlayout1 = new FormLayout("FILL:DEFAULT:NONE,FILL:DEFAULT:GROW(1.0),FILL:DEFAULT:NONE,FILL:DEFAULT:NONE,FILL:DEFAULT:NONE,FILL:DEFAULT:NONE,FILL:DEFAULT:NONE,FILL:DEFAULT:NONE,FILL:DEFAULT:NONE,FILL:DEFAULT:NONE,FILL:DEFAULT:NONE,FILL:DEFAULT:NONE,FILL:DEFAULT:NONE,FILL:DEFAULT:NONE,FILL:DEFAULT:NONE,FILL:DEFAULT:NONE,FILL:DEFAULT:NONE,FILL:DEFAULT:NONE,FILL:DEFAULT:NONE,FILL:DEFAULT:NONE","CENTER:DEFAULT:NONE,CENTER:DEFAULT:NONE,CENTER:DEFAULT:NONE,CENTER:DEFAULT:NONE,CENTER:DEFAULT:NONE,CENTER:DEFAULT:NONE,CENTER:DEFAULT:NONE"); CellConstraints cc = new CellConstraints(); jpanel1.setLayout(formlayout1); _applyButton.setActionCommand("Apply"); _applyButton.setName("applyButton"); _applyButton.setText("Apply"); jpanel1.add(_applyButton,cc.xywh(7,6,13,1)); jpanel1.add(createPanel1(),cc.xywh(2,2,19,1)); jpanel1.add(createPanel2(),cc.xywh(2,4,19,1)); addFillComponents(jpanel1,new int[]{ 1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20 },new int[]{ 1,2,3,4,5,6,7 }); return jpanel1; }
Example 4
Source File: GenericView.java From jFuzzyLogic with GNU Lesser General Public License v3.0 | 6 votes |
/** * associate a model with this view */ public void setModel(Model aModel) { model = (GenericModel) aModel; for (final Variable v:model.getVariables()) { JPanel p=new JPanel(); p.setLayout(new BoxLayout(p,BoxLayout.X_AXIS)); JLabel lab=new JLabel(v.getName()); final JSlider slider=new JSlider(0,1000); p.add(lab); p.add(slider); final double maxv=v.getUniverseMax(); final double minv=v.getUniverseMin(); slider.addChangeListener(new ChangeListener() { public void stateChanged(ChangeEvent e) { double x=minv+(slider.getModel().getValue())*(maxv-minv)/1000.0; v.setValue(x); } }); add(p); System.out.println(" Added " + v.getName()); } validate(); repaint(); }
Example 5
Source File: GridBagLayoutBuilder.java From triplea with GNU General Public License v3.0 | 5 votes |
/** * Constructs a Swing JPanel using current builder values. Values that must be set: (requires no * values to be set) */ public JPanel build() { final JPanel panel = panelBuilder.build(); panel.setLayout(new GridBagLayout()); components.forEach(c -> panel.add(c.component, c.constraints)); return panel; }
Example 6
Source File: SettingsPanel.java From visualvm with GNU General Public License v2.0 | 5 votes |
private static int defaultHeight() { if (DEFAULT_HEIGHT == -1) { JPanel ref = new JPanel(null); ref.setLayout(new BoxLayout(ref, BoxLayout.LINE_AXIS)); ref.setOpaque(false); ref.add(new JLabel("XXX")); // NOI18N ref.add(new JButton("XXX")); // NOI18N ref.add(new PopupButton("XXX")); // NOI18N ref.add(new JCheckBox("XXX")); // NOI18N ref.add(new JRadioButton("XXX")); // NOI18N ref.add(new JTextField("XXX")); // NOI18N ref.add(new JExtendedSpinner(new SpinnerNumberModel(1, 1, 655535, 1))); Component separator = Box.createHorizontalStrut(1); Dimension d = separator.getMaximumSize(); d.height = 20; separator.setMaximumSize(d); ref.add(separator); DEFAULT_HEIGHT = ref.getPreferredSize().height; } return DEFAULT_HEIGHT; }
Example 7
Source File: GUIOptionSSLPassThroughDialog.java From PacketProxy with Apache License 2.0 | 5 votes |
private JComponent label_and_object(String label_name, JComponent object) { JPanel panel = new JPanel(); panel.setLayout(new BoxLayout(panel, BoxLayout.X_AXIS)); JLabel label = new JLabel(label_name); label.setPreferredSize(new Dimension(150, label.getMaximumSize().height)); panel.add(label); object.setMaximumSize(new Dimension(Short.MAX_VALUE, label.getMaximumSize().height * 2)); panel.add(object); return panel; }
Example 8
Source File: CreatureAnimationPreview.java From stendhal with GNU General Public License v2.0 | 5 votes |
private CreatureAnimationPreview() { jFrame.setSize(new Dimension(818, 470)); JScrollPane scroll = new JScrollPane(); scroll.setViewportView(createJTree()); split.setLeftComponent(scroll); JPanel rightPanel = new JPanel(); JComponent row = new JComponent() {}; row.setLayout(new BoxLayout(row, BoxLayout.X_AXIS)); rightPanel.setLayout(new BoxLayout(rightPanel, BoxLayout.Y_AXIS)); for (int i = 0; i < NUMBER_OF_ROWS; i++) { JLabel l = new JLabel(); animationPanel[i] = l; animations[i] = new AnimationRunner(l); row.add(l); } rightPanel.add(row); rightPanel.add(mainPanel); split.setRightComponent(rightPanel); jFrame.setContentPane(split); jFrame.setTitle("animated Monsters test"); jFrame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); jFrame.setVisible(true); }
Example 9
Source File: InstructionPanel.java From Cafebabe with GNU General Public License v3.0 | 5 votes |
public InstructionPanel(ClassNode cn, MethodNode mn) { this.setFocusable(false); this.setLayout(new BorderLayout()); InstructionList il = new InstructionList(cn, mn); this.add(il, BorderLayout.CENTER); JPanel p = new JPanel(); p.setLayout(new BorderLayout()); p.setBorder(BorderFactory.createMatteBorder(0, 0, 0, 1, Color.gray)); p.add(new AdressList(il), BorderLayout.CENTER); this.add(p, BorderLayout.WEST); }
Example 10
Source File: HierarchyTopComponent.java From netbeans with Apache License 2.0 | 4 votes |
@NbBundle.Messages({ "TXT_NonActiveContent=<No View Available - Refresh Manually>", "TXT_InspectHierarchyHistory=<empty>", "TOOLTIP_RefreshContent=Refresh for entity under cursor", "TOOLTIP_OpenJDoc=Open Javadoc Window", "TOOLTIP_ViewHierarchyType=Hierachy View Type", "TOOLTIP_InspectHierarchyHistory=Inspect Hierarchy History" }) public HierarchyTopComponent() { history = HistorySupport.getInstnace(this.getClass()); jdocFinder = SelectJavadocTask.create(this); jdocTask = RP.create(jdocFinder); explorerManager = new ExplorerManager(); rootChildren = new RootChildren(); filters = new HierarchyFilters(); explorerManager.setRootContext(Nodes.rootNode(rootChildren, filters)); selectedNodes = new InstanceContent(); lookup = new AbstractLookup(selectedNodes); explorerManager.addPropertyChangeListener(this); initComponents(); setName(Bundle.CTL_HierarchyTopComponent()); setToolTipText(Bundle.HINT_HierarchyTopComponent()); viewTypeCombo = new JComboBox(new DefaultComboBoxModel(ViewType.values())); viewTypeCombo.setMinimumSize(new Dimension(MIN_TYPE_WIDTH,COMBO_HEIGHT)); viewTypeCombo.addActionListener(this); viewTypeCombo.setToolTipText(Bundle.TOOLTIP_ViewHierarchyType()); historyCombo = new JComboBox(HistorySupport.createModel(history, Bundle.TXT_InspectHierarchyHistory())); historyCombo.setMinimumSize(new Dimension(MIN_HISTORY_WIDTH,COMBO_HEIGHT)); historyCombo.setRenderer(HistorySupport.createRenderer(history)); historyCombo.addActionListener(this); historyCombo.setEnabled(false); historyCombo.getModel().addListDataListener(this); historyCombo.setToolTipText(Bundle.TOOLTIP_InspectHierarchyHistory()); refreshButton = new JButton(ImageUtilities.loadImageIcon(REFRESH_ICON, true)); refreshButton.addActionListener(this); refreshButton.setToolTipText(Bundle.TOOLTIP_RefreshContent()); jdocButton = new JButton(ImageUtilities.loadImageIcon(JDOC_ICON, true)); jdocButton.addActionListener(this); jdocButton.setToolTipText(Bundle.TOOLTIP_OpenJDoc()); final Box upperToolBar = new MainToolBar( constrainedComponent(viewTypeCombo, GridBagConstraints.HORIZONTAL, 1.0, new Insets(0,0,0,0)), constrainedComponent(historyCombo, GridBagConstraints.HORIZONTAL, 1.5, new Insets(0,3,0,0)), constrainedComponent(refreshButton, GridBagConstraints.NONE, 0.0, new Insets(0,3,0,0)), constrainedComponent(jdocButton, GridBagConstraints.NONE, 0.0, new Insets(0,3,0,3))); add(decorateAsUpperPanel(upperToolBar), BorderLayout.NORTH); contentView = new JPanel(); contentView.setLayout(new CardLayout()); JPanel nonActiveContent = Utils.updateBackground(new JPanel()); nonActiveContent.setLayout(new BorderLayout()); nonActiveInfo = new JLabel(Bundle.TXT_NonActiveContent()); nonActiveInfo.setEnabled(false); nonActiveInfo.setHorizontalAlignment(SwingConstants.CENTER); nonActiveContent.add(nonActiveInfo, BorderLayout.CENTER); btw = createBeanTreeView(); contentView.add(nonActiveContent, NON_ACTIVE_CONTENT); contentView.add(btw, ACTIVE_CONTENT); add(contentView,BorderLayout.CENTER); lowerToolBar = new TapPanel(); lowerToolBar.setOrientation(TapPanel.DOWN); final JComponent lowerButtons = filters.getComponent(); lowerButtons.setBorder(BorderFactory.createEmptyBorder(0, 5, 5, 0)); lowerToolBar.add(lowerButtons); final boolean expanded = NbPreferences.forModule(HierarchyTopComponent.class). getBoolean(PROP_LOWER_TOOLBAR_EXPANDED, true); //NOI18N lowerToolBar.setExpanded(expanded); lowerToolBar.addPropertyChangeListener(this); add(Utils.updateBackground(lowerToolBar), BorderLayout.SOUTH); }
Example 11
Source File: DiacriticsTest.java From openjdk-jdk8u with GNU General Public License v2.0 | 4 votes |
public void start() { setSize(350, 200); JPanel panel = new JPanel(); panel.setLayout(new GridLayout(2, 1)); TextArea txtArea = new TextArea(); panel.add(txtArea); TextField txtField = new TextField(); panel.add(txtField); add(panel, BorderLayout.CENTER); validate(); setVisible(true); }
Example 12
Source File: DiacriticsTest.java From jdk8u-dev-jdk with GNU General Public License v2.0 | 4 votes |
public void start() { setSize(350, 200); JPanel panel = new JPanel(); panel.setLayout(new GridLayout(2, 1)); TextArea txtArea = new TextArea(); panel.add(txtArea); TextField txtField = new TextField(); panel.add(txtField); add(panel, BorderLayout.CENTER); validate(); setVisible(true); }
Example 13
Source File: XSheet.java From TencentKona-8 with GNU General Public License v2.0 | 4 votes |
private void setupScreen() { setLayout(new BorderLayout()); setBorder(BorderFactory.createLineBorder(Color.GRAY)); // add main panel to XSheet mainPanel = new JPanel(); mainPanel.setLayout(new BorderLayout()); add(mainPanel, BorderLayout.CENTER); // add south panel to XSheet southPanel = new JPanel(); add(southPanel, BorderLayout.SOUTH); // create the refresh button refreshButton = new JButton(Messages.MBEANS_TAB_REFRESH_ATTRIBUTES_BUTTON); refreshButton.setMnemonic(Resources.getMnemonicInt(Messages.MBEANS_TAB_REFRESH_ATTRIBUTES_BUTTON)); refreshButton.setToolTipText(Messages.MBEANS_TAB_REFRESH_ATTRIBUTES_BUTTON_TOOLTIP); refreshButton.addActionListener(this); // create the clear button clearButton = new JButton(Messages.MBEANS_TAB_CLEAR_NOTIFICATIONS_BUTTON); clearButton.setMnemonic(Resources.getMnemonicInt(Messages.MBEANS_TAB_CLEAR_NOTIFICATIONS_BUTTON)); clearButton.setToolTipText(Messages.MBEANS_TAB_CLEAR_NOTIFICATIONS_BUTTON_TOOLTIP); clearButton.addActionListener(this); // create the subscribe button subscribeButton = new JButton(Messages.MBEANS_TAB_SUBSCRIBE_NOTIFICATIONS_BUTTON); subscribeButton.setMnemonic(Resources.getMnemonicInt(Messages.MBEANS_TAB_SUBSCRIBE_NOTIFICATIONS_BUTTON)); subscribeButton.setToolTipText(Messages.MBEANS_TAB_SUBSCRIBE_NOTIFICATIONS_BUTTON_TOOLTIP); subscribeButton.addActionListener(this); // create the unsubscribe button unsubscribeButton = new JButton(Messages.MBEANS_TAB_UNSUBSCRIBE_NOTIFICATIONS_BUTTON); unsubscribeButton.setMnemonic(Resources.getMnemonicInt(Messages.MBEANS_TAB_UNSUBSCRIBE_NOTIFICATIONS_BUTTON)); unsubscribeButton.setToolTipText(Messages.MBEANS_TAB_UNSUBSCRIBE_NOTIFICATIONS_BUTTON_TOOLTIP); unsubscribeButton.addActionListener(this); // create XMBeanAttributes container mbeanAttributes = new XMBeanAttributes(mbeansTab); // create XMBeanOperations container mbeanOperations = new XMBeanOperations(mbeansTab); mbeanOperations.addOperationsListener(this); // create XMBeanNotifications container mbeanNotifications = new XMBeanNotifications(); mbeanNotifications.addNotificationsListener(this); // create XMBeanInfo container mbeanInfo = new XMBeanInfo(); }
Example 14
Source File: ImportStatusDialog.java From importer-exporter with Apache License 2.0 | 4 votes |
private void initGUI(String impExpTitle, String impExpMessage) { setDefaultCloseOperation(JDialog.DO_NOTHING_ON_CLOSE); fileName = new JLabel(impExpMessage); fileName.setFont(fileName.getFont().deriveFont(Font.BOLD)); mesageLabel = new JLabel(" "); cancelButton = new JButton(Language.I18N.getString("common.button.cancel")); featureLabel = new JLabel(Language.I18N.getString("common.status.dialog.featureCounter")); appearanceLabel = new JLabel(Language.I18N.getString("common.status.dialog.appearanceCounter")); textureLabel = new JLabel(Language.I18N.getString("common.status.dialog.textureCounter")); fileCounter = new JLabel(Language.I18N.getString("common.status.dialog.fileCounter")); fileCounterLabel = new JLabel("n/a", SwingConstants.TRAILING); featureCounterLabel = new JLabel("0", SwingConstants.TRAILING); appearanceCounterLabel = new JLabel("0", SwingConstants.TRAILING); textureCounterLabel = new JLabel("0", SwingConstants.TRAILING); featureCounterLabel.setPreferredSize(new Dimension(100, featureLabel.getPreferredSize().height)); appearanceCounterLabel.setPreferredSize(new Dimension(100, appearanceLabel.getPreferredSize().height)); textureCounterLabel.setPreferredSize(new Dimension(100, textureLabel.getPreferredSize().height)); progressBar = new JProgressBar(); setLayout(new GridBagLayout()); { main = new JPanel(); add(main, GuiUtil.setConstraints(0,0,1.0,0.0,GridBagConstraints.BOTH,5,5,5,5)); main.setLayout(new GridBagLayout()); { main.add(fileName, GuiUtil.setConstraints(0,0,0.0,0,GridBagConstraints.HORIZONTAL,5,5,5,5)); main.add(mesageLabel, GuiUtil.setConstraints(0,1,0.0,0,GridBagConstraints.HORIZONTAL,5,5,0,5)); main.add(progressBar, GuiUtil.setConstraints(0,2,1.0,0.0,GridBagConstraints.HORIZONTAL,0,5,5,5)); details = new JLabel("Details"); main.add(details, GuiUtil.setConstraints(0,3,1.0,0.0,GridBagConstraints.HORIZONTAL,5,5,0,5)); row = new JPanel(); row.setBackground(new Color(255, 255, 255)); row.setBorder(BorderFactory.createEtchedBorder()); main.add(row, GuiUtil.setConstraints(0,4,1.0,0.0,GridBagConstraints.BOTH,0,5,5,5)); row.setLayout(new GridBagLayout()); { row.add(featureLabel, GuiUtil.setConstraints(0,0,0.0,0.0,GridBagConstraints.HORIZONTAL,5,5,1,5)); row.add(featureCounterLabel, GuiUtil.setConstraints(1,0,1.0,0.0,GridBagConstraints.HORIZONTAL,5,5,1,5)); row.add(appearanceLabel, GuiUtil.setConstraints(0,1,0.0,0.0,GridBagConstraints.HORIZONTAL,1,5,1,5)); row.add(appearanceCounterLabel, GuiUtil.setConstraints(1,1,1.0,0.0,GridBagConstraints.HORIZONTAL,1,5,1,5)); row.add(textureLabel, GuiUtil.setConstraints(0,2,0.0,0.0,GridBagConstraints.HORIZONTAL,1,5,5,5)); row.add(textureCounterLabel, GuiUtil.setConstraints(1,2,1.0,0.0,GridBagConstraints.HORIZONTAL,1,5,5,5)); row.add(fileCounter, GuiUtil.setConstraints(0,3,1.0,0.0,GridBagConstraints.HORIZONTAL,1,5,5,5)); row.add(fileCounterLabel, GuiUtil.setConstraints(1,3,1.0,0.0,GridBagConstraints.HORIZONTAL,1,5,5,5)); } } add(cancelButton, GuiUtil.setConstraints(0,1,0.0,0.5,GridBagConstraints.NONE,5,5,5,5)); } pack(); progressBar.setIndeterminate(true); addWindowListener(new WindowAdapter() { public void windowClosed(WindowEvent e) { eventDispatcher.removeEventHandler(ImportStatusDialog.this); } }); }
Example 15
Source File: ComponentCellRenderer.java From mzmine2 with GNU General Public License v2.0 | 4 votes |
/** * @see javax.swing.table.TableCellRenderer#getTableCellRendererComponent(javax.swing.JTable, * java.lang.Object, boolean, boolean, int, int) */ public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) { JPanel newPanel = new JPanel(); newPanel.setLayout(new OverlayLayout(newPanel)); Color bgColor; if (isSelected) bgColor = table.getSelectionBackground(); else bgColor = table.getBackground(); newPanel.setBackground(bgColor); if (hasFocus) { Border border = null; if (isSelected) border = UIManager.getBorder("Table.focusSelectedCellHighlightBorder"); if (border == null) border = UIManager.getBorder("Table.focusCellHighlightBorder"); if (border != null) newPanel.setBorder(border); } if (value != null) { if (value instanceof JComponent) { newPanel.add((JComponent) value); } else { JLabel newLabel = new JLabel(); if (value instanceof IIsotope) { IIsotope is = (IIsotope) value; newLabel.setText(is.getSymbol()); } else { newLabel.setText(value.toString()); } if (font != null) newLabel.setFont(font); else if (table.getFont() != null) newLabel.setFont(table.getFont()); newPanel.add(newLabel); } if (createTooltips) newPanel.setToolTipText(value.toString()); } return newPanel; }
Example 16
Source File: NumberPayloadGeneratorAdapterUIHandler.java From zap-extensions with Apache License 2.0 | 4 votes |
public NumberPayloadGeneratorUIPanel() { fieldsPanel = new JPanel(); GroupLayout layout = new GroupLayout(fieldsPanel); fieldsPanel.setLayout(layout); layout.setAutoCreateGaps(true); fromField = new ZapNumberSpinner(Integer.MIN_VALUE, 0, Integer.MAX_VALUE); toField = new ZapNumberSpinner(Integer.MIN_VALUE, 0, Integer.MAX_VALUE); stepField = new ZapNumberSpinner(Integer.MIN_VALUE, 1, Integer.MAX_VALUE); JLabel fromLabel = new JLabel(PAYLOADS_FROM_LABEL); fromLabel.setLabelFor(fromField); JLabel toLabel = new JLabel(PAYLOADS_TO_LABEL); toLabel.setLabelFor(toField); JLabel stepLabel = new JLabel(PAYLOADS_INCREMENT_LABEL); stepLabel.setLabelFor(stepField); JLabel payloadsPreviewLabel = new JLabel(PAYLOADS_PREVIEW_FIELD_LABEL); payloadsPreviewLabel.setLabelFor(getPayloadsPreviewTextArea()); JScrollPane payloadsPreviewScrollPane = new JScrollPane(getPayloadsPreviewTextArea()); setPreviewAndSaveButtonsEnabled(true); layout.setHorizontalGroup( layout.createSequentialGroup() .addGroup( layout.createParallelGroup(GroupLayout.Alignment.TRAILING) .addComponent(fromLabel) .addComponent(toLabel) .addComponent(stepLabel) .addComponent(payloadsPreviewLabel)) .addGroup( layout.createParallelGroup(GroupLayout.Alignment.LEADING) .addComponent(fromField) .addComponent(toField) .addComponent(stepField) .addGroup( layout.createSequentialGroup() .addComponent( getPayloadsPreviewGenerateButton()) .addComponent(getSaveButton())) .addComponent(payloadsPreviewScrollPane))); layout.setVerticalGroup( layout.createSequentialGroup() .addGroup( layout.createParallelGroup(GroupLayout.Alignment.BASELINE) .addComponent(fromLabel) .addComponent(fromField)) .addGroup( layout.createParallelGroup(GroupLayout.Alignment.BASELINE) .addComponent(toLabel) .addComponent(toField)) .addGroup( layout.createParallelGroup(GroupLayout.Alignment.BASELINE) .addComponent(stepLabel) .addComponent(stepField)) .addGroup( layout.createParallelGroup() .addComponent(getPayloadsPreviewGenerateButton()) .addComponent(getSaveButton())) .addGroup( layout.createParallelGroup(GroupLayout.Alignment.BASELINE) .addComponent(payloadsPreviewLabel) .addComponent(payloadsPreviewScrollPane))); }
Example 17
Source File: KMeansDemo.java From COMP3204 with BSD 3-Clause "New" or "Revised" License | 4 votes |
@Override public Component getComponent(int width, int height) throws IOException { final JPanel base = new JPanel(); base.setOpaque(false); base.setPreferredSize(new Dimension(width, height)); base.setLayout(new BoxLayout(base, BoxLayout.Y_AXIS)); image = new MBFImage(width, height - 50, ColourSpace.RGB); renderer = image.createRenderer(RenderHints.FAST); resetImage(); ic = new DisplayUtilities.ImageComponent(true, false); ic.setShowPixelColours(false); ic.setShowXYPosition(false); ic.setAllowPanning(false); ic.setAllowZoom(false); ic.addMouseListener(this); ic.addMouseMotionListener(this); base.add(ic); final JPanel controls = new JPanel(); controls.setPreferredSize(new Dimension(width, 50)); controls.setMaximumSize(new Dimension(width, 50)); controls.setSize(new Dimension(width, 50)); clearBtn = new JButton("Clear"); clearBtn.setActionCommand("button.clear"); clearBtn.addActionListener(this); controls.add(clearBtn); controls.add(new JSeparator(SwingConstants.VERTICAL)); controls.add(new JLabel("K:")); kSpn = new JSpinner(new SpinnerNumberModel(1, 1, 10, 1)); controls.add(kSpn); controls.add(new JSeparator(SwingConstants.VERTICAL)); runBtn = new JButton("Run KMeans"); runBtn.setActionCommand("button.run"); runBtn.addActionListener(this); controls.add(runBtn); controls.add(new JSeparator(SwingConstants.VERTICAL)); cnclBtn = new JButton("Cancel"); cnclBtn.setEnabled(false); cnclBtn.setActionCommand("button.cancel"); cnclBtn.addActionListener(this); controls.add(cnclBtn); base.add(controls); updateImage(); return base; }
Example 18
Source File: MainFrame.java From Hotel-Properties-Management-System with GNU General Public License v2.0 | 4 votes |
public MainFrame() { logging = LoggingEngine.getInstance(); componentOrientation = new ChangeComponentOrientation(); componentOrientation.setTheFrame(this); bean = LocaleBean.getInstance(); sessionBean = SessionBean.getSESSION_BEAN(); // get operation system name to add icon (if windows to taskbar else for dock) mainPanel = new JPanel(); mainPanel.setLayout(new BorderLayout()); mainPanel.setBackground(Color.decode("#066d95")); this.setIconImage(Toolkit.getDefaultToolkit(). getImage(getClass().getResource(LOGOPATH))); this.setTitle("Coder HPMSA - [Main]"); this.setMinimumSize(new Dimension(800, 600)); /*make it default size of frame maximized */ this.setExtendedState(Frame.MAXIMIZED_BOTH); /*get the external menubar and initialize it*/ customMenuBar = new Main_MenuBar(); customMenuBar.setJFrame(this); customMenuBar.themeChanger.setFrame(this); /*add it to our frame*/ this.setJMenuBar(customMenuBar.getMenuBar()); currency = new GetLiveCurrencyRates(); customUperToolbar = new Main_UpperToolbar(mainPanel); this.getContentPane().add(mainPanel, BorderLayout.CENTER);//add it this frame after injection customBottomToolbar = new Main_BottomToolbar(); //get user name from login frame and add it to main frame customBottomToolbar.setUserLabelText(sessionBean.getNickName()); customBottomToolbar.setUsdLabelText(currency.getUSDToTRYLiveCurrency()); customBottomToolbar.setEuroLabelText(currency.getEURToTRYLiveCurrency()); customBottomToolbar.setPoundLabelText(currency.getGBPToTRYLiveCurrency()); customBottomToolbar.setDateLabelText(""); customBottomToolbar.sethotelNameLabelText(sessionBean.getHotelName()); /*add it to our frame*/ getContentPane().add(customUperToolbar, BorderLayout.NORTH); getContentPane().add(customBottomToolbar.getToolBar(), BorderLayout.SOUTH); //change language as locale. changeLanguage(bean.getLocale()); //change component orientation with locale. if (bean.getLocale().toString().equals("ar_IQ")) { componentOrientation.changeOrientationOfJFrameToRight(); } else { componentOrientation.changeOrientationOfJFrameToLeft(); } /*set exiting from the application when clicking on X button*/ this.addWindowListener(new WindowAdapter() { @Override public void windowClosing(WindowEvent e) { final int decision = JOptionPane.showConfirmDialog(null, exitMessage, titleMessage, JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE); if (decision == JOptionPane.YES_OPTION) { new DataSourceFactory().shutDown(); System.exit(0); } else { setDefaultCloseOperation(WindowConstants.DO_NOTHING_ON_CLOSE); } super.windowClosing(e); } }); logging.setMessage("MainFrame created successfully."); this.setVisible(true); }
Example 19
Source File: MarvinFilterWindow.java From marvinproject with GNU Lesser General Public License v3.0 | 4 votes |
/** * Constructs a {@link MarvinFilterWindow} * @param name Window name * @param width width * @param height height * @param thumbWidth thumbnail with * @param thumbHeight thumbnail height * @param ip {@link MarvinImagePanel} * @param plg {@link MarvinPlugin} */ public MarvinFilterWindow ( String name, int width, int height, int thumbWidth, int thumbHeight, MarvinImagePanel ip, MarvinImagePlugin plg ) { super(name, width, height, plg.getAttributesPanel()); attributesPanel = plg.getAttributesPanel(); if(attributesPanel != null){ int newWidth = width; if(attributesPanel.getPreferredSize().width > width){ newWidth = attributesPanel.getPreferredSize().width+20; } setSize(newWidth, height+attributesPanel.getPreferredSize().height); } imagePanel = ip; plugin = plg; //Buttons actionHandler = new ActionHandler(); buttonPreview = new JButton("Preview"); buttonReset = new JButton("Reset"); buttonApply = new JButton("Apply"); buttonPreview.setMnemonic('P'); buttonReset.setMnemonic('R'); buttonApply.setMnemonic('A'); buttonPreview.addActionListener(actionHandler); buttonReset.addActionListener(actionHandler); buttonApply.addActionListener(actionHandler); // Fixed Components panelFixedComponents = new JPanel(); panelFixedComponents.setLayout(new FlowLayout()); panelFixedComponents.add(buttonPreview); panelFixedComponents.add(buttonReset); panelFixedComponents.add(buttonApply); // Image Panel panelImage = new JPanel(); panelImage.setLayout(new FlowLayout()); // Image if(thumbWidth > 0 && thumbHeight > 0){ imageThumbnail = new MarvinImage(imagePanel.getImage().getBufferedImage(thumbWidth, thumbHeight, MarvinImage.PROPORTIONAL)); imageResetBuffer = imageThumbnail.clone(); labelImage = new JLabel(new ImageIcon(imageThumbnail.getBufferedImage())); panelImage.add(labelImage); } imageOut = new MarvinImage(imagePanel.getImage().getWidth(), imagePanel.getImage().getHeight(), imagePanel.getImage().getColorModel()); container.add(panelImage, BorderLayout.NORTH); container.add(panelCenter, BorderLayout.CENTER); container.add(panelFixedComponents, BorderLayout.SOUTH); }
Example 20
Source File: XSheet.java From jdk8u-jdk with GNU General Public License v2.0 | 4 votes |
private void setupScreen() { setLayout(new BorderLayout()); setBorder(BorderFactory.createLineBorder(Color.GRAY)); // add main panel to XSheet mainPanel = new JPanel(); mainPanel.setLayout(new BorderLayout()); add(mainPanel, BorderLayout.CENTER); // add south panel to XSheet southPanel = new JPanel(); add(southPanel, BorderLayout.SOUTH); // create the refresh button refreshButton = new JButton(Messages.MBEANS_TAB_REFRESH_ATTRIBUTES_BUTTON); refreshButton.setMnemonic(Resources.getMnemonicInt(Messages.MBEANS_TAB_REFRESH_ATTRIBUTES_BUTTON)); refreshButton.setToolTipText(Messages.MBEANS_TAB_REFRESH_ATTRIBUTES_BUTTON_TOOLTIP); refreshButton.addActionListener(this); // create the clear button clearButton = new JButton(Messages.MBEANS_TAB_CLEAR_NOTIFICATIONS_BUTTON); clearButton.setMnemonic(Resources.getMnemonicInt(Messages.MBEANS_TAB_CLEAR_NOTIFICATIONS_BUTTON)); clearButton.setToolTipText(Messages.MBEANS_TAB_CLEAR_NOTIFICATIONS_BUTTON_TOOLTIP); clearButton.addActionListener(this); // create the subscribe button subscribeButton = new JButton(Messages.MBEANS_TAB_SUBSCRIBE_NOTIFICATIONS_BUTTON); subscribeButton.setMnemonic(Resources.getMnemonicInt(Messages.MBEANS_TAB_SUBSCRIBE_NOTIFICATIONS_BUTTON)); subscribeButton.setToolTipText(Messages.MBEANS_TAB_SUBSCRIBE_NOTIFICATIONS_BUTTON_TOOLTIP); subscribeButton.addActionListener(this); // create the unsubscribe button unsubscribeButton = new JButton(Messages.MBEANS_TAB_UNSUBSCRIBE_NOTIFICATIONS_BUTTON); unsubscribeButton.setMnemonic(Resources.getMnemonicInt(Messages.MBEANS_TAB_UNSUBSCRIBE_NOTIFICATIONS_BUTTON)); unsubscribeButton.setToolTipText(Messages.MBEANS_TAB_UNSUBSCRIBE_NOTIFICATIONS_BUTTON_TOOLTIP); unsubscribeButton.addActionListener(this); // create XMBeanAttributes container mbeanAttributes = new XMBeanAttributes(mbeansTab); // create XMBeanOperations container mbeanOperations = new XMBeanOperations(mbeansTab); mbeanOperations.addOperationsListener(this); // create XMBeanNotifications container mbeanNotifications = new XMBeanNotifications(); mbeanNotifications.addNotificationsListener(this); // create XMBeanInfo container mbeanInfo = new XMBeanInfo(); }