private void initUI() { JPanel panel = new JPanel(); JTextArea area = new JTextArea("Text zona"); area.setPreferredSize(new Dimension(100, 100)); JButton button = new JButton("Buton"); button.addActionListener( new ActionListener() { @Override public void actionPerformed(ActionEvent actionEvent) { System.exit(0); } }); panel.add(button); JTree tree = new JTree(); panel.add(tree); panel.add(area); add(panel); pack(); setTitle("Fereastra layout flow"); setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); setLocationRelativeTo(null); }
protected void createWidgets() { ReadOnlyTableModel<B> model = new ReadOnlyTableModel<>(getAssignments()); model.addColumn( "Profesor", "request", new ToStringConverter<Request>() { @Override public String convert(Request aRequest) { return aRequest.getProfessor().getName(); } }); model.addColumn( "Materia", "request", new ToStringConverter<Request>() { @Override public String convert(Request aRequest) { return aRequest.getSubject().getName(); } }); assignmentsTable = new JTable(model); assignmentsTable.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); assignmentsTable .getSelectionModel() .addListSelectionListener( AssignmentsDetailWindow.this::whenAssignmentsTableSelectionChanged); periodDetail = new JTextArea(); periodDetail.setPreferredSize(new Dimension(480, 100)); periodDetail.setEditable(false); createOtherWidgets(); }
protected JComponent createCenterPanel() { JPanel panel = new JPanel(new GridBagLayout()); GridBagConstraints constr; // list label constr = new GridBagConstraints(); constr.gridy = 0; constr.anchor = GridBagConstraints.WEST; constr.insets = new Insets(5, 5, 0, 5); panel.add(new JLabel(IdeBundle.message("label.macros")), constr); // macros list constr = new GridBagConstraints(); constr.gridy = 1; constr.weightx = 1; constr.weighty = 1; constr.insets = new Insets(0, 5, 0, 5); constr.fill = GridBagConstraints.BOTH; constr.anchor = GridBagConstraints.WEST; panel.add(new JScrollPane(myMacrosList), constr); myMacrosList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); myMacrosList.setPreferredSize(null); // preview label constr = new GridBagConstraints(); constr.gridx = 0; constr.gridy = 2; constr.anchor = GridBagConstraints.WEST; constr.insets = new Insets(5, 5, 0, 5); panel.add(new JLabel(IdeBundle.message("label.macro.preview")), constr); // preview constr = new GridBagConstraints(); constr.gridx = 0; constr.gridy = 3; constr.weightx = 1; constr.weighty = 1; constr.fill = GridBagConstraints.BOTH; constr.anchor = GridBagConstraints.WEST; constr.insets = new Insets(0, 5, 5, 5); panel.add(new JScrollPane(myPreviewTextarea), constr); myPreviewTextarea.setEditable(false); myPreviewTextarea.setLineWrap(true); myPreviewTextarea.setPreferredSize(null); panel.setPreferredSize(new Dimension(400, 500)); return panel; }
{ // Set the layout to the frame in order to show the panels, BorderLayout used. setLayout(new BorderLayout()); // program will stop running when "X" is pressed. setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE); // set the title for the program. this.setTitle("Financial Modeller - B00540772"); // add the two frames to the frame show that they will show in the correct areas. this.add(drawing, BorderLayout.NORTH); this.add(control, BorderLayout.SOUTH); // add the instructions panel into the frame. this.add(instructions, BorderLayout.CENTER); // set the size of the two panels. drawing.setPreferredSize(new Dimension(900, 350)); control.setPreferredSize(new Dimension(900, 250)); instructions.setPreferredSize(new Dimension(900, 80)); // set the background of the DrawingPanel to highlight the two different panels. drawing.setBackground(Color.WHITE); // call the line wrap method to improve the layout of the text area. instructions.setLineWrap(true); // insert the instructions for the user. instructions.append( "Please use the control panel to enter your financial" + " information. When the information has been entered press 'Start'" + " to run the simulation. The textual output will show each" + " input and output as it happens, and will give you a balance update." + " The graphical output will give you a representation of the changing" + " weekly balance, each second represents" + " one week. Please be aware that if the balance goes above £16000" + " or the duration goes above 52 weeks the graphical output will stop," + " if this happens you can continue to use the textual output." + " If you do not wish to use all of the threads please leave amount AND" + " frequency as '0' and that thread will not start."); // set visible and pack to ensure it will run correctly. pack(); setVisible(true); }
private JTextArea getTextArea() { JTextArea textArea = new JTextArea(); textArea.setPreferredSize(new Dimension(350, 50)); textArea.setLineWrap(true); return textArea; }
protected JComponent createCenterPanel() { JPanel panel = new JPanel(new GridBagLayout()); // Single/Double click JPanel clickCountPanel = new JPanel(new GridBagLayout()); clickCountPanel.setBorder( IdeBorderFactory.createTitledBorder( KeyMapBundle.message("mouse.shortcut.dialog.click.count.border"), false, true, true)); panel.add( clickCountPanel, new GridBagConstraints( 0, 0, 1, 1, 1, 0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0)); clickCountPanel.add( myRbSingleClick, new GridBagConstraints( 0, 0, 1, 1, 1, 0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(0, 0, 0, 10), 0, 0)); clickCountPanel.add( myRbDoubleClick, new GridBagConstraints( 1, 0, 1, 1, 1, 0, GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0)); ActionListener listener = new ActionListener() { public void actionPerformed(ActionEvent e) { updatePreviewAndConflicts(); } }; myRbSingleClick.addActionListener(listener); myRbDoubleClick.addActionListener(listener); // Click pad JPanel clickPadPanel = new JPanel(new BorderLayout()); panel.add( clickPadPanel, new GridBagConstraints( 0, 1, 1, 1, 1, 0, GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(0, 0, 4, 0), 0, 0)); clickPadPanel.setBorder( IdeBorderFactory.createTitledBorder( KeyMapBundle.message("mouse.shortcut.dialog.click.pad.border"), false, true, true)); myClickPad.setPreferredSize(new Dimension(260, 60)); clickPadPanel.add(myClickPad, BorderLayout.CENTER); // Shortcut preview JPanel previewPanel = new JPanel(new GridBagLayout()); previewPanel.setBorder( IdeBorderFactory.createTitledBorder( KeyMapBundle.message("mouse.shortcut.dialog.shortcut.preview.border"), false, true, true)); panel.add( previewPanel, new GridBagConstraints( 0, 2, 1, 1, 1, 0, GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(0, 0, 4, 0), 0, 0)); previewPanel.add( myLblPreview, new GridBagConstraints( 0, 0, 1, 1, 1, 1, GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(2, 2, 2, 2), 0, 0)); // Conflicts panel JPanel conflictsPanel = new JPanel(new GridBagLayout()); conflictsPanel.setBorder( IdeBorderFactory.createTitledBorder( KeyMapBundle.message("mouse.shortcut.dialog.conflicts.border"), false, true, true)); panel.add( conflictsPanel, new GridBagConstraints( 0, 3, 1, 1, 1, 1, GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(0, 0, 0, 0), 0, 0)); myTarConflicts.setPreferredSize(new Dimension(260, 60)); JScrollPane scrollPane = ScrollPaneFactory.createScrollPane(myTarConflicts); scrollPane.setBorder(null); conflictsPanel.add( scrollPane, new GridBagConstraints( 0, 0, 1, 1, 1, 1, GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(0, 0, 0, 0), 0, 0)); return panel; }
protected void init() { GridBagLayout gb = new GridBagLayout(); GridBagConstraints gbc = new GridBagConstraints(); setLayout(gb); JLabel subjectDNLbl = makeJLabel("SUBJECTDN"); CMSAdminUtil.resetGBC(gbc); gbc.anchor = gbc.NORTHWEST; gbc.weightx = 1.0; gbc.insets = new Insets(COMPONENT_SPACE, COMPONENT_SPACE, 0, COMPONENT_SPACE); add(subjectDNLbl, gbc); JLabel issuerLbl = makeJLabel("ISSUE"); CMSAdminUtil.resetGBC(gbc); gbc.anchor = gbc.NORTHWEST; gbc.gridwidth = gbc.REMAINDER; gbc.weightx = 1.0; gbc.insets = new Insets(COMPONENT_SPACE, COMPONENT_SPACE, 0, COMPONENT_SPACE); add(issuerLbl, gbc); JTextArea subjectText = new JTextArea(null, null, 0, 0); JScrollPane subjectScrollPane = new JScrollPane( subjectText, JScrollPane.VERTICAL_SCROLLBAR_ALWAYS, JScrollPane.HORIZONTAL_SCROLLBAR_ALWAYS); // subjectScrollPane.setPreferredSize(new Dimension(50, 30)); CMSAdminUtil.resetGBC(gbc); gbc.anchor = gbc.NORTHWEST; gbc.insets = new Insets(0, COMPONENT_SPACE, COMPONENT_SPACE, 0); gbc.weighty = 1.0; gbc.weightx = 1.0; gbc.fill = gbc.BOTH; add(subjectScrollPane, gbc); JTextArea issueText = new JTextArea(null, null, 0, 0); JScrollPane issueScrollPane = new JScrollPane( issueText, JScrollPane.VERTICAL_SCROLLBAR_ALWAYS, JScrollPane.HORIZONTAL_SCROLLBAR_ALWAYS); // issueScrollPane.setPreferredSize(new Dimension(50, 30)); CMSAdminUtil.resetGBC(gbc); gbc.insets = new Insets(0, COMPONENT_SPACE, COMPONENT_SPACE, COMPONENT_SPACE); gbc.anchor = gbc.NORTHWEST; gbc.weighty = 1.0; gbc.weightx = 1.0; gbc.fill = gbc.BOTH; gbc.gridwidth = gbc.REMAINDER; add(issueScrollPane, gbc); JTextArea infoText = new JTextArea(null, null, 0, 0); gbc.insets = new Insets(COMPONENT_SPACE, COMPONENT_SPACE, COMPONENT_SPACE, COMPONENT_SPACE); infoText.setPreferredSize(new Dimension(50, 20)); gbc.fill = gbc.BOTH; gbc.anchor = gbc.NORTHWEST; gbc.gridwidth = gbc.REMAINDER; gbc.weighty = 1.0; add(infoText, gbc); mAdd = makeJButton("ADD"); CMSAdminUtil.resetGBC(gbc); gbc.anchor = gbc.NORTHEAST; gbc.fill = gbc.NONE; gbc.insets = new Insets(COMPONENT_SPACE, COMPONENT_SPACE, COMPONENT_SPACE, COMPONENT_SPACE); gbc.gridwidth = gbc.REMAINDER; add(mAdd, gbc); super.init(); }
private void jbInit() throws Exception { saveButton.setText("Save"); saveButton.addActionListener(new PrintfTemplateEditor_saveButton_actionAdapter(this)); cancelButton.setText("Cancel"); cancelButton.addActionListener(new PrintfTemplateEditor_cancelButton_actionAdapter(this)); this.setTitle(this.getTitle() + " Template Editor"); printfPanel.setLayout(gridBagLayout1); formatLabel.setFont(new java.awt.Font("DialogInput", 0, 12)); formatLabel.setText("Format String:"); buttonPanel.setLayout(flowLayout1); printfPanel.setBorder(BorderFactory.createEtchedBorder()); printfPanel.setMinimumSize(new Dimension(100, 160)); printfPanel.setPreferredSize(new Dimension(380, 160)); parameterPanel.setLayout(gridBagLayout2); parameterLabel.setText("Parameters:"); parameterLabel.setFont(new java.awt.Font("DialogInput", 0, 12)); parameterTextArea.setMinimumSize(new Dimension(100, 25)); parameterTextArea.setPreferredSize(new Dimension(200, 25)); parameterTextArea.setEditable(true); parameterTextArea.setText(""); insertButton.setMaximumSize(new Dimension(136, 20)); insertButton.setMinimumSize(new Dimension(136, 20)); insertButton.setPreferredSize(new Dimension(136, 20)); insertButton.setToolTipText( "insert the format in the format string and add parameter to list."); insertButton.setText("Insert Parameter"); insertButton.addActionListener(new PrintfTemplateEditor_insertButton_actionAdapter(this)); formatTextArea.setMinimumSize(new Dimension(100, 25)); formatTextArea.setPreferredSize(new Dimension(200, 15)); formatTextArea.setText(""); parameterPanel.setBorder(null); parameterPanel.setMinimumSize(new Dimension(60, 40)); parameterPanel.setPreferredSize(new Dimension(300, 40)); insertMatchButton.addActionListener( new PrintfTemplateEditor_insertMatchButton_actionAdapter(this)); insertMatchButton.setText("Insert Match"); insertMatchButton.setToolTipText( "insert the match in the format string and add parameter to list."); insertMatchButton.setPreferredSize(new Dimension(136, 20)); insertMatchButton.setMinimumSize(new Dimension(136, 20)); insertMatchButton.setMaximumSize(new Dimension(136, 20)); matchPanel.setPreferredSize(new Dimension(300, 40)); matchPanel.setBorder(null); matchPanel.setMinimumSize(new Dimension(60, 60)); matchPanel.setLayout(gridBagLayout3); InsertPanel.setLayout(gridLayout1); gridLayout1.setColumns(1); gridLayout1.setRows(2); gridLayout1.setVgap(0); InsertPanel.setBorder(BorderFactory.createEtchedBorder()); InsertPanel.setMinimumSize(new Dimension(100, 100)); InsertPanel.setPreferredSize(new Dimension(380, 120)); editorPane.setText(""); editorPane.addKeyListener(new PrintfEditor_editorPane_keyAdapter(this)); printfTabPane.addChangeListener(new PrintfEditor_printfTabPane_changeAdapter(this)); parameterPanel.add( insertButton, new GridBagConstraints( 1, 0, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(8, 6, 13, 8), 0, 10)); parameterPanel.add( paramComboBox, new GridBagConstraints( 0, 0, 1, 1, 1.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(8, 8, 13, 0), 258, 11)); paramComboBox.setRenderer(new MyCellRenderer()); InsertPanel.add(matchPanel, null); InsertPanel.add(parameterPanel, null); buttonPanel.add(cancelButton, null); buttonPanel.add(saveButton, null); this.getContentPane().add(printfTabPane, BorderLayout.NORTH); this.getContentPane().add(InsertPanel, BorderLayout.CENTER); matchPanel.add( insertMatchButton, new GridBagConstraints( 1, 0, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(8, 6, 13, 8), 0, 10)); matchPanel.add( matchComboBox, new GridBagConstraints( 0, 0, 1, 1, 1.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(8, 8, 13, 0), 258, 11)); printfPanel.add( parameterLabel, new GridBagConstraints( 0, 2, 1, 1, 0.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(7, 5, 0, 5), 309, 0)); printfPanel.add( formatLabel, new GridBagConstraints( 0, 0, 1, 1, 0.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(4, 5, 0, 5), 288, 0)); printfPanel.add( formatTextArea, new GridBagConstraints( 0, 1, 1, 1, 1.0, 1.0, GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(6, 5, 0, 5), 300, 34)); printfPanel.add( parameterTextArea, new GridBagConstraints( 0, 3, 1, 1, 1.0, 1.0, GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(6, 5, 6, 5), 300, 34)); printfTabPane.addTab("Editor View", null, editorPanel, "View in Editor"); printfTabPane.addTab("Printf View", null, printfPanel, "Vies as Printf"); editorPane.setCharacterAttributes(PLAIN_ATTR, true); editorPane.addStyle("PLAIN", editorPane.getLogicalStyle()); editorPanel.getViewport().add(editorPane, null); this.getContentPane().add(buttonPanel, BorderLayout.SOUTH); buttonGroup.add(cancelButton); }