List of usage examples for javax.swing JPanel setLayout
public void setLayout(LayoutManager mgr)
From source file:com.documentgenerator.view.MainWindow.java
private void initComponents() { statusBarPanel = new StatusBarPanel(); //JPanel northPanel = new ImagePanel(new FlowLayout(), windowUtils.getImageIcon("images/header.gif").getImage()); JPanel centerPanel = new JPanel(); JPanel southPanel = new JPanel(new FlowLayout()); centerPanel.setLayout(new BorderLayout()); centerPanel.setBackground(Color.WHITE); //adding components mdlFunctions.setJTabbedPane(tabbedPane); tabbedPane.addTab("Configuration", WindowUtils.getImageIcon("images/ListBarrowers.gif"), new ConfigPanel(this), "Configuration"); tabbedPane.addTab("Name Entry", WindowUtils.getImageIcon("images/ListBarrowers.gif"), new NameEntryConfigPanel(this), "Name Entry"); tabbedPane.addTab("Schedule Entry", WindowUtils.getImageIcon("images/ListBarrowers.gif"), new ScheduleEntryConfigPanel(this), "Schedule Entry"); tabbedPane.addTab("Document Details", WindowUtils.getImageIcon("images/ListBarrowers.gif"), new DocumentEntryConfigPanel(this), "Document Details"); //northPanel.add(lblIcon); //northPanel.add(lblCaption); centerPanel.add(tabbedPane);//ww w .j av a2s.c om southPanel.setBackground(Color.WHITE); southPanel.add(statusBarPanel); setLayout(new BorderLayout()); setBackground(Color.WHITE); //add(northPanel, BorderLayout.PAGE_START); add(centerPanel, BorderLayout.CENTER); add(southPanel, BorderLayout.SOUTH); menuBar = new JMenuBar(); container = getContentPane(); setJMenuBar(menuBar); }
From source file:EditorPaneExample7.java
public EditorPaneExample7() { super("JEditorPane Example 7"); pane = new JEditorPane(); pane.setEditable(false); // Start read-only getContentPane().add(new JScrollPane(pane), "Center"); // Build the panel of controls JPanel panel = new JPanel(); panel.setLayout(new GridBagLayout()); GridBagConstraints c = new GridBagConstraints(); c.gridwidth = 1;/*from w ww . ja va 2 s . c om*/ c.gridheight = 1; c.anchor = GridBagConstraints.EAST; c.fill = GridBagConstraints.NONE; c.weightx = 0.0; c.weighty = 0.0; JLabel urlLabel = new JLabel("File name: ", JLabel.RIGHT); panel.add(urlLabel, c); JLabel loadingLabel = new JLabel("State: ", JLabel.RIGHT); c.gridy = 1; panel.add(loadingLabel, c); JLabel typeLabel = new JLabel("Type: ", JLabel.RIGHT); c.gridy = 2; panel.add(typeLabel, c); c.gridx = 1; c.gridy = 0; c.gridwidth = 1; c.weightx = 1.0; c.fill = GridBagConstraints.HORIZONTAL; textField = new JTextField(32); panel.add(textField, c); loadingState = new JLabel(spaces, JLabel.LEFT); loadingState.setForeground(Color.black); c.gridy = 1; c.gridwidth = 2; panel.add(loadingState, c); loadedType = new JLabel(spaces, JLabel.LEFT); loadedType.setForeground(Color.black); c.gridy = 2; panel.add(loadedType, c); getContentPane().add(panel, "South"); panel = new JPanel(); panel.setLayout(new BoxLayout(panel, BoxLayout.Y_AXIS)); saveButton = new JButton("Save"); plain = new JCheckBox("Plain Text"); html = new JCheckBox("HTML"); rtf = new JCheckBox("RTF"); panel.add(plain); panel.add(html); panel.add(rtf); ButtonGroup group = new ButtonGroup(); group.add(plain); group.add(html); group.add(rtf); plain.setSelected(true); panel.add(Box.createVerticalStrut(10)); panel.add(saveButton); panel.add(Box.createVerticalGlue()); panel.setBorder(BorderFactory.createEmptyBorder(2, 4, 2, 4)); getContentPane().add(panel, "East"); // Change page based on text field textField.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { String fileName = textField.getText().trim(); file = new File(fileName); absolutePath = file.getAbsolutePath(); String url = "file:///" + absolutePath; try { // Check if the new page and the old // page are the same. URL newURL = new URL(url); URL loadedURL = pane.getPage(); if (loadedURL != null && loadedURL.sameFile(newURL)) { return; } // Try to display the page textField.setEnabled(false); // Disable input textField.paintImmediately(0, 0, textField.getSize().width, textField.getSize().height); saveButton.setEnabled(false); saveButton.paintImmediately(0, 0, saveButton.getSize().width, saveButton.getSize().height); setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR)); // Busy cursor loadingState.setText("Loading..."); loadingState.paintImmediately(0, 0, loadingState.getSize().width, loadingState.getSize().height); loadedType.setText(""); loadedType.paintImmediately(0, 0, loadedType.getSize().width, loadedType.getSize().height); pane.setEditable(false); pane.setPage(url); loadedType.setText(pane.getContentType()); } catch (Exception e) { JOptionPane.showMessageDialog(pane, new String[] { "Unable to open file", url }, "File Open Error", JOptionPane.ERROR_MESSAGE); loadingState.setText("Failed"); textField.setEnabled(true); setCursor(Cursor.getDefaultCursor()); } } }); // Listen for page load to complete pane.addPropertyChangeListener(new PropertyChangeListener() { public void propertyChange(PropertyChangeEvent evt) { if (evt.getPropertyName().equals("page")) { loadingState.setText("Page loaded."); textField.setEnabled(true); // Allow entry of new file name textField.requestFocus(); setCursor(Cursor.getDefaultCursor()); // Allow editing and saving if appropriate pane.setEditable(file.canWrite()); saveButton.setEnabled(file.canWrite()); } } }); saveButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { Writer w = null; OutputStream os = System.out; String contentType; if (plain.isSelected()) { contentType = "text/plain"; w = new OutputStreamWriter(os); } else if (html.isSelected()) { contentType = "text/html"; w = new OutputStreamWriter(os); } else { contentType = "text/rtf"; } EditorKit kit = pane.getEditorKitForContentType(contentType); try { if (w != null) { kit.write(w, pane.getDocument(), 0, pane.getDocument().getLength()); w.flush(); } else { kit.write(os, pane.getDocument(), 0, pane.getDocument().getLength()); os.flush(); } } catch (Exception e) { System.out.println("Write failed"); } } }); }
From source file:IDlookBlob.java
private void buildGUI() { Container c = getContentPane(); c.setLayout(new FlowLayout()); accountNumberList = new JList(); loadAccounts();/*from w ww .j a v a 2 s . co m*/ accountNumberList.setVisibleRowCount(2); JScrollPane accountNumberListScrollPane = new JScrollPane(accountNumberList); //Do Get Account Button getAccountButton = new JButton("Get Account"); getAccountButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { try { rs.beforeFirst(); while (rs.next()) { if (rs.getString("acc_id").equals(accountNumberList.getSelectedValue())) break; } if (!rs.isAfterLast()) { accountIDText.setText(rs.getString("acc_id")); thumbIDText.setText(rs.getString("thumb_id")); Blob b = rs.getBlob("pic"); icon = new ImageIcon(b.getBytes(1L, (int) b.length())); createThumbnail(); photographLabel.setIcon(iconThumbnail); } } catch (SQLException selectException) { displaySQLErrors(selectException); } } }); //Do Update Account Button updateAccountButton = new JButton("Update Account"); updateAccountButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { try { byte[] bytes = new byte[50000]; FileInputStream fs = new FileInputStream(nailFileText.getText()); BufferedInputStream bis = new BufferedInputStream(fs); bis.read(bytes); rs.updateBytes("thumbnail.pic", bytes); rs.updateRow(); bis.close(); accountNumberList.removeAll(); loadAccounts(); } catch (SQLException insertException) { displaySQLErrors(insertException); } catch (Exception generalE) { generalE.printStackTrace(); } } }); //Do insert Account Button insertAccountButton = new JButton("Insert Account"); insertAccountButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { try { byte[] bytes = new byte[50000]; FileInputStream fs = new FileInputStream(nailFileText.getText()); BufferedInputStream bis = new BufferedInputStream(fs); bis.read(bytes); rs.moveToInsertRow(); rs.updateInt("thumb_id", Integer.parseInt(thumbIDText.getText())); rs.updateInt("acc_id", Integer.parseInt(accountIDText.getText())); rs.updateBytes("pic", bytes); rs.updateObject("sysobject", null); rs.updateTimestamp("ts", new Timestamp(0)); rs.updateTimestamp("act_ts", new Timestamp(new java.util.Date().getTime())); rs.insertRow(); bis.close(); accountNumberList.removeAll(); loadAccounts(); } catch (SQLException insertException) { displaySQLErrors(insertException); } catch (Exception generalE) { generalE.printStackTrace(); } } }); photographLabel = new JLabel(); photographLabel.setHorizontalAlignment(JLabel.CENTER); photographLabel.setVerticalAlignment(JLabel.CENTER); photographLabel.setVerticalTextPosition(JLabel.CENTER); photographLabel.setHorizontalTextPosition(JLabel.CENTER); JPanel first = new JPanel(new GridLayout(4, 1)); first.add(accountNumberListScrollPane); first.add(getAccountButton); first.add(updateAccountButton); first.add(insertAccountButton); accountIDText = new JTextField(15); thumbIDText = new JTextField(15); errorText = new JTextArea(5, 15); errorText.setEditable(false); JPanel second = new JPanel(); second.setLayout(new GridLayout(2, 1)); second.add(thumbIDText); second.add(accountIDText); JPanel third = new JPanel(); third.add(new JScrollPane(errorText)); nailFileText = new JTextField(25); c.add(first); c.add(second); c.add(third); c.add(nailFileText); c.add(photographLabel); setSize(500, 500); show(); }
From source file:com.game.ui.views.MapEditor.java
public void generateGUI() throws IOException { setDefaultCloseOperation(DISPOSE_ON_CLOSE); // setResizable(false); JMenuBar menubar = new JMenuBar(); ImageIcon icon = null;/* w w w.j a v a2 s .c o m*/ try { icon = GameUtils.shrinkImage("save.png", 20, 20); } catch (IOException e) { System.out.println("Dialog : showDialogForMap(): Exception occured :" + e); e.printStackTrace(); } JMenu file = new JMenu("File"); JMenuItem save = new JMenuItem("Save", icon); save.setToolTipText("Save Map Information"); save.setActionCommand("Save Map"); save.addActionListener(this); file.add(save); menubar.add(file); setJMenuBar(menubar); JPanel topPanel = new JPanel(); topPanel.setBorder(BorderFactory.createLineBorder(Color.BLACK)); topPanel.setLayout(new GridBagLayout()); JLabel headerLbl = new JLabel("Legend : "); headerLbl.setFont(new Font("Times New Roman", Font.BOLD, 15)); JLabel lbl1 = new JLabel(); lbl1.setPreferredSize(new Dimension(50, 20)); lbl1.setBackground(Configuration.pathColor); lbl1.setOpaque(true); JLabel lbl2 = new JLabel("- Represents the path."); JLabel lbl3 = new JLabel(); lbl3.setPreferredSize(new Dimension(50, 20)); lbl3.setBackground(Configuration.enemyColor); lbl3.setOpaque(true); JLabel lbl4 = new JLabel("- Represents the path with monsters"); JLabel lbl5 = new JLabel(); lbl5.setPreferredSize(new Dimension(50, 20)); lbl5.setBackground(Configuration.startPointColor); lbl5.setOpaque(true); JLabel lbl6 = new JLabel("- Represents the starting point in the path"); JLabel lbl7 = new JLabel(); lbl7.setBackground(Configuration.endPointColor); lbl7.setOpaque(true); lbl7.setPreferredSize(new Dimension(50, 20)); JLabel lbl8 = new JLabel("- Ending point in the path"); GridBagConstraints c = new GridBagConstraints(); c.fill = GridBagConstraints.HORIZONTAL; c.gridx = 0; c.weightx = 1; c.weighty = 0; c.insets = new Insets(5, 5, 5, 5); c.gridwidth = 2; topPanel.add(headerLbl, c); c.fill = GridBagConstraints.NONE; c.gridx = 0; c.gridy = 1; c.weightx = 0; c.weighty = 0; c.gridwidth = 1; c.ipadx = 5; c.ipady = 5; topPanel.add(lbl1, c); c.gridx = 1; c.anchor = GridBagConstraints.FIRST_LINE_START; topPanel.add(lbl2, c); c.gridx = 0; c.gridy = 2; topPanel.add(lbl3, c); c.gridx = 1; topPanel.add(lbl4, c); c.gridx = 0; c.gridy = 3; topPanel.add(lbl5, c); c.gridx = 1; topPanel.add(lbl6, c); c.gridx = 0; c.gridy = 4; topPanel.add(lbl7, c); c.gridx = 1; topPanel.add(lbl8, c); add(topPanel, BorderLayout.NORTH); bottomPanel = new JPanel(); add(bottomPanel, BorderLayout.CENTER); bottomPanel.setBorder(new EmptyBorder(5, 5, 5, 5)); // bottomPanel.add(new JButton("kaushik")); pack(); setExtendedState(JFrame.MAXIMIZED_BOTH); GraphicsEnvironment env = GraphicsEnvironment.getLocalGraphicsEnvironment(); setMaximizedBounds(env.getMaximumWindowBounds()); setVisible(true); callDialogForUsersInput(); }
From source file:com.k42b3.sacmis.Sacmis.java
public Sacmis(String path, String file, int exitCode, boolean writerStdIn) throws Exception { this.path = path; this.file = file; this.exitCode = exitCode; this.writerStdIn = writerStdIn; this.setTitle("sacmis (version: " + ver + ")"); this.setLocation(100, 100); this.setSize(600, 500); this.setMinimumSize(this.getSize()); // arguments/* w w w . j a v a2 s . co m*/ JPanel panelArgs = new JPanel(); panelArgs.setLayout(new BorderLayout()); panelArgs.setBorder(BorderFactory.createEmptyBorder(4, 4, 4, 4)); this.args = new Args(); this.args.setText(file); panelArgs.add(this.args, BorderLayout.CENTER); this.add(panelArgs, BorderLayout.NORTH); // main panel JSplitPane sp = new JSplitPane(JSplitPane.VERTICAL_SPLIT); this.in = new In(); JScrollPane scrIn = new JScrollPane(this.in); scrIn.setBorder(BorderFactory.createEmptyBorder(4, 4, 4, 4)); scrIn.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS); scrIn.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED); sp.add(scrIn); this.out = new Out(); JScrollPane scrOut = new JScrollPane(this.out); scrOut.setBorder(BorderFactory.createEmptyBorder(4, 4, 4, 4)); scrOut.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS); scrOut.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED); sp.add(scrOut); this.add(sp, BorderLayout.CENTER); // toolbar this.toolbar = new Toolbar(); this.toolbar.getRun().addActionListener(new runHandler()); this.toolbar.getReset().addActionListener(new resetHandler()); this.toolbar.getAbout().addActionListener(new aboutHandler()); this.toolbar.getExit().addActionListener(new exitHandler()); this.getContentPane().add(this.toolbar, BorderLayout.SOUTH); this.setVisible(true); this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); this.loadFile(); }
From source file:net.sf.firemox.ui.wizard.About.java
/** * Creates a new instance of About <br> * //from w ww . j a v a2s . co m * @param parent */ public About(JFrame parent) { super(LanguageManager.getString("wiz_about.title"), LanguageManager.getString("wiz_about.description"), "mp64.gif", LanguageManager.getString("close"), 420, 620); JPanel thanksPanel = new JPanel(); thanksPanel.setLayout(new BoxLayout(thanksPanel, BoxLayout.X_AXIS)); thanksPanel.setMaximumSize(new Dimension(32767, 26)); thanksPanel.setOpaque(false); JLabel jLabel5 = new JLabel(LanguageManager.getString("version") + " : "); jLabel5.setFont(MToolKit.defaultFont); jLabel5.setHorizontalAlignment(SwingConstants.RIGHT); jLabel5.setMaximumSize(new Dimension(100, 16)); jLabel5.setMinimumSize(new Dimension(100, 16)); jLabel5.setPreferredSize(new Dimension(100, 16)); thanksPanel.add(jLabel5); jLabel5 = new JLabel(IdConst.VERSION); thanksPanel.add(jLabel5); gameParamPanel.add(thanksPanel); thanksPanel = new JPanel(); thanksPanel.setLayout(new BoxLayout(thanksPanel, BoxLayout.X_AXIS)); thanksPanel.setOpaque(false); JPanel thanksPanelLeft = new JPanel(new FlowLayout(FlowLayout.LEADING)); thanksPanelLeft.setLayout(new BoxLayout(thanksPanelLeft, BoxLayout.Y_AXIS)); thanksPanelLeft.setMaximumSize(new Dimension(100, 2000)); thanksPanelLeft.setMinimumSize(new Dimension(100, 16)); jLabel5 = new JLabel(LanguageManager.getString("thanks") + " : "); jLabel5.setFont(MToolKit.defaultFont); jLabel5.setHorizontalAlignment(SwingConstants.RIGHT); jLabel5.setMaximumSize(new Dimension(100, 16)); jLabel5.setMinimumSize(new Dimension(100, 16)); jLabel5.setPreferredSize(new Dimension(100, 16)); thanksPanelLeft.add(jLabel5); thanksPanel.add(thanksPanelLeft); thanksPanelLeft = new JPanel(); thanksPanelLeft.setLayout(new BoxLayout(thanksPanelLeft, BoxLayout.Y_AXIS)); StringBuilder contributors = new StringBuilder(); addContributor(contributors, "Fabrice Daugan", "developper", "france"); addContributor(contributors, "Hoani Cross", "developper", "frenchpolynesia"); addContributor(contributors, "nico100", "graphist", "france"); addContributor(contributors, "seingalt_tm", "graphist", "france"); addContributor(contributors, "surtur2", "tester", null); addContributor(contributors, "Jan Blaha", "developper", "cz"); addContributor(contributors, "Tureba", "developper", "brazil"); addContributor(contributors, "hakvf", "tester", "france"); addContributor(contributors, "Stefano \"Kismet\" Lenzi", "developper", "italian"); jLabel5 = new JLabel(contributors.toString()); jLabel5.setFont(MToolKit.defaultFont); jLabel5.setHorizontalAlignment(SwingConstants.LEFT); thanksPanelLeft.add(jLabel5); jLabel5 = new JLink("http://obsidiurne.free.fr", "morgil has designed the splash screen"); jLabel5.setFont(MToolKit.defaultFont); thanksPanelLeft.add(jLabel5); thanksPanel.add(thanksPanelLeft); gameParamPanel.add(thanksPanel); thanksPanel = new JPanel(); thanksPanel.setLayout(new BoxLayout(thanksPanel, BoxLayout.X_AXIS)); thanksPanel.setMaximumSize(new Dimension(32767, 26)); thanksPanel.setOpaque(false); JLabel blanklbl = new JLabel(); blanklbl.setHorizontalAlignment(SwingConstants.RIGHT); blanklbl.setMaximumSize(new Dimension(100, 16)); blanklbl.setMinimumSize(new Dimension(100, 16)); blanklbl.setPreferredSize(new Dimension(100, 16)); thanksPanel.add(blanklbl); jLabel5 = new JLink( "http://sourceforge.net/tracker/?func=add&group_id=" + IdConst.PROJECT_ID + "&atid=601043", LanguageManager.getString("joindev")); jLabel5.setFont(MToolKit.defaultFont); thanksPanel.add(jLabel5); gameParamPanel.add(thanksPanel); thanksPanel = new JPanel(); thanksPanel.setLayout(new BoxLayout(thanksPanel, BoxLayout.X_AXIS)); thanksPanel.setOpaque(false); jLabel5 = new JLabel(LanguageManager.getString("projecthome") + " : "); jLabel5.setFont(MToolKit.defaultFont); jLabel5.setHorizontalAlignment(SwingConstants.RIGHT); jLabel5.setMaximumSize(new Dimension(100, 16)); jLabel5.setMinimumSize(new Dimension(100, 16)); jLabel5.setPreferredSize(new Dimension(100, 16)); thanksPanel.add(jLabel5); jLabel5 = new JLink(IdConst.MAIN_PAGE, IdConst.MAIN_PAGE); jLabel5.setFont(MToolKit.defaultFont); thanksPanel.add(jLabel5); gameParamPanel.add(thanksPanel); // forum francais thanksPanel = new JPanel(); thanksPanel.setLayout(new BoxLayout(thanksPanel, BoxLayout.X_AXIS)); thanksPanel.setOpaque(false); jLabel5 = new JLabel(LanguageManager.getString("othersites") + " : "); jLabel5.setFont(MToolKit.defaultFont); jLabel5.setHorizontalAlignment(SwingConstants.RIGHT); jLabel5.setMaximumSize(new Dimension(100, 16)); jLabel5.setMinimumSize(new Dimension(100, 16)); jLabel5.setPreferredSize(new Dimension(100, 16)); thanksPanel.add(jLabel5); jLabel5 = new JLink("http://www.Firemox.fr.st", UIHelper.getIcon("mpfrsml.gif"), SwingConstants.LEFT); jLabel5.setToolTipText(LanguageManager.getString("frenchforum.tooltip")); thanksPanel.add(jLabel5); jLabel5 = new JLabel(); jLabel5.setMaximumSize(new Dimension(1000, 16)); thanksPanel.add(jLabel5); gameParamPanel.add(thanksPanel); JTextArea disclaimer = new JTextArea(); disclaimer.setEditable(false); disclaimer.setLineWrap(true); disclaimer.setWrapStyleWord(true); disclaimer.setAutoscrolls(true); disclaimer.setTabSize(2); disclaimer.setFont(new Font("Arial", 0, 10)); // Then try and read it locally BufferedReader inGPL = null; try { inGPL = new BufferedReader(new InputStreamReader(MToolKit.getResourceAsStream(IdConst.FILE_LICENSE))); disclaimer.read(inGPL, ""); } catch (IOException e) { e.printStackTrace(); } finally { IOUtils.closeQuietly(inGPL); } JScrollPane disclaimerSPanel = new JScrollPane(); disclaimerSPanel.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER); MToolKit.addOverlay(disclaimerSPanel); disclaimerSPanel.setViewportView(disclaimer); gameParamPanel.add(disclaimerSPanel); }
From source file:LineTypes.java
JPanel guiPanel() { JPanel panel = new JPanel(); panel.setLayout(new GridLayout(0, 1)); if (isApplication) { JButton snapButton = new JButton(snapImageString); snapButton.setActionCommand(snapImageString); snapButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { doSnapshot();/*from ww w . j av a2 s.c o m*/ } }); panel.add(snapButton); } return panel; }
From source file:Visuals.RingChart.java
public JPanel addAVCharts() { JPanel thisPanel = new JPanel(); thisPanel.setLayout(new BorderLayout()); int tempCriticalCount = 0, tempUpdatedCount = 0; String[][] criticalList = new String[critical][4]; String[][] updatedList = new String[low][4]; for (int i = 0; i < riskCount; i++) { if (risks[i][2].equals("Critical")) { criticalList[tempCriticalCount][0] = risks[i][0]; criticalList[tempCriticalCount][1] = risks[i][1]; criticalList[tempCriticalCount][3] = risks[i][3]; tempCriticalCount++;/*ww w . j ava 2 s .c om*/ } if (risks[i][2].equals("Low")) { updatedList[tempUpdatedCount][0] = risks[i][0]; updatedList[tempUpdatedCount][1] = risks[i][1]; tempUpdatedCount++; } } JTable criticalTable = new JTable(criticalList, criticalColumns); JTable updatedTable = new JTable(updatedList, updatedColumns); TableColumn tcol = criticalTable.getColumnModel().getColumn(2); criticalTable.removeColumn(tcol); TableColumn tcol2 = updatedTable.getColumnModel().getColumn(2); updatedTable.removeColumn(tcol2); criticalTable.setAutoResizeMode(JTable.AUTO_RESIZE_OFF); updatedTable.setAutoResizeMode(JTable.AUTO_RESIZE_OFF); criticalTable.setEnabled(false); updatedTable.setEnabled(false); int width = 0; for (int i = 0; i < 3; i++) { for (int row = 0; row < criticalTable.getRowCount(); row++) { TableCellRenderer renderer = criticalTable.getCellRenderer(row, i); Component comp = criticalTable.prepareRenderer(renderer, row, i); width = Math.max(comp.getPreferredSize().width, width); } criticalTable.getColumnModel().getColumn(i).setPreferredWidth(width); width = 0; } for (int i = 0; i < 2; i++) { for (int row = 0; row < updatedTable.getRowCount(); row++) { TableCellRenderer renderer = updatedTable.getCellRenderer(row, i); Component comp = updatedTable.prepareRenderer(renderer, row, i); width = Math.max(comp.getPreferredSize().width, width); } updatedTable.getColumnModel().getColumn(i).setPreferredWidth(width); width = 0; } criticalTable.setShowHorizontalLines(true); criticalTable.setRowHeight(40); updatedTable.setShowHorizontalLines(true); updatedTable.setRowHeight(40); JScrollPane criticalTableScrollPane = new JScrollPane(criticalTable, JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED, JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED); JScrollPane updatedTableScrollPane = new JScrollPane(updatedTable, JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED, JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED); Dimension d = criticalTable.getPreferredSize(); criticalTableScrollPane.setPreferredSize( new Dimension((d.width - 400), (criticalTable.getRowHeight() + 1) * (tempCriticalCount + 1))); Dimension d2 = updatedTable.getPreferredSize(); updatedTableScrollPane.setPreferredSize( new Dimension((d.width - 400), (updatedTable.getRowHeight() + 1) * (tempUpdatedCount + 1))); Font titleFonts = new Font("Calibri", Font.BOLD, 30); JLabel criticalLabel = new JLabel(" Critical "); criticalLabel.setFont(titleFonts); criticalLabel.setForeground(new Color(230, 27, 27)); JPanel leftPanel = new JPanel(); leftPanel.setLayout(new BorderLayout()); leftPanel.add(criticalLabel, BorderLayout.WEST); leftPanel.add(criticalTableScrollPane, BorderLayout.CENTER); JLabel updatedLabel = new JLabel(" Updated "); updatedLabel.setFont(titleFonts); updatedLabel.setForeground(new Color(47, 196, 6)); JPanel rightPanel = new JPanel(); rightPanel.setLayout(new BorderLayout()); rightPanel.add(updatedLabel, BorderLayout.WEST); rightPanel.add(updatedTableScrollPane, BorderLayout.CENTER); if (tempCriticalCount != 0) thisPanel.add(leftPanel, BorderLayout.NORTH); if (tempUpdatedCount != 0) thisPanel.add(rightPanel, BorderLayout.SOUTH); return thisPanel; }
From source file:fxts.stations.util.preferences.EditAction.java
public void actionPerformed(ActionEvent aEvent) { JButton okButton = UIManager.getInst().createButton(); JButton cancelButton = UIManager.getInst().createButton(); final JDialog dialog = new JDialog(mEditorPanel.getParentDialog()); dialog.setTitle(mEditorPanel.getTitle()); JPanel editPanel = new JPanel(); JPanel buttonPanel = new JPanel(); JPanel mainPanel = new JPanel(); mainPanel.setLayout(UIFrontEnd.getInstance().getSideLayout()); //mainPanel.setLayout(new SideLayout()); //sets button panel buttonPanel.setLayout(UIFrontEnd.getInstance().getSideLayout()); okButton.setText(mResMan.getString("IDS_OK_BUTTON")); //okButton.setPreferredSize(new Dimension(80, 27)); GridBagConstraints sideConstraints = UIFrontEnd.getInstance().getSideConstraints(); sideConstraints.insets = new Insets(10, 10, 10, 10); sideConstraints.gridx = 0;// www. ja v a 2 s . c o m sideConstraints.gridy = 0; ResizeParameterWrapper resizeParameter = UIFrontEnd.getInstance().getResizeParameter(); resizeParameter.init(0.5, 0.0, 0.5, 0.0); resizeParameter.setToConstraints(sideConstraints); buttonPanel.add(okButton, sideConstraints); cancelButton.setText(mResMan.getString("IDS_CANCEL_BUTTON")); //cancelButton.setPreferredSize(new Dimension(80, 27)); sideConstraints = UIFrontEnd.getInstance().getSideConstraints(); sideConstraints.insets = new Insets(10, 10, 10, 10); sideConstraints.gridx = 1; sideConstraints.gridy = 0; resizeParameter = UIFrontEnd.getInstance().getResizeParameter(); resizeParameter.init(0.5, 0.0, 0.5, 0.0); resizeParameter.setToConstraints(sideConstraints); buttonPanel.add(cancelButton, sideConstraints); //adds button panel sideConstraints = UIFrontEnd.getInstance().getSideConstraints(); sideConstraints.insets = new Insets(10, 10, 10, 10); sideConstraints.gridx = 0; sideConstraints.gridy = 1; resizeParameter = UIFrontEnd.getInstance().getResizeParameter(); resizeParameter.init(0.0, 1.0, 1.0, 1.0); resizeParameter.setToConstraints(sideConstraints); mainPanel.add(buttonPanel, sideConstraints); //sets edit panel final IEditor editor = mType.getEditor(); editor.setValue(mValue); editPanel.setLayout(UIFrontEnd.getInstance().getSideLayout()); sideConstraints = UIFrontEnd.getInstance().getSideConstraints(); resizeParameter = UIFrontEnd.getInstance().getResizeParameter(); resizeParameter.init(0.0, 0.0, 1.0, 1.0); resizeParameter.setToConstraints(sideConstraints); Component editComp = editor.getComponent(); //Mar 25 2004 - kav: added for right tab order at Font Chooser at java 1.4. if (editComp instanceof FontChooser) { FontChooser fc = (FontChooser) editComp; fc.setNextFocusedComp(okButton); } editPanel.add(editComp, sideConstraints); //adds editor panel sideConstraints = UIFrontEnd.getInstance().getSideConstraints(); sideConstraints.gridx = 0; sideConstraints.gridy = 0; resizeParameter = UIFrontEnd.getInstance().getResizeParameter(); resizeParameter.init(0.0, 0.0, 1.0, 1.0); resizeParameter.setToConstraints(sideConstraints); mainPanel.add(editPanel, sideConstraints); //adds main panel dialog.getContentPane().setLayout(UIFrontEnd.getInstance().getSideLayout()); //dialog.getContentPane().setLayout(new SideLayout()); sideConstraints = UIFrontEnd.getInstance().getSideConstraints(); sideConstraints.fill = GridBagConstraints.BOTH; resizeParameter = UIFrontEnd.getInstance().getResizeParameter(); resizeParameter.init(0.0, 0.0, 1.0, 1.0); resizeParameter.setToConstraints(sideConstraints); dialog.getContentPane().add(mainPanel, sideConstraints); //adds listeners to buttons okButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent aEvent) { if (editor.getValue().equals(mValue)) { // } else { mValue = editor.getValue(); mEditorPanel.setValue(mValue); mEditorPanel.refreshControls(); mEditorPanel.setValueChanged(true); } dialog.setVisible(false); dialog.dispose(); } }); okButton.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put(KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0), "ExitAction"); okButton.getActionMap().put("ExitAction", new AbstractAction() { /** * Invoked when an action occurs. */ public void actionPerformed(ActionEvent aEvent) { editor.setValue(mValue); dialog.setVisible(false); dialog.dispose(); } }); okButton.requestFocus(); cancelButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent aEvent) { editor.setValue(mValue); dialog.setVisible(false); dialog.dispose(); } }); //dialog.setResizable(false); dialog.setModal(true); dialog.pack(); //sets minimal sizes for components Dimension dim = mainPanel.getSize(); mainPanel.setMinimumSize(dim); mainPanel.setPreferredSize(dim); //sets size of buttons Dimension dimOkButton = okButton.getSize(); Dimension dimCancelButton = cancelButton.getSize(); int nMaxWidth = dimOkButton.getWidth() > dimCancelButton.getWidth() ? (int) dimOkButton.getWidth() : (int) dimCancelButton.getWidth(); okButton.setPreferredSize(new Dimension(nMaxWidth, (int) dimOkButton.getHeight())); okButton.setSize(new Dimension(nMaxWidth, (int) dimOkButton.getHeight())); cancelButton.setPreferredSize(new Dimension(nMaxWidth, (int) dimCancelButton.getHeight())); cancelButton.setSize(new Dimension(nMaxWidth, (int) dimCancelButton.getHeight())); dialog.setLocationRelativeTo(dialog.getOwner()); dialog.setVisible(true); }
From source file:com.floreantpos.config.ui.DatabaseConfigurationView.java
protected void initUI() { setLayout(new BorderLayout()); JPanel contentPanel = new JPanel(); contentPanel.setLayout(new MigLayout("fill", "[][grow,fill]", "[][][][][][][][grow,fill]")); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ tfServerAddress = new POSTextField(); tfServerPort = new POSTextField(); tfDatabaseName = new POSTextField(); tfUserName = new POSTextField(); tfPassword = new POSPasswordField(); databaseCombo = new JComboBox(Database.values()); String databaseProviderName = AppConfig.getDatabaseProviderName(); if (StringUtils.isNotEmpty(databaseProviderName)) { databaseCombo.setSelectedItem(Database.getByProviderName(databaseProviderName)); }/* ww w . jav a2s . com*/ contentPanel.add(new JLabel(Messages.getString("DatabaseConfigurationDialog.8"))); //$NON-NLS-1$ contentPanel.add(databaseCombo, "grow, wrap"); //$NON-NLS-1$ lblServerAddress = new JLabel(Messages.getString("DatabaseConfigurationDialog.10") + ":"); //$NON-NLS-1$ //$NON-NLS-2$ contentPanel.add(lblServerAddress); contentPanel.add(tfServerAddress, "grow, wrap"); //$NON-NLS-1$ lblServerPort = new JLabel(Messages.getString("DatabaseConfigurationDialog.13") + ":"); //$NON-NLS-1$ //$NON-NLS-2$ contentPanel.add(lblServerPort); contentPanel.add(tfServerPort, "grow, wrap"); //$NON-NLS-1$ lblDbName = new JLabel(Messages.getString("DatabaseConfigurationDialog.16") + ":"); //$NON-NLS-1$ //$NON-NLS-2$ contentPanel.add(lblDbName); contentPanel.add(tfDatabaseName, "grow, wrap"); //$NON-NLS-1$ lblUserName = new JLabel(Messages.getString("DatabaseConfigurationDialog.19") + ":"); //$NON-NLS-1$ //$NON-NLS-2$ contentPanel.add(lblUserName); contentPanel.add(tfUserName, "grow, wrap"); //$NON-NLS-1$ lblDbPassword = new JLabel(Messages.getString("DatabaseConfigurationDialog.22") + ":"); //$NON-NLS-1$ //$NON-NLS-2$ contentPanel.add(lblDbPassword); contentPanel.add(tfPassword, "grow, wrap"); //$NON-NLS-1$ contentPanel.add(new JSeparator(), "span, grow, gaptop 10"); //$NON-NLS-1$ btnTestConnection = new JButton(Messages.getString("DatabaseConfigurationDialog.26")); //$NON-NLS-1$ btnTestConnection.setActionCommand(TEST); btnSave = new JButton(Messages.getString("DatabaseConfigurationDialog.27")); //$NON-NLS-1$ btnSave.setActionCommand(SAVE); JPanel buttonPanel = new JPanel(new FlowLayout(FlowLayout.RIGHT)); btnCreateDb = new JButton(Messages.getString("DatabaseConfigurationDialog.29")); //$NON-NLS-1$ btnCreateDb.setActionCommand(CONFIGURE_DB); buttonPanel.add(btnCreateDb); buttonPanel.add(btnTestConnection); buttonPanel.add(btnSave); contentPanel.add(buttonPanel, "span, grow"); //$NON-NLS-1$ JScrollPane scrollPane = new JScrollPane(contentPanel); scrollPane.setBorder(null); add(scrollPane); }