List of usage examples for javax.swing SwingConstants CENTER
int CENTER
To view the source code for javax.swing SwingConstants CENTER.
Click Source Link
From source file:pl.piotrsukiennik.jbrain.gui.NewSimulationPanel.java
/** * This method is called from within the constructor to initialize the form. * WARNING: Do NOT modify this code. The content of this method is always * regenerated by the Form Editor.//from w ww . j av a 2 s .com */ @SuppressWarnings("unchecked") // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents private void initComponents() { titleInput = new javax.swing.JTextField(); timeInput = new javax.swing.JSlider(); routeInput = new javax.swing.JComboBox(); imageHolder = new javax.swing.JPanel(); jLabel5 = new javax.swing.JLabel(); simulateButton = new javax.swing.JButton(); jLabel1 = new javax.swing.JLabel(); jLabel2 = new javax.swing.JLabel(); jLabel3 = new javax.swing.JLabel(); jLabel4 = new javax.swing.JLabel(); setBackground(new java.awt.Color(255, 255, 255)); titleInput.setText("Simulation"); titleInput.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { titleInputActionPerformed(evt); } }); timeInput.setBackground(new java.awt.Color(255, 255, 255)); timeInput.setMaximum(10000); timeInput.setMinimum(100); timeInput.setValue(1000); timeInput.addChangeListener(new javax.swing.event.ChangeListener() { public void stateChanged(javax.swing.event.ChangeEvent evt) { timeInputStateChanged(evt); } }); routeInput.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { routeInputActionPerformed(evt); } }); imageHolder.setBorder(javax.swing.BorderFactory.createBevelBorder(javax.swing.border.BevelBorder.RAISED)); imageHolder.addMouseListener(new java.awt.event.MouseAdapter() { public void mouseClicked(java.awt.event.MouseEvent evt) { imageHolderMouseClicked(evt); } }); jLabel5.setHorizontalAlignment(javax.swing.SwingConstants.CENTER); jLabel5.setText("No input image selected"); javax.swing.GroupLayout imageHolderLayout = new javax.swing.GroupLayout(imageHolder); imageHolder.setLayout(imageHolderLayout); imageHolderLayout.setHorizontalGroup( imageHolderLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING).addGroup( javax.swing.GroupLayout.Alignment.TRAILING, imageHolderLayout.createSequentialGroup().addContainerGap() .addComponent(jLabel5, javax.swing.GroupLayout.DEFAULT_SIZE, 356, Short.MAX_VALUE) .addContainerGap())); imageHolderLayout .setVerticalGroup(imageHolderLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(imageHolderLayout.createSequentialGroup().addContainerGap() .addComponent(jLabel5, javax.swing.GroupLayout.DEFAULT_SIZE, 119, Short.MAX_VALUE) .addContainerGap())); simulateButton.setText("Simulate!"); simulateButton.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { simulateButtonActionPerformed(evt); } }); jLabel1.setText("Simulation title:"); jLabel2.setText("Simulation time (msec):"); jLabel3.setText("Brain route:"); jLabel4.setHorizontalAlignment(javax.swing.SwingConstants.CENTER); jLabel4.setText("Input image:"); javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this); this.setLayout(layout); layout.setHorizontalGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(layout.createSequentialGroup().addContainerGap().addGroup(layout .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addComponent(imageHolder, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addComponent(simulateButton, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout .createSequentialGroup() .addGroup(layout .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addComponent(jLabel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addComponent( jLabel2, javax.swing.GroupLayout.DEFAULT_SIZE, 177, Short.MAX_VALUE) .addComponent(jLabel3, javax.swing.GroupLayout.DEFAULT_SIZE, 177, Short.MAX_VALUE)) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addGroup(layout .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false) .addComponent(titleInput, javax.swing.GroupLayout.Alignment.TRAILING) .addComponent(routeInput, javax.swing.GroupLayout.Alignment.TRAILING, 0, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addComponent(timeInput, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, 199, Short.MAX_VALUE))) .addComponent(jLabel4, javax.swing.GroupLayout.DEFAULT_SIZE, 380, Short.MAX_VALUE)) .addContainerGap())); layout.setVerticalGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING).addGroup( javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup().addContainerGap().addGroup(layout .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false) .addComponent(titleInput, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addGroup(layout.createSequentialGroup().addGap(3, 3, 3).addComponent(jLabel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addComponent(timeInput, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(jLabel2, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(routeInput, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(jLabel3, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(jLabel4, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(imageHolder, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(simulateButton).addContainerGap())); }
From source file:ca.inverse.sogo.admin.SOGoSyncSourceConfigPanel.java
/** * //from w ww. jav a2 s . co m */ private void init() { this.setLayout(null); titledBorder1 = new TitledBorder(""); panelName.setFont(titlePanelFont); panelName.setText("Edit SOGo SyncSource"); panelName.setBounds(new Rectangle(14, 5, 316, 28)); panelName.setAlignmentX(SwingConstants.CENTER); panelName.setBorder(titledBorder1); int y = 60; int dy = 30; sourceURILabel.setText("Source URI: "); sourceURILabel.setFont(defaultFont); sourceURILabel.setBounds(new Rectangle(14, y, 150, 18)); sourceURIValue.setFont(defaultFont); sourceURIValue.setBounds(new Rectangle(170, y, 350, 18)); y += dy; nameLabel.setText("Name: "); nameLabel.setFont(defaultFont); nameLabel.setBounds(new Rectangle(14, y, 150, 18)); nameValue.setFont(defaultFont); nameValue.setBounds(new Rectangle(170, y, 350, 18)); y += dy; typeLabel.setText("Supported type: "); typeLabel.setFont(defaultFont); typeLabel.setBounds(new Rectangle(14, y, 150, 18)); typeValue.setFont(defaultFont); typeValue.setBounds(new Rectangle(170, y, 150, 18)); y += dy; dbURLLabel.setText("Database URL: "); dbURLLabel.setFont(defaultFont); dbURLLabel.setBounds(new Rectangle(14, y, 150, 18)); dbURLValue.setFont(defaultFont); dbURLValue.setBounds(new Rectangle(170, y, 350, 18)); y += dy; dbUsernameLabel.setText("Database username:"); dbUsernameLabel.setFont(defaultFont); dbUsernameLabel.setBounds(new Rectangle(14, y, 150, 18)); dbUsernameValue.setFont(defaultFont); dbUsernameValue.setBounds(new Rectangle(170, y, 150, 18)); y += dy; dbPasswordLabel.setText("Database password:"); dbPasswordLabel.setFont(defaultFont); dbPasswordLabel.setBounds(new Rectangle(14, y, 150, 18)); dbPasswordValue.setFont(defaultFont); dbPasswordValue.setBounds(new Rectangle(170, y, 150, 18)); y += dy; button.setFont(defaultFont); button.setText("Add"); button.setBounds(170, y, 70, 25); button.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent event) { try { validateValues(); getValues(); if (getState() == STATE_INSERT) { SOGoSyncSourceConfigPanel.this.actionPerformed(new ActionEvent( SOGoSyncSourceConfigPanel.this, ACTION_EVENT_INSERT, event.getActionCommand())); } else { SOGoSyncSourceConfigPanel.this.actionPerformed(new ActionEvent( SOGoSyncSourceConfigPanel.this, ACTION_EVENT_UPDATE, event.getActionCommand())); } } catch (Exception e) { notifyError(new AdminException(e.getMessage())); } } }); this.add(panelName, null); this.add(nameLabel, null); this.add(nameValue, null); this.add(typeLabel, null); this.add(typeValue, null); this.add(sourceURILabel, null); this.add(sourceURIValue, null); this.add(dbURLLabel); this.add(dbURLValue); this.add(dbUsernameLabel); this.add(dbUsernameValue); this.add(dbPasswordLabel); this.add(dbPasswordValue); this.add(button, null); }
From source file:HtmlDemo.java
public HtmlDemo() { setLayout(new BoxLayout(this, BoxLayout.LINE_AXIS)); String initialText = "<html>\n" + "Color and font test:\n" + "<ul>\n" + "<li><font color=red>red</font>\n" + "<li><font color=blue>blue</font>\n" + "<li><font color=green>green</font>\n" + "<li><font size=-2>small</font>\n" + "<li><font size=+2>large</font>\n" + "<li><i>italic</i>\n" + "<li><b>bold</b>\n" + "</ul>\n"; htmlTextArea = new JTextArea(10, 20); htmlTextArea.setText(initialText);/*w w w .j a va 2 s . c o m*/ JScrollPane scrollPane = new JScrollPane(htmlTextArea); JButton changeTheLabel = new JButton("Change the label"); changeTheLabel.setMnemonic(KeyEvent.VK_C); changeTheLabel.setAlignmentX(Component.CENTER_ALIGNMENT); changeTheLabel.addActionListener(this); theLabel = new JLabel(initialText) { public Dimension getPreferredSize() { return new Dimension(200, 200); } public Dimension getMinimumSize() { return new Dimension(200, 200); } public Dimension getMaximumSize() { return new Dimension(200, 200); } }; theLabel.setVerticalAlignment(SwingConstants.CENTER); theLabel.setHorizontalAlignment(SwingConstants.CENTER); JPanel leftPanel = new JPanel(); leftPanel.setLayout(new BoxLayout(leftPanel, BoxLayout.PAGE_AXIS)); leftPanel.setBorder(BorderFactory.createCompoundBorder( BorderFactory.createTitledBorder("Edit the HTML, then click the button"), BorderFactory.createEmptyBorder(10, 10, 10, 10))); leftPanel.add(scrollPane); leftPanel.add(Box.createRigidArea(new Dimension(0, 10))); leftPanel.add(changeTheLabel); JPanel rightPanel = new JPanel(); rightPanel.setLayout(new BoxLayout(rightPanel, BoxLayout.PAGE_AXIS)); rightPanel .setBorder(BorderFactory.createCompoundBorder(BorderFactory.createTitledBorder("A label with HTML"), BorderFactory.createEmptyBorder(10, 10, 10, 10))); rightPanel.add(theLabel); setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10)); add(leftPanel); add(Box.createRigidArea(new Dimension(10, 0))); add(rightPanel); }
From source file:edu.ku.brc.specify.config.init.InstSetupPanel.java
@Override protected void init(final String title, final String[] fields, final boolean[] required, final String[] types, final Integer[] numColumns) { super.init(title, fields, required, types, numColumns); label = UIHelper.createLabel("", SwingConstants.CENTER); testBtn = UIHelper.createI18NButton("CREATEINST_BTN"); PanelBuilder tstPB = new PanelBuilder(new FormLayout("f:p:g,p,f:p:g", "p")); tstPB.add(testBtn, cc.xy(2, 1));//from ww w . jav a 2 s.c o m PanelBuilder panelPB = new PanelBuilder(new FormLayout("f:p:g", "20px,p,2px,p,2px,p:g,f:p:g")); panelPB.add(tstPB.getPanel(), cc.xy(1, 2)); panelPB.add(getProgressBar(), cc.xy(1, 4)); panelPB.add(label, cc.xy(1, 6)); builder.add(panelPB.getPanel(), cc.xyw(3, row, 2)); row += 2; testBtn.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { doCreate(); } }); progressBar.setVisible(false); }
From source file:MenuItemChooser.java
private void initGUI() { JPanel itemDetailsPanel = new JPanel(); itemDetailsPanel.setLayout(new GridLayout(4, 2)); itemDetailsPanel.setBackground(Color.WHITE); JLabel lbl = new JLabel("Item: "); itemDetailsPanel.add(lbl);/*from www .java2 s .com*/ itemName = new JLabel(""); itemDetailsPanel.add(itemName); lbl = new JLabel("Type: "); itemDetailsPanel.add(lbl); itemType = new JLabel(""); itemDetailsPanel.add(itemType); lbl = new JLabel("Price: $ "); itemDetailsPanel.add(lbl); price = new JLabel(""); itemDetailsPanel.add(price); lbl = new JLabel("Quantity: "); itemDetailsPanel.add(lbl); qty = new JTextField("0", 1); qty.addActionListener(this); qty.addFocusListener(this); itemDetailsPanel.add(qty); JPanel imgDescPanel = new JPanel(new BorderLayout()); imgDescPanel.setBackground(Color.WHITE); image = new JLabel(""); image.setHorizontalAlignment(SwingConstants.CENTER); image.setVerticalAlignment(SwingConstants.CENTER); imgDescPanel.add(image, BorderLayout.NORTH); desc = new JLabel("desc"); imgDescPanel.add(desc, BorderLayout.SOUTH); JPanel buttonPanel = new JPanel(); buttonPanel.setBackground(Color.WHITE); next = new JButton("Next"); next.addActionListener(this); buttonPanel.add(next); prev = new JButton("Previous"); prev.addActionListener(this); buttonPanel.add(prev); order = new JButton("Order"); order.addActionListener(this); buttonPanel.add(order); cancel = new JButton("Cancel / New"); cancel.addActionListener(this); buttonPanel.add(cancel); close = new JButton("Close"); close.addActionListener(this); close.setEnabled(false); buttonPanel.add(close); totalLbl = new JLabel(""); totalLbl.setFont(new Font("Serif", Font.BOLD, 14)); totalLbl.setForeground((Color.GREEN).darker()); buttonPanel.add(totalLbl); BorderLayout bl = new BorderLayout(); bl.setHgap(30); bl.setVgap(20); setLayout(bl); setBackground(Color.WHITE); add(itemDetailsPanel, BorderLayout.WEST); add(imgDescPanel, BorderLayout.EAST); add(buttonPanel, BorderLayout.SOUTH); TitledBorder title = BorderFactory.createTitledBorder("Choose Menu Items And Place Order"); setBorder(title); loadMenuItem(); }
From source file:edu.ku.brc.specify.tasks.subpane.wb.SGRResultsForForm.java
private void showMessage(String key) { UIRegistry.loadAndPushResourceBundle("specify_plugins"); String msg = UIRegistry.getResourceString(key); UIRegistry.popResourceBundle();//w ww . ja v a 2 s .co m setLayout(new BorderLayout()); JLabel label = createLabel(msg, SwingConstants.CENTER); add(label, BorderLayout.CENTER); getParent().validate(); }
From source file:com.funambol.json.admin.JsonConnectorConfigPanel.java
/** * Create the panel/* w w w . j av a 2s. co m*/ */ private void init() { JLabel title, serverLabel; JPanel seccPanel; JPanel behaviourOnErrorsPanel; title = new JLabel(); seccPanel = new JPanel(); behaviourOnErrorsPanel = new JPanel(); serverLabel = new JLabel(); serverValue = new JTextField(); setLayout(null); title.setFont(titlePanelFont); title.setText("Funambol Json Connector"); title.setBounds(new Rectangle(14, 5, 316, 28)); title.setAlignmentX(SwingConstants.CENTER); title.setBorder(new TitledBorder("")); seccPanel.setLayout(null); seccPanel.setBorder(new TitledBorder("HTTP Server Configuration")); serverLabel.setText("Server:"); seccPanel.add(serverLabel); serverLabel.setBounds(10, 20, 116, 15); seccPanel.add(serverValue); serverValue.setBounds(150, 20, 220, 19); serverValue.setFont(defaultFont); add(seccPanel); seccPanel.setBounds(10, 50, 380, 70); //the ssl option panel behaviourOnErrorsPanel.setBorder(new TitledBorder("Behaviour on errors")); behaviourOnErrorsPanel.setLayout(null); stopSyncOnFatalError.setText("Stop sync on fatal errors"); stopSyncOnFatalError.setBounds(10, 25, 200, 15); behaviourOnErrorsPanel.add(stopSyncOnFatalError); add(behaviourOnErrorsPanel); behaviourOnErrorsPanel.setBounds(10, 130, 380, 60); confirmButton.setFont(defaultFont); confirmButton.setText("Save"); add(confirmButton); confirmButton.setBounds(160, 200, 70, 25); confirmButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent event) { try { validateValues(); getValues(); JsonConnectorConfigPanel.this.actionPerformed(new ActionEvent(JsonConnectorConfigPanel.this, ACTION_EVENT_UPDATE, event.getActionCommand())); } catch (Exception e) { notifyError(new AdminException(e.getMessage())); } } }); // // Setting font... // Component[] components = getComponents(); for (int i = 0; (components != null) && (i < components.length); ++i) { components[i].setFont(defaultFont); } // // We add it as the last one so that the font won't be changed // add(title); }
From source file:com.igormaznitsa.sciareto.ui.editors.PictureViewer.java
@Override public void loadContent(@Nullable final File file) throws IOException { BufferedImage loaded = null;/*from ww w . ja va2 s .c o m*/ if (file != null) { try { loaded = ImageIO.read(file); } catch (Exception ex) { LOGGER.error("Can't load image", ex); loaded = null; } } this.image = loaded; this.label.setHorizontalTextPosition(JLabel.CENTER); this.label.setVerticalTextPosition(JLabel.CENTER); this.label.setHorizontalAlignment(SwingConstants.CENTER); this.label.setVerticalAlignment(SwingConstants.CENTER); if (this.image == null) { this.label.setIcon(null); this.label.setText("Can't load image"); } else { this.label.setIcon(new ImageIcon(this.image)); this.label.setText(""); } this.setViewportView(this.label); this.revalidate(); }
From source file:dk.dma.epd.common.prototype.gui.voct.VOCTAdditionalInfoPanel.java
/** * Constructor// www.java 2s.com * * @param compactLayout * if false, there will be message type selectors in the panel */ public VOCTAdditionalInfoPanel(boolean compactLayout) { super(new BorderLayout()); EPD.getInstance().getVoctHandler().addVoctSarInfoListener(this); // Prepare the title header titleHeader.setBackground(getBackground().darker()); titleHeader.setOpaque(true); titleHeader.setBorder(BorderFactory.createEmptyBorder(2, 2, 2, 2)); titleHeader.setHorizontalAlignment(SwingConstants.CENTER); add(titleHeader, BorderLayout.NORTH); // Add messages panel scrollPane.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER); scrollPane.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS); messagesPanel.setBackground(UIManager.getColor("List.background")); messagesPanel.setOpaque(false); messagesPanel.setLayout(new GridBagLayout()); messagesPanel.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5)); add(scrollPane, BorderLayout.CENTER); JPanel sendPanel = new JPanel(new GridBagLayout()); add(sendPanel, BorderLayout.SOUTH); Insets insets = new Insets(2, 2, 2, 2); // Add text area // if (false) { // messageText = new JTextField(); // ((JTextField) messageText).addActionListener(this); // sendPanel.add(messageText, new GridBagConstraints(0, 0, 1, 1, 1.0, 1.0, NORTH, BOTH, insets, 0, 0)); // // } else { messageText = new JTextArea(); JScrollPane scrollPane2 = new JScrollPane(messageText); scrollPane2.setPreferredSize(new Dimension(100, 50)); scrollPane2.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER); scrollPane2.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED); sendPanel.add(scrollPane2, new GridBagConstraints(0, 0, 1, 2, 1.0, 1.0, NORTH, BOTH, insets, 0, 0)); // } // Add buttons // ButtonGroup group = new ButtonGroup(); if (!compactLayout) { JToolBar msgTypePanel = new JToolBar(); msgTypePanel.setBorderPainted(false); msgTypePanel.setOpaque(true); msgTypePanel.setFloatable(false); sendPanel.add(msgTypePanel, new GridBagConstraints(1, 0, 1, 1, 0.0, 0.0, NORTH, NONE, insets, 0, 0)); } if (compactLayout) { addBtn = new JButton("Add to Log"); sendPanel.add(addBtn, new GridBagConstraints(1, 0, 1, 1, 0.0, 0.0, NORTH, NONE, insets, 0, 0)); } // addBtn.setEnabled(false); // messageText.setEditable(false); addBtn.addActionListener(this); }
From source file:com.googlecode.commons.swing.component.datetime.MiniDateCalendar.java
private void init() { final DateFormatSymbols dfs = new DateFormatSymbols(locale); CollectionUtils.addAll(this.weekdays, dfs.getShortWeekdays()); for (int i = 0; i < 7; i++) { orderedWeekdays.add(((i + weekDayStart - 1) % 7) + 1); }/*from w ww . j a v a2s . com*/ setLayout(new BorderLayout()); SizeUtils.setAllWidths(this, 150); SizeUtils.setAllHeights(this, 180); panNorth = new JPanel(new BorderLayout()); add(panNorth, BorderLayout.NORTH); btnPrev = new JButton(); SizeUtils.setAllWidths(btnPrev, 18); SizeUtils.setAllHeights(btnPrev, 18); btnPrev.setIcon(DefaultIcons.resultset_previous()); btnPrev.setMargin(new Insets(0, 0, 0, 0)); btnPrev.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { onClickPrev(); } }); panNorth.add(btnPrev, BorderLayout.WEST); lblMonth = new JLabel(); SizeUtils.setMinHeight(lblMonth, 0); SizeUtils.setPreferredHeight(lblMonth, 0); lblMonth.setHorizontalAlignment(SwingConstants.CENTER); panNorth.add(lblMonth, BorderLayout.CENTER); btnNext = new JButton(); btnNext.setIcon(DefaultIcons.resultset_next()); SizeUtils.setAllWidths(btnNext, 18); SizeUtils.setAllHeights(btnNext, 18); btnNext.setMargin(new Insets(0, 0, 0, 0)); btnNext.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { onClickNext(); } }); panNorth.add(btnNext, BorderLayout.EAST); panCenter = new JPanel(); panCenter.setLayout(new GridLayout(7, 7)); add(panCenter, BorderLayout.CENTER); for (int col = 0; col < 7; col++) { JLabel lblDay = new JLabel(weekdays.get(orderedWeekdays.get(col))); lblDay.setHorizontalAlignment(SwingConstants.CENTER); panCenter.add(lblDay); } ButtonGroup grp = new ButtonGroup(); for (int row = 0; row < 6; row++) { for (int col = 0; col < 7; col++) { final int day = orderedWeekdays.get(col); final DayButton btn = createDayButton(day, weekdays.get(day)); btn.setMargin(new Insets(0, 0, 0, 0)); btn.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { onClickDay(btn.value); } }); days.add(btn); grp.add(btn); panCenter.add(btn); } } refresh(); }