javax.swing.JLabel#CENTER源码实例Demo

下面列出了javax.swing.JLabel#CENTER 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: joshua   文件: StartupWindow.java
public StartupWindow(String title, String author, String year, Image image, Color borderColor,
    int borderWidth) {
  JPanel content = (JPanel) getContentPane();
  content.setBackground(Color.WHITE);

  int width = 250;
  int height = 100;

  Point center = GraphicsEnvironment.getLocalGraphicsEnvironment().getCenterPoint();
  setBounds(center.x - width / 2, center.y - height / 2, width, height);

  JLabel titleLabel = new JLabel(title, JLabel.CENTER);
  titleLabel.setFont(new Font("Sans-Serif", Font.BOLD, 24));
  content.add(titleLabel, BorderLayout.NORTH);

  JLabel copyright = new JLabel("\u24D2 " + year + " - " + author, JLabel.CENTER);
  copyright.setFont(new Font("Sans-Serif", Font.PLAIN, 8));
  content.add(copyright, BorderLayout.SOUTH);

  if (image != null) {
    content.add(new JLabel(new ImageIcon(image)));
  }

  content.setBorder(BorderFactory.createLineBorder(borderColor, borderWidth));

  // Display it
  setVisible(true);
}
 
源代码2 项目: jdk8u_jdk   文件: FileChooserDemo.java
@SuppressWarnings("LeakingThisInConstructor")
WizardDialog(JFrame frame, boolean modal) {
    super(frame, "Embedded JFileChooser Demo", modal);

    cardLayout = new CardLayout();
    cardPanel = new JPanel(cardLayout);
    getContentPane().add(cardPanel, BorderLayout.CENTER);

    messageLabel = new JLabel("", JLabel.CENTER);
    cardPanel.add(chooser, "fileChooser");
    cardPanel.add(messageLabel, "label");
    cardLayout.show(cardPanel, "fileChooser");
    chooser.addActionListener(this);

    JPanel buttonPanel = new JPanel();
    backButton = new JButton("< Back");
    nextButton = new JButton("Next >");
    closeButton = new JButton("Close");

    buttonPanel.add(backButton);
    buttonPanel.add(nextButton);
    buttonPanel.add(closeButton);

    getContentPane().add(buttonPanel, BorderLayout.SOUTH);

    backButton.setEnabled(false);
    getRootPane().setDefaultButton(nextButton);

    backButton.addActionListener(this);
    nextButton.addActionListener(this);
    closeButton.addActionListener(this);

    pack();
    setLocationRelativeTo(frame);
}
 
源代码3 项目: hottub   文件: FileChooserDemo.java
@SuppressWarnings("LeakingThisInConstructor")
WizardDialog(JFrame frame, boolean modal) {
    super(frame, "Embedded JFileChooser Demo", modal);

    cardLayout = new CardLayout();
    cardPanel = new JPanel(cardLayout);
    getContentPane().add(cardPanel, BorderLayout.CENTER);

    messageLabel = new JLabel("", JLabel.CENTER);
    cardPanel.add(chooser, "fileChooser");
    cardPanel.add(messageLabel, "label");
    cardLayout.show(cardPanel, "fileChooser");
    chooser.addActionListener(this);

    JPanel buttonPanel = new JPanel();
    backButton = new JButton("< Back");
    nextButton = new JButton("Next >");
    closeButton = new JButton("Close");

    buttonPanel.add(backButton);
    buttonPanel.add(nextButton);
    buttonPanel.add(closeButton);

    getContentPane().add(buttonPanel, BorderLayout.SOUTH);

    backButton.setEnabled(false);
    getRootPane().setDefaultButton(nextButton);

    backButton.addActionListener(this);
    nextButton.addActionListener(this);
    closeButton.addActionListener(this);

    pack();
    setLocationRelativeTo(frame);
}
 
源代码4 项目: Robot-Overlord-App   文件: SpideeControlPanel.java
private CollapsiblePanel createSpeedPanel() {
	CollapsiblePanel speedPanel = new CollapsiblePanel("Speed");
	GridBagConstraints con2 = PanelHelper.getDefaultGridBagConstraints();
	con2.weighty=1;
	con2.weightx=0.25;

	double speed=robot.speed_scale;
	int speedIndex;
	for(speedIndex=0;speedIndex<speedOptions.length;++speedIndex) {
		if( speedOptions[speedIndex] >= speed )
			break;
	}
	
	speedNow = new JLabel(Double.toString(speedOptions[speedIndex]),JLabel.CENTER);
	java.awt.Dimension dim = speedNow.getPreferredSize();
	dim.width = 50;
	speedNow.setPreferredSize(dim);
	speedPanel.getContentPane().add(speedNow,con2);

	speedControl = new JSlider(0,speedOptions.length-1,speedIndex);
	speedControl.addChangeListener(this);
	speedControl.setMajorTickSpacing(speedOptions.length-1);
	speedControl.setMinorTickSpacing(1);
	speedControl.setPaintTicks(true);
	con2.anchor=GridBagConstraints.NORTHEAST;
	con2.fill=GridBagConstraints.HORIZONTAL;
	con2.weightx=0.75;
	con2.gridx=1;
	speedPanel.getContentPane().add(speedControl,con2);

	return speedPanel;
}
 
源代码5 项目: TencentKona-8   文件: FileChooserDemo.java
@SuppressWarnings("LeakingThisInConstructor")
WizardDialog(JFrame frame, boolean modal) {
    super(frame, "Embedded JFileChooser Demo", modal);

    cardLayout = new CardLayout();
    cardPanel = new JPanel(cardLayout);
    getContentPane().add(cardPanel, BorderLayout.CENTER);

    messageLabel = new JLabel("", JLabel.CENTER);
    cardPanel.add(chooser, "fileChooser");
    cardPanel.add(messageLabel, "label");
    cardLayout.show(cardPanel, "fileChooser");
    chooser.addActionListener(this);

    JPanel buttonPanel = new JPanel();
    backButton = new JButton("< Back");
    nextButton = new JButton("Next >");
    closeButton = new JButton("Close");

    buttonPanel.add(backButton);
    buttonPanel.add(nextButton);
    buttonPanel.add(closeButton);

    getContentPane().add(buttonPanel, BorderLayout.SOUTH);

    backButton.setEnabled(false);
    getRootPane().setDefaultButton(nextButton);

    backButton.addActionListener(this);
    nextButton.addActionListener(this);
    closeButton.addActionListener(this);

    pack();
    setLocationRelativeTo(frame);
}
 
源代码6 项目: egdownloader   文件: TaskTableHeaderRenderer.java
public Component getTableCellRendererComponent(JTable table, Object value,
		boolean isSelected, boolean hasFocus, int row, int column) {
		JLabel l = null;
		TaskingTable t = (TaskingTable)table;
	switch (column){
		case 0://类别
			l = new AJLabel(t.getTasks().size() + "", "", color, JLabel.CENTER);
			l.setFont(FontConst.Georgia_BOLD_12);
			l.setToolTipText("漫画总数(按照阅读状态排序)");
			return l;
		case 1://名称
			l = new AJLabel(value.toString() + "", "", color, JLabel.LEFT);
			l.setToolTipText("切换排序(名称/创建时间)");
			return l;
		case 2://图片数
			l = new AJLabel(value.toString(), "", color, JLabel.LEFT);
			l.setToolTipText("按照漫画总数降序排序");
			return l;
		case 3://语言
			l =  new AJLabel(value.toString(), "", color, JLabel.LEFT);
			l.setToolTipText("按照漫画语言排序");
			return l;
		case 4://下载进度
			l =  new AJLabel(value.toString(), "", color, JLabel.CENTER);
			l.setToolTipText("按照漫画进度降序排序");
			return l;
		case 5://状态
			l = new AJLabel(value.toString(), "", color, JLabel.CENTER);
			l.setToolTipText("按照漫画下载状态排序");
			return l;
		default:
			return new AJLabel(value.toString(), color);
	}
}
 
源代码7 项目: openjdk-jdk8u   文件: FileChooserDemo.java
@SuppressWarnings("LeakingThisInConstructor")
WizardDialog(JFrame frame, boolean modal) {
    super(frame, "Embedded JFileChooser Demo", modal);

    cardLayout = new CardLayout();
    cardPanel = new JPanel(cardLayout);
    getContentPane().add(cardPanel, BorderLayout.CENTER);

    messageLabel = new JLabel("", JLabel.CENTER);
    cardPanel.add(chooser, "fileChooser");
    cardPanel.add(messageLabel, "label");
    cardLayout.show(cardPanel, "fileChooser");
    chooser.addActionListener(this);

    JPanel buttonPanel = new JPanel();
    backButton = new JButton("< Back");
    nextButton = new JButton("Next >");
    closeButton = new JButton("Close");

    buttonPanel.add(backButton);
    buttonPanel.add(nextButton);
    buttonPanel.add(closeButton);

    getContentPane().add(buttonPanel, BorderLayout.SOUTH);

    backButton.setEnabled(false);
    getRootPane().setDefaultButton(nextButton);

    backButton.addActionListener(this);
    nextButton.addActionListener(this);
    closeButton.addActionListener(this);

    pack();
    setLocationRelativeTo(frame);
}
 
源代码8 项目: jaamsim   文件: GUIFrame.java
private void addSimulationTime(JToolBar mainToolBar, Insets margin) {
	clockDisplay = new JLabel( "", JLabel.CENTER );
	clockDisplay.setPreferredSize( new Dimension( 110, 16 ) );
	clockDisplay.setForeground( new Color( 1.0f, 0.0f, 0.0f ) );
	clockDisplay.setToolTipText(formatToolTip("Simulation Time",
			"The present simulation time"));
	mainToolBar.add( clockDisplay );
}
 
源代码9 项目: swift-explorer   文件: LoginPanel.java
private void initMenuActions () 
{
    okAction = new ReflectionAction<LoginPanel>(getLocalizedString("Ok"), MainPanel.getIcon("server_connect.png"), this, "onOk");
    saveAction = new ReflectionAction<LoginPanel>("", MainPanel.getIcon("table_save.png"), this, "onSave");
    deleteAction = new ReflectionAction<LoginPanel>("", MainPanel.getIcon("table_delete.png"), this, "onDelete");
    cancelAction = new ReflectionAction<LoginPanel>(getLocalizedString("Cancel"), this, "onCancel");
    
    okButton = new JButton(okAction);
    cancelButton = new JButton(cancelAction);
    saveButton = new JButton(saveAction);
    deleteButton = new JButton(deleteAction);
    
    warningLabel = new JLabel(getLocalizedString("warning_credentials_stored_plain_text"), MainPanel.getIcon("table_error.png"), JLabel.CENTER);
}
 
源代码10 项目: SimpleERP   文件: Chooser.java
public DayLabel(Calendar cal){
    super(""+cal.get(Calendar.DAY_OF_MONTH), JLabel.CENTER);
    this.year = cal.get(Calendar.YEAR);
    this.month = cal.get(Calendar.MONTH);
    this.day = cal.get(Calendar.DAY_OF_MONTH);
    
    this.setFont(font);
    this.addMouseListener(this);
    this.addMouseMotionListener(this);
    if(month == calendar.get(Calendar.MONTH)) this.setForeground(java.awt.Color.BLACK);
    else this.setForeground(java.awt.Color.LIGHT_GRAY);
    
}
 
源代码11 项目: openjdk-jdk9   文件: FileChooserDemo.java
@SuppressWarnings("LeakingThisInConstructor")
WizardDialog(JFrame frame, boolean modal) {
    super(frame, "Embedded JFileChooser Demo", modal);

    cardLayout = new CardLayout();
    cardPanel = new JPanel(cardLayout);
    getContentPane().add(cardPanel, BorderLayout.CENTER);

    messageLabel = new JLabel("", JLabel.CENTER);
    cardPanel.add(chooser, "fileChooser");
    cardPanel.add(messageLabel, "label");
    cardLayout.show(cardPanel, "fileChooser");
    chooser.addActionListener(this);

    JPanel buttonPanel = new JPanel();
    backButton = new JButton("< Back");
    nextButton = new JButton("Next >");
    closeButton = new JButton("Close");

    buttonPanel.add(backButton);
    buttonPanel.add(nextButton);
    buttonPanel.add(closeButton);

    getContentPane().add(buttonPanel, BorderLayout.SOUTH);

    backButton.setEnabled(false);
    getRootPane().setDefaultButton(nextButton);

    backButton.addActionListener(this);
    nextButton.addActionListener(this);
    closeButton.addActionListener(this);

    pack();
    setLocationRelativeTo(frame);
}
 
源代码12 项目: jdk8u-jdk   文件: FileChooserDemo.java
@SuppressWarnings("LeakingThisInConstructor")
WizardDialog(JFrame frame, boolean modal) {
    super(frame, "Embedded JFileChooser Demo", modal);

    cardLayout = new CardLayout();
    cardPanel = new JPanel(cardLayout);
    getContentPane().add(cardPanel, BorderLayout.CENTER);

    messageLabel = new JLabel("", JLabel.CENTER);
    cardPanel.add(chooser, "fileChooser");
    cardPanel.add(messageLabel, "label");
    cardLayout.show(cardPanel, "fileChooser");
    chooser.addActionListener(this);

    JPanel buttonPanel = new JPanel();
    backButton = new JButton("< Back");
    nextButton = new JButton("Next >");
    closeButton = new JButton("Close");

    buttonPanel.add(backButton);
    buttonPanel.add(nextButton);
    buttonPanel.add(closeButton);

    getContentPane().add(buttonPanel, BorderLayout.SOUTH);

    backButton.setEnabled(false);
    getRootPane().setDefaultButton(nextButton);

    backButton.addActionListener(this);
    nextButton.addActionListener(this);
    closeButton.addActionListener(this);

    pack();
    setLocationRelativeTo(frame);
}
 
源代码13 项目: visualvm   文件: Utils.java
PlaceholderPanel(String className) {
    super(null);
    
    putClientProperty("className", className);
    
    setOpaque(true);
    setBorder(BorderFactory.createLineBorder(LINE));
    
    label = new JLabel(BrowserUtils.getSimpleType(className), JLabel.CENTER);
    label.setOpaque(true);
}
 
源代码14 项目: jdk8u-jdk   文件: FileChooserDemo.java
@SuppressWarnings("LeakingThisInConstructor")
WizardDialog(JFrame frame, boolean modal) {
    super(frame, "Embedded JFileChooser Demo", modal);

    cardLayout = new CardLayout();
    cardPanel = new JPanel(cardLayout);
    getContentPane().add(cardPanel, BorderLayout.CENTER);

    messageLabel = new JLabel("", JLabel.CENTER);
    cardPanel.add(chooser, "fileChooser");
    cardPanel.add(messageLabel, "label");
    cardLayout.show(cardPanel, "fileChooser");
    chooser.addActionListener(this);

    JPanel buttonPanel = new JPanel();
    backButton = new JButton("< Back");
    nextButton = new JButton("Next >");
    closeButton = new JButton("Close");

    buttonPanel.add(backButton);
    buttonPanel.add(nextButton);
    buttonPanel.add(closeButton);

    getContentPane().add(buttonPanel, BorderLayout.SOUTH);

    backButton.setEnabled(false);
    getRootPane().setDefaultButton(nextButton);

    backButton.addActionListener(this);
    nextButton.addActionListener(this);
    closeButton.addActionListener(this);

    pack();
    setLocationRelativeTo(frame);
}
 
源代码15 项目: mpcmaid   文件: MainFrame.java
public void makeAboutDialog() {
	// set up a simple about box
	aboutBox = new JDialog(this, "About MPCMaid");
	aboutBox.setSize(400, 422);
	aboutBox.setResizable(false);
	aboutBox.getContentPane().setLayout(new BorderLayout());

	try {
		final JLabel imageLabel = new JLabel();
		final BufferedImage currentImage = ImageIO.read(getClass().getResourceAsStream("mpcmaidlogo400_400.png"));
		imageLabel.setHorizontalAlignment(SwingConstants.CENTER);
		imageLabel.setVerticalAlignment(SwingConstants.CENTER);
		imageLabel.setOpaque(true);

		imageLabel.setIcon(new ImageIcon(currentImage));
		// imageLabel.setBackground((Color)
		// colors[colorComboBox.getSelectedIndex()]);
		imageLabel.setText("");

		aboutBox.getContentPane().add(imageLabel, BorderLayout.NORTH);
	} catch (IOException e) {
		e.printStackTrace();
	}

	// aboutBox.getContentPane().add(new JLabel("MPCMaid", JLabel.CENTER));
	final JLabel notice = new JLabel("\u00A92009 Cyrille Martraire (cyrille.martraire.com)", JLabel.CENTER);
	// notice.setPreferredSize(new Dimension(400, 25));
	// aboutBox.getContentPane().add(notice, BorderLayout.CENTER);

	// final JLabel notice2 = new JLabel("Logo design: Yunshan Xia",
	// JLabel.CENTER);
	// notice.setPreferredSize(new Dimension(400, 25));
	// aboutBox.getContentPane().add(notice2, BorderLayout.SOUTH);

}
 
源代码16 项目: mars-sim   文件: OngoingStudyListPanel.java
/**
 * Constructor.
 * @param scienceWindow the science window.
 */
public OngoingStudyListPanel(ScienceWindow scienceWindow) {
	// Use JPanel constructor.
	super();

	this.scienceWindow = scienceWindow;

	setLayout(new BorderLayout());

	// Create title label.
	JLabel titleLabel = new JLabel(Msg.getString("OngoingStudyListPanel.ongoingScientificStudies"), JLabel.CENTER); //$NON-NLS-1$
	add(titleLabel, BorderLayout.NORTH);

	// Create list scroll pane.
	listScrollPane = new JScrollPane();
	listScrollPane.setBorder(new MarsPanelBorder());
	listScrollPane.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
	add(listScrollPane, BorderLayout.CENTER);

	// Create study table model.
	studyTableModel = new StudyTableModel();

	// Create study table.
	studyTable = new JTable(studyTableModel);
	studyTable.setPreferredScrollableViewportSize(new Dimension(500, 200));
	studyTable.setCellSelectionEnabled(false);
	studyTable.setRowSelectionAllowed(true);
	studyTable.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
	studyTable.getSelectionModel().addListSelectionListener(new ListSelectionListener() {
		public void valueChanged(ListSelectionEvent event) {
			if (event.getValueIsAdjusting()) {
				int row = studyTable.getSelectedRow();
				if (row >= 0) {
					ScientificStudy selectedStudy = studyTableModel.getStudy(row);
					if (selectedStudy != null) setSelectedScientificStudy(selectedStudy);
				}
			}
		}
	});
	studyTable.getColumnModel().getColumn(0).setPreferredWidth(40);
	studyTable.getColumnModel().getColumn(1).setPreferredWidth(7);
	studyTable.getColumnModel().getColumn(2).setPreferredWidth(80);
	studyTable.getColumnModel().getColumn(3).setPreferredWidth(80);
	studyTable.getColumnModel().getColumn(3).setPreferredWidth(80);
	
	studyTable.setAutoCreateRowSorter(true);
	
	TableStyle.setTableStyle(studyTable);
	
	listScrollPane.setViewportView(studyTable);
}
 
源代码17 项目: visualvm   文件: DetailsPanel.java
private void initComponents() {        
    table = new DetailsTable();
    table.getSelectionModel().setSelectionMode(ListSelectionModel.SINGLE_SELECTION);

    JViewport viewport = new Viewport(table);

    final JScrollPane tableScroll = new JScrollPane(
                                        JScrollPane.VERTICAL_SCROLLBAR_ALWAYS,
                                        JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
    tableScroll.setViewport(viewport);
    tableScroll.setBorder(BorderFactory.createEmptyBorder());
    tableScroll.setViewportBorder(BorderFactory.createEmptyBorder());
    tableScroll.setCorner(JScrollPane.UPPER_RIGHT_CORNER, new HeaderPanel());
    
    scrollBar = new ScrollBar(JScrollBar.VERTICAL) {
        public int getUnitIncrement(int direction) {
            JViewport vp = tableScroll.getViewport();
            Scrollable view = (Scrollable)(vp.getView());
            Rectangle vr = vp.getViewRect();
            return view.getScrollableUnitIncrement(vr, getOrientation(), direction);
        }
        public int getBlockIncrement(int direction) {
            JViewport vp = tableScroll.getViewport();
            Scrollable view = (Scrollable)(vp.getView());
            Rectangle vr = vp.getViewRect();
            return view.getScrollableBlockIncrement(vr, getOrientation(), direction);
        }
        public void setValues(int newValue, int newExtent, int newMin, int newMax) {
            setEnabled(newExtent < newMax);
            if (isEnabled() && !isSelectionChanging() && isTrackingEnd())
                newValue = newMax - newExtent;
            super.setValues(newValue, newExtent, newMin, newMax);
        }
    };
    tableScroll.setVerticalScrollBar(scrollBar);
    dataContainer = tableScroll;

    JLabel noDataLabel = new JLabel("<No probe selected>", JLabel.CENTER);
    noDataLabel.setEnabled(false);
    noDataContainer = new JPanel(new BorderLayout());
    noDataContainer.setOpaque(false);
    noDataContainer.add(noDataLabel, BorderLayout.CENTER);

    setOpaque(false);
    setLayout(new BorderLayout());
    add(noDataContainer, BorderLayout.CENTER);
}
 
源代码18 项目: mars-sim   文件: MaintenanceTabPanel.java
public void initializeUI() {
		uiDone = true;
		
        Malfunctionable malfunctionable = (Malfunctionable) unit;
        MalfunctionManager manager = malfunctionable.getMalfunctionManager();

        // Create maintenance label.
  		JPanel mpanel = new JPanel(new FlowLayout(FlowLayout.CENTER));
        JLabel maintenanceLabel = new JLabel(Msg.getString("MaintenanceTabPanel.title", JLabel.CENTER));
        maintenanceLabel.setFont(new Font("Serif", Font.BOLD, 16));
  		mpanel.add(maintenanceLabel);
        topContentPanel.add(mpanel);

        // Create maintenance panel
        JPanel maintenancePanel = new JPanel(new GridLayout(6, 1, 0, 0));
        maintenancePanel.setBorder(new MarsPanelBorder());
        topContentPanel.add(maintenancePanel);

        // Create wear condition label.
        wearConditionCache = (int) Math.round(manager.getWearCondition());
        wearConditionLabel = new JLabel("Condition: " + wearConditionCache +
                "%", JLabel.CENTER);
        wearConditionLabel.setToolTipText("The health condition due to wear & tear : 100% = new; 0% = worn out");
        maintenancePanel.add(wearConditionLabel);

        // Create lastCompletedLabel.
        lastCompletedTime = (int) (manager.getTimeSinceLastMaintenance() / 1000D);
        lastCompletedLabel = new JLabel("Last Completed: " + lastCompletedTime +
            " sols", JLabel.CENTER);
        maintenancePanel.add(lastCompletedLabel);

        // Create maintenance progress bar panel.
        JPanel progressPanel = new JPanel(new FlowLayout(FlowLayout.CENTER, 0, 0));
        maintenancePanel.add(progressPanel);

        // Prepare maintenance parts label.
        partsLabel = new JLabel(getPartsString(false), JLabel.CENTER);
        partsLabel.setPreferredSize(new Dimension(-1, -1));
        maintenancePanel.add(partsLabel);

        // Prepare progress bar.
        JProgressBar progressBar = new JProgressBar();
        progressBarModel = progressBar.getModel();
        progressBar.setStringPainted(true);
        progressPanel.add(progressBar);

        // Set initial value for progress bar.
        double completed = manager.getMaintenanceWorkTimeCompleted();
        double total = manager.getMaintenanceWorkTime();
        int percentDone = (int) (100D * (completed / total));
        progressBarModel.setValue(percentDone);

        // Prepare malfunction panel
        JPanel malfunctionPanel = new JPanel(new BorderLayout(0, 0));
//        malfunctionPanel.setBorder(new MarsPanelBorder());
        centerContentPanel.add(malfunctionPanel, BorderLayout.CENTER);

        // Create malfunctions label
        JLabel malfunctionsLabel = new JLabel("Malfunctions", JLabel.CENTER);
        malfunctionPanel.add(malfunctionsLabel, BorderLayout.NORTH);

        // Create scroll panel for malfunction list
        JScrollPane malfunctionScrollPanel = new JScrollPane();
        malfunctionScrollPanel.setPreferredSize(new Dimension(170, 90));
        malfunctionPanel.add(malfunctionScrollPanel, BorderLayout.CENTER);

        // Create malfunction list main panel.
        JPanel malfunctionListMainPanel = new JPanel(new BorderLayout(0, 0));
        malfunctionScrollPanel.setViewportView(malfunctionListMainPanel);

        // Create malfunction list panel
        malfunctionListPanel = new JPanel();
        malfunctionListPanel.setLayout(new BoxLayout(malfunctionListPanel, BoxLayout.Y_AXIS));
        malfunctionListMainPanel.add(malfunctionListPanel, BorderLayout.NORTH);

        // Create malfunction panels
        malfunctionCache = malfunctionable.getMalfunctionManager().getMalfunctions();
        malfunctionPanels = new ArrayList<MalfunctionPanel>();
        Iterator<Malfunction> i = malfunctionCache.iterator();
        while (i.hasNext()) {
            MalfunctionPanel panel = new MalfunctionPanel(i.next());
            malfunctionListPanel.add(panel);
            malfunctionPanels.add(panel);
        }
    }
 
源代码19 项目: pentaho-reporting   文件: WelcomePane.java
private JPanel createButtonsPane() {
  final int buttonPaneHeight = backgroundImage.getHeight( null );
  final JPanel buttonPane = new JPanel();
  buttonPane.setLayout( null );
  buttonPane.setOpaque( false );
  buttonPane.setBackground( new Color( 0, 0, 0, 0 ) );
  buttonPane.setBorder( new EmptyBorder( 0, 0, 0, 0 ) );
  buttonPane.setMinimumSize( new Dimension( 514, buttonPaneHeight ) );
  buttonPane.setMaximumSize( new Dimension( 514, buttonPaneHeight ) );
  buttonPane.setPreferredSize( new Dimension( 514, buttonPaneHeight ) );

  try {
    final Class wizardClass =
      Class.forName( "org.pentaho.reporting.designer.extensions.wizard.NewWizardReportAction" );
    final AbstractDesignerContextAction newWizardActionListener =
      (AbstractDesignerContextAction) wizardClass.newInstance();
    newWizardActionListener.setReportDesignerContext( reportDesignerContext );
    final JButton wizardBtn = new TransparentButton();
    wizardBtn.addActionListener( newWizardActionListener );
    wizardBtn.addActionListener( closeActionListener );
    wizardBtn.setBorderPainted( true );
    wizardBtn.setBounds( 117, 137, 100, 118 );
    buttonPane.add( wizardBtn );

    final JLabel wizardLabel =
      new JLabel( newWizardActionListener.getValue( "WIZARD.BUTTON.TEXT" ).toString(), JLabel.CENTER ); //NON-NLS
    wizardLabel.setBounds( 80, 273, 165, 56 );
    buttonPane.add( wizardLabel );

    final JButton wizardLabelBtn = new TransparentButton();
    wizardLabelBtn.addActionListener( newWizardActionListener );
    wizardLabelBtn.addActionListener( closeActionListener );
    wizardLabelBtn.setBorderPainted( true );
    wizardLabelBtn.setBounds( 80, 273, 165, 56 );
    buttonPane.add( wizardLabelBtn );
  } catch ( Exception e ) {
    // todo: Remove me. Replace the code with a real extension mechanism
  }

  // Adds the new (blank) report button
  final JButton newReportBtn = new TransparentButton();
  newReportBtn.addActionListener( newReportAction );
  newReportBtn.addActionListener( closeActionListener );
  newReportBtn.setBorderPainted( true );
  newReportBtn.setBounds( 323, 137, 100, 118 );
  buttonPane.add( newReportBtn );

  final JLabel newReportLabel = new JLabel( Messages.getString( "WelcomePane.newReportLabel" ), JLabel.CENTER );
  newReportLabel.setBounds( 285, 273, 165, 56 );
  buttonPane.add( newReportLabel );

  final JButton newReportLabelBtn = new TransparentButton();
  newReportLabelBtn.addActionListener( newReportAction );
  newReportLabelBtn.addActionListener( closeActionListener );
  newReportLabelBtn.setBorderPainted( true );
  newReportLabelBtn.setBounds( 285, 273, 165, 56 );
  buttonPane.add( newReportLabelBtn );
  return buttonPane;
}
 
源代码20 项目: netbeans   文件: BookmarkKeyChooser.java
public void show(Component parent, Runnable runOnClose) {
    this.runOnClose = runOnClose;
    key2bookmark = new HashMap<Character, BookmarkInfo>(2 * 46, 0.5f);
    BookmarkManager lockedBookmarkManager = BookmarkManager.getLocked();
    try {
        // Open projects should have their bookmarks loaded before invocation of this method
        // so that it's possible to enumerate present keys properly
        for (ProjectBookmarks projectBookmarks : lockedBookmarkManager.activeProjectBookmarks()) {
            for (FileBookmarks fileBookmarks : projectBookmarks.getFileBookmarks()) {
                for (BookmarkInfo bookmark : fileBookmarks.getBookmarks()) {
                    String key = bookmark.getKey();
                    if (key != null && key.length() > 0) {
                        key2bookmark.put(key.charAt(0), bookmark);
                    }
                }
            }
        }
    } finally {
        lockedBookmarkManager.unlock();
    }
    
    JPanel cellPanel = new JPanel();
    if (key2bookmark.size() > 0) {
        cellPanel.setLayout(new GridLayout(4, 10, 2, 2));
        addCells(cellPanel, 10 * 4, '1', '9', '0', '0', 'A', 'Z');
    } else { // No bookmarks with keys
        cellPanel.setLayout(new GridLayout(2, 1, 2, 2));
        JLabel noKeysLabel = new JLabel(NbBundle.getMessage(BookmarkKeyChooser.class, "LBL_keyChooserNoActiveKeys"), JLabel.CENTER);
        JLabel noKeysHelpLabel = new JLabel(NbBundle.getMessage(BookmarkKeyChooser.class, "LBL_keyChooserNoActiveKeysHelp"), JLabel.CENTER);
        cellPanel.add(noKeysLabel);
        cellPanel.add(noKeysHelpLabel);
    }
    cellPanel.setBorder(new EmptyBorder(4, 4, 4, 4));
    closeButton = new JButton(NbBundle.getMessage(BookmarkKeyChooser.class, "CTL_keyChooserCloseButton")); // NOI18N

    dialog = org.netbeans.editor.DialogSupport.createDialog(
            NbBundle.getMessage(BookmarkKeyChooser.class, "CTL_keyChooserTitle"), // NOI18N
            cellPanel, true, // modal
            new JButton[] { closeButton }, false, // bottom buttons
            0, // defaultIndex = 0 => allow close by Enter key too
            0, // cancelIndex
            this // ActionListener
    );
    dialog.pack();
    
    Point parentMidPoint = new Point(parent.getWidth() / 2, parent.getHeight() / 2);
    SwingUtilities.convertPointToScreen(parentMidPoint, parent);
    dialog.setBounds(
            parentMidPoint.x - dialog.getWidth() / 2,
            parentMidPoint.y - dialog.getHeight() / 2,
            dialog.getWidth(),
            dialog.getHeight()
    );
    closeButton.addKeyListener(this);
    dialog.setAlwaysOnTop(true);
    dialog.setVisible(true);
}