Java Code Examples for java.awt.FlowLayout#CENTER

The following examples show how to use java.awt.FlowLayout#CENTER . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: RandomMapDialog.java    From megamek with GNU General Public License v2.0 6 votes vote down vote up
private JPanel setupDisplayButtons() {
    JPanel panel = new JPanel(new FlowLayout(FlowLayout.CENTER, 2, 2));
    ButtonGroup displayButtonGroup = new ButtonGroup();

    basicButton.addActionListener(this);
    displayButtonGroup.add(basicButton);
    panel.add(basicButton);

    advancedButton.addActionListener(this);
    displayButtonGroup.add(advancedButton);
    panel.add(advancedButton);

    basicButton.setSelected(true);

    panel.setBorder(new TitledBorder(new LineBorder(Color.black, 1), "View"));

    return panel;
}
 
Example 2
Source File: ModeChoicePanel.java    From magarena with GNU General Public License v3.0 6 votes vote down vote up
public ModeChoicePanel(final SwingGameController aController, final MagicSource source, final List<Integer> aModes) {
    controller = aController;
    modes = aModes;

    setLayout(new BorderLayout());
    setOpaque(false);

    final TextLabel textLabel=new TextLabel(SwingGameController.getMessageWithSource(source,MESSAGE),UserActionPanel.TEXT_WIDTH,true);
    add(textLabel,BorderLayout.NORTH);

    final JPanel buttonPanel=new JPanel(new FlowLayout(FlowLayout.CENTER,5,5));
    buttonPanel.setBorder(FontsAndBorders.EMPTY_BORDER);
    buttonPanel.setOpaque(false);
    add(buttonPanel,BorderLayout.CENTER);

    for (int index=0; index < modes.size(); index++) {
        final JButton button=new JButton(Integer.toString(modes.get(index)));
        button.setPreferredSize(BUTTON_DIMENSION);
        button.setBorder(BorderFactory.createLineBorder(FontsAndBorders.GRAY4));
        button.setActionCommand(Integer.toString(index));
        button.addActionListener(this);
        button.setFocusable(false);
        buttonPanel.add(button);
    }
}
 
Example 3
Source File: TabPanelVehicles.java    From mars-sim with GNU General Public License v3.0 5 votes vote down vote up
public void initializeUI() {
		uiDone = true;
		
		// Create vehicle label panel
		JPanel vehicleLabelPanel = new JPanel(new FlowLayout(FlowLayout.CENTER));
		topContentPanel.add(vehicleLabelPanel);

		// Create vehicle label
		JLabel label = new JLabel(Msg.getString("TabPanelVehicles.parkedVehicles"), JLabel.CENTER); //$NON-NLS-1$
		label.setFont(new Font("Serif", Font.BOLD, 16));
		//label.setForeground(new Color(102, 51, 0)); // dark brown
		vehicleLabelPanel.add(label);

		// Create vehicle display panel
		JPanel vehicleDisplayPanel = new JPanel(new FlowLayout(FlowLayout.CENTER));
//		vehicleDisplayPanel.setBorder(new MarsPanelBorder());
		topContentPanel.add(vehicleDisplayPanel);

		// Create scroll panel for vehicle list.
		vehicleScrollPanel = new JScrollPane();
		vehicleScrollPanel.setPreferredSize(new Dimension(175, 200));
		vehicleDisplayPanel.add(vehicleScrollPanel);

		// Create vehicle list model
		vehicleListModel = new VehicleListModel(settlement);

		// Create vehicle list
		vehicleList = new JList<Vehicle>(vehicleListModel);
		vehicleList.addMouseListener(this);
		vehicleScrollPanel.setViewportView(vehicleList);
	}
 
Example 4
Source File: NotesTabPanel.java    From mars-sim with GNU General Public License v3.0 5 votes vote down vote up
public void initializeUI() {
	uiDone = true;
	
	// Initialize location header.
	WebPanel titlePane = new WebPanel(new FlowLayout(FlowLayout.CENTER));
	topContentPanel.add(titlePane);

	WebLabel titleLabel = new WebLabel(Msg.getString("NotesTabPanel.title"), WebLabel.CENTER); //$NON-NLS-1$
	titleLabel.setFont(new Font("Serif", Font.BOLD, 16));
	// titleLabel.setForeground(new Color(102, 51, 0)); // dark brown
	titlePane.add(titleLabel);
	
	// Create notes panel
	WebPanel notesPanel = new WebPanel(new BorderLayout(5, 5));
	notesPanel.setBorder(new MarsPanelBorder());
	notesPanel.setBorder(new EmptyBorder(1, 1, 1, 1));
	centerContentPanel.add(notesPanel);
	
	notesCache = unit.getNotes();
	
	textArea = new WebTextArea(StyleId.textareaDecorated);
	notesPanel.add(textArea);
	
	if (notesCache == null || notesCache.equals(""))
		textArea.setInputPrompt("Enter Here");
	else {
		textArea.append(notesCache);
	}

}
 
Example 5
Source File: GameLoadingPanel.java    From ShootPlane with Apache License 2.0 5 votes vote down vote up
private void createLoadingPanel() {
this.gameLoadingPlaneImgList = new ImageIcon[3];
this.gameLoadingPlaneImgList[0] = new ImageIcon(Images.GAME_LOADING_IMG1);
this.gameLoadingPlaneImgList[1] = new ImageIcon(Images.GAME_LOADING_IMG2);
this.gameLoadingPlaneImgList[2] = new ImageIcon(Images.GAME_LOADING_IMG3);
this.gameLoadingTextImg = Images.GAME_LOADING_TEXT_IMG;

gameLoadingPlaneLabel = new JLabel();
gameLoadingPlaneLabel.setOpaque(false);
gameLoadingTextLabel = new JLabel(new ImageIcon(this.gameLoadingTextImg));
gameLoadingTextLabel.setOpaque(false);
GridLayout gridLayout = new GridLayout(2, 1);

FlowLayout flowLayout1 = new FlowLayout(FlowLayout.CENTER);
JPanel panel1 = new JPanel();
panel1.setLayout(flowLayout1);
panel1.add(gameLoadingPlaneLabel);
panel1.setOpaque(false);

FlowLayout flowLayout2 = new FlowLayout(FlowLayout.CENTER);
JPanel panel2 = new JPanel();
panel2.setLayout(flowLayout2);
panel2.add(gameLoadingTextLabel);
panel2.setOpaque(false);

this.setLayout(gridLayout);
this.setOpaque(false);
this.add(panel1);
this.add(panel2);
   }
 
Example 6
Source File: HasLockIcon.java    From radiance with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
/**
 * Creates the main frame for <code>this</code> sample.
 */
public HasLockIcon() {
    super("Has lock icon");

    this.setLayout(new BorderLayout());

    final JTextField jtf = new JTextField("sample text");
    jtf.setEditable(false);
    jtf.setColumns(20);

    JPanel main = new JPanel(new FlowLayout(FlowLayout.CENTER));
    this.add(main, BorderLayout.CENTER);
    main.add(jtf);

    JPanel controls = new JPanel(new FlowLayout(FlowLayout.RIGHT));

    final JCheckBox hasLockIcon = new JCheckBox("Has lock icon");
    hasLockIcon.addActionListener((ActionEvent e) -> SubstanceCortex.ComponentScope
            .setLockIconVisible(jtf, hasLockIcon.isSelected()));

    controls.add(hasLockIcon);
    this.add(controls, BorderLayout.SOUTH);

    this.setSize(400, 200);
    this.setLocationRelativeTo(null);
    this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
}
 
Example 7
Source File: ConstructedBuildingsPanel.java    From mars-sim with GNU General Public License v3.0 5 votes vote down vote up
/**
	 * Constructor.
	 * @param manager the settlement construction manager.
	 */
	public ConstructedBuildingsPanel(ConstructionManager manager) {
		// Use JPanel constructor.
		super();

		setLayout(new BorderLayout(0, 0));
//		setBorder(new MarsPanelBorder());

		JPanel titlePanel = new JPanel(new FlowLayout(FlowLayout.CENTER));
		add(titlePanel, BorderLayout.NORTH);

		JLabel titleLabel = new JLabel("Constructed Buildings");
		titlePanel.add(titleLabel);

		// Create scroll panel for the outer table panel.
		JScrollPane scrollPanel = new JScrollPane();
		scrollPanel.setPreferredSize(new Dimension(200, 75));
		scrollPanel.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
		add(scrollPanel, BorderLayout.CENTER);

		// Prepare constructed table model.
		constructedTableModel = new ConstructedBuildingTableModel(manager);

		// Prepare constructed table.
		constructedTable = new ZebraJTable(constructedTableModel);
		scrollPanel.setViewportView(constructedTable);
		constructedTable.setRowSelectionAllowed(true);
		constructedTable.getColumnModel().getColumn(0).setPreferredWidth(105);
		constructedTable.getColumnModel().getColumn(1).setPreferredWidth(105);

		constructedTable.setPreferredScrollableViewportSize(new Dimension(225, -1));
		constructedTable.setAutoResizeMode(JTable.AUTO_RESIZE_ALL_COLUMNS);
		constructedTable.setAutoCreateRowSorter(true);
	
		TableStyle.setTableStyle(constructedTable);

	}
 
Example 8
Source File: SwitchablePane.java    From DroidUIBuilder with Apache License 2.0 5 votes vote down vote up
/**
	 * 核心GUI初始化方法.
	 * 
	 * @param cards
	 */
	protected void initGUI(Object[][] cards)
	{
		// 实例化子各主要面板
		mainPane = new JPanel(new BorderLayout());
		cardPane = new JPanel(new CardLayout());
		FlowLayout btnPaneLayout = new FlowLayout(FlowLayout.CENTER);
		btnPaneLayout.setVgap(0);
		btnPane = new JPanel(btnPaneLayout);
		
		// 加入向前按钮
		addToBtnPane(initPreviousButton());
		// 加入页号按钮
		for(int i=0;i<cards.length;i++ )
		{
			Object[] cardInfo = cards[i];
//			String num = (String)cardInfo[0];
			JComponent c = (JComponent)cardInfo[0];
			String toolTipText = (String)cardInfo[1];
			
			// 此key即进分页组件的顺序号(从1开始),又将做为它
			// 位于CardLayout中的name(constraints),一举多得
			final String key = (i+1)+"";
			// 先在把要显示的内容组件加入到内容子面板中
			this.addCard(key, c, toolTipText);
			// 再把该分页内容组件对应的页号按钮加入到按钮面板中
			addToBtnPane(createPageButton(key, toolTipText));
		}
		// 加入向后按钮
		addToBtnPane(initNextButton());
		
		// 总体布局
		mainPane.add(cardPane, BorderLayout.CENTER);
		mainPane.add(btnPane, BorderLayout.SOUTH);
	}
 
Example 9
Source File: DGetNewPassword.java    From portecle with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Initialize the dialog's GUI components.
 */
private void initComponents()
{
	getContentPane().setLayout(new BorderLayout());

	JLabel jlFirst = new JLabel(RB.getString("DGetNewPassword.jlFirst.text"));
	JLabel jlConfirm = new JLabel(RB.getString("DGetNewPassword.jlConfirm.text"));
	m_jpfFirst = new JPasswordField(15);
	m_jpfConfirm = new JPasswordField(15);
	jlFirst.setLabelFor(m_jpfFirst);
	jlConfirm.setLabelFor(m_jpfConfirm);

	JButton jbOK = getOkButton(false);
	JButton jbCancel = getCancelButton();

	JPanel jpPassword = new JPanel(new GridLayout(2, 2, 5, 5));
	jpPassword.add(jlFirst);
	jpPassword.add(m_jpfFirst);
	jpPassword.add(jlConfirm);
	jpPassword.add(m_jpfConfirm);
	jpPassword.setBorder(new EmptyBorder(5, 5, 5, 5));

	JPanel jpButtons = new JPanel(new FlowLayout(FlowLayout.CENTER));
	jpButtons.add(jbOK);
	jpButtons.add(jbCancel);

	getContentPane().add(jpPassword, BorderLayout.CENTER);
	getContentPane().add(jpButtons, BorderLayout.SOUTH);

	getRootPane().setDefaultButton(jbOK);

	initDialog();
}
 
Example 10
Source File: AboutDialogFactory.java    From lucene-solr with Apache License 2.0 5 votes vote down vote up
private JPanel header() {
  JPanel panel = new JPanel(new GridLayout(3, 1));
  panel.setOpaque(false);

  JPanel logo = new JPanel(new FlowLayout(FlowLayout.CENTER));
  logo.setOpaque(false);
  logo.add(new JLabel(ImageUtils.createImageIcon("luke-logo.gif", 200, 40)));
  panel.add(logo);

  JPanel project = new JPanel(new FlowLayout(FlowLayout.CENTER));
  project.setOpaque(false);
  JLabel projectLbl = new JLabel("Lucene Toolbox Project");
  projectLbl.setFont(new Font(projectLbl.getFont().getFontName(), Font.BOLD, 32));
  projectLbl.setForeground(Color.decode("#5aaa88"));
  project.add(projectLbl);
  panel.add(project);

  JPanel desc = new JPanel();
  desc.setOpaque(false);
  desc.setLayout(new BoxLayout(desc, BoxLayout.PAGE_AXIS));

  JPanel subTitle = new JPanel(new FlowLayout(FlowLayout.CENTER, 10, 5));
  subTitle.setOpaque(false);
  JLabel subTitleLbl = new JLabel("GUI client of the best Java search library Apache Lucene");
  subTitleLbl.setFont(new Font(subTitleLbl.getFont().getFontName(), Font.PLAIN, 20));
  subTitle.add(subTitleLbl);
  subTitle.add(new JLabel(ImageUtils.createImageIcon("lucene-logo.gif", 100, 15)));
  desc.add(subTitle);

  JPanel link = new JPanel(new FlowLayout(FlowLayout.CENTER, 5, 5));
  link.setOpaque(false);
  JLabel linkLbl = FontUtils.toLinkText(new URLLabel("https://lucene.apache.org/"));
  link.add(linkLbl);
  desc.add(link);

  panel.add(desc);

  return panel;
}
 
Example 11
Source File: StartupProgressDialog.java    From zencash-swing-wallet-ui with MIT License 5 votes vote down vote up
public StartupProgressDialog(ZCashClientCaller clientCaller) 
  {
      this.clientCaller = clientCaller;
      
      URL iconUrl = this.getClass().getClassLoader().getResource("images/ZEN-yellow.orange-logo.png");
      imageIcon = new ImageIcon(iconUrl);
      imageLabel.setIcon(imageIcon);
      imageLabel.setBorder(BorderFactory.createEmptyBorder(16, 40, 8, 40));
      Container contentPane = getContentPane();
      contentPane.setLayout(borderLayout1);
      southPanel.setLayout(southPanelLayout);
      southPanel.setBorder(BorderFactory.createEmptyBorder(0, 16, 16, 16));
      contentPane.add(imageLabel, BorderLayout.NORTH);
JLabel zcashWalletLabel = new JLabel(LanguageUtil.instance().getString("startup.progress.dialog.label"));
zcashWalletLabel.setBorder(BorderFactory.createEmptyBorder(16, 16, 16, 16));
// todo - place in a panel with flow center
JPanel tempPanel = new JPanel(new FlowLayout(FlowLayout.CENTER, 1, 1));
tempPanel.add(zcashWalletLabel);
contentPane.add(tempPanel, BorderLayout.CENTER);
      contentPane.add(southPanel, BorderLayout.SOUTH);
      progressBar.setIndeterminate(true);
      southPanel.add(progressBar, BorderLayout.NORTH);
      progressLabel.setText(LanguageUtil.instance().getString("startup.progress.dialog.progressbar.label"));
      southPanel.add(progressLabel, BorderLayout.SOUTH);
      pack();
      setLocationRelativeTo(null);
      
      this.setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE);
  }
 
Example 12
Source File: TabPanelAssociatedPeople.java    From mars-sim with GNU General Public License v3.0 4 votes vote down vote up
public void initializeUI() {
		uiDone = true;
		
		WebPanel titlePane = new WebPanel(new FlowLayout(FlowLayout.CENTER));
		topContentPanel.add(titlePane);

		// Create associated people label
		WebLabel heading = new WebLabel(Msg.getString("TabPanelAssociatedPeople.title"), WebLabel.CENTER); //$NON-NLS-1$
		heading.setFont(new Font("Serif", Font.BOLD, 16));
		// heading.setForeground(new Color(102, 51, 0)); // dark brown
		titlePane.add(heading);

		// Prepare count spring layout panel.
		WebPanel countPanel = new WebPanel(new SpringLayout());//GridLayout(3, 1, 0, 0));
//		countPanel.setBorder(new MarsPanelBorder());
		topContentPanel.add(countPanel);

		// Create associate label
		WebLabel populationNumHeader = new WebLabel(Msg.getString("TabPanelAssociatedPeople.associated"),
				WebLabel.RIGHT); // $NON-NLS-1$
		countPanel.add(populationNumHeader);
		
		populationCitizensCache = settlement.getNumCitizens();
		populationCitizensLabel = new WebLabel(populationCitizensCache + "", WebLabel.LEFT);
		countPanel.add(populationCitizensLabel);

		// Create population indoor label
		WebLabel populationIndoorHeader = new WebLabel(Msg.getString("TabPanelAssociatedPeople.indoor"),
				WebLabel.RIGHT); // $NON-NLS-1$
		countPanel.add(populationIndoorHeader);
		
		populationIndoorCache = settlement.getIndoorPeopleCount();
		populationIndoorLabel = new WebLabel(populationIndoorCache + "", WebLabel.LEFT);
		countPanel.add(populationIndoorLabel);
		
		// Create population capacity label
		WebLabel populationCapacityHeader = new WebLabel(Msg.getString("TabPanelAssociatedPeople.capacity"),
				WebLabel.RIGHT); // $NON-NLS-1$
		countPanel.add(populationCapacityHeader);
		
		populationCapacityCache = settlement.getPopulationCapacity();
		populationCapacityLabel = new WebLabel(populationCapacityCache + "", WebLabel.RIGHT);
		countPanel.add(populationCapacityLabel);
		
		// Lay out the spring panel.
		SpringUtilities.makeCompactGrid(countPanel, 3, 2, // rows, cols
				25, 10, // initX, initY
				10, 10); // xPad, yPad
		
        UIManager.getDefaults().put("TitledBorder.titleColor", Color.darkGray);
        Border lowerEtched = BorderFactory.createEtchedBorder(EtchedBorder.LOWERED);
        TitledBorder title = BorderFactory.createTitledBorder(lowerEtched, " " + Msg.getString("TabPanelAssociatedPeople.title") + " ");
//      title.setTitleJustification(TitledBorder.RIGHT);
        Font titleFont = UIManager.getFont("TitledBorder.font");
        title.setTitleFont( titleFont.deriveFont(Font.ITALIC + Font.BOLD));
        
		// Create spring layout population display panel
		WebPanel populationDisplayPanel = new WebPanel(new FlowLayout(FlowLayout.CENTER));
		populationDisplayPanel.setBorder(title);
//		populationDisplayPanel.setBorder(new MarsPanelBorder());
		topContentPanel.add(populationDisplayPanel);

		// Create scroll panel for population list.
		populationScrollPanel = new WebScrollPane();
		populationScrollPanel.setPreferredSize(new Dimension(200, 250));
		populationDisplayPanel.add(populationScrollPanel);

		// Create population list model
		populationListModel = new AssociatedPopulationListModel(settlement);

		// Create population list
		populationList = new JList<Person>(populationListModel);
		populationList.addMouseListener(this);
		populationScrollPanel.setViewportView(populationList);


		// Create population monitor button
		JButton monitorButton = new JButton(ImageLoader.getIcon(Msg.getString("img.monitor"))); //$NON-NLS-1$
		monitorButton.setMargin(new Insets(1, 1, 1, 1));
		monitorButton.addActionListener(this);
		monitorButton.setToolTipText(Msg.getString("TabPanelAssociatedPeople.tooltip.monitor")); //$NON-NLS-1$
		populationDisplayPanel.add(monitorButton);
		
//		WebPanel buttonPane = new WebPanel(new FlowLayout(FlowLayout.RIGHT));
////		buttonPane.setPreferredSize(new Dimension(25, 25));
//		buttonPane.add(monitorButton);
//		
//		populationDisplayPanel.add(buttonPane);

	}
 
Example 13
Source File: UnknownParametersInfoDialog.java    From rapidminer-studio with GNU Affero General Public License v3.0 4 votes vote down vote up
public UnknownParametersInfoDialog(Frame owner, List<UnknownParameterInformation> unknownParameters) {
	super(owner, "Unknown Parameters", true);
	setDefaultCloseOperation(DISPOSE_ON_CLOSE);

	setLayout(new BorderLayout());

	setModal(true);

	// text
	JTextArea text = new JTextArea();
	text.setLineWrap(true);
	text.setWrapStyleWord(true);
	text.setBackground(getBackground());
	text.setEditable(false);
	String textString = "The following table shows all parameters which are not (no longer) valid. This can happen for several reasons. First, a mistake in the parameter name can cause this error. Second, a parameter was removed and is now no longer supported. Third, a parameter was replaced by a (set of) other parameter(s). Please ensure that the process still performs the desired task by checking the parameter settings manually.";
	text.setText(textString);
	text.setBorder(BorderFactory.createEmptyBorder(11, 11, 11, 11));
	add(text, BorderLayout.NORTH);

	// table
	ExtendedJTable table = new ExtendedJTable(new UnknownParametersTableModel(unknownParameters), true, true, true);
	ExtendedJScrollPane pane = new ExtendedJScrollPane(table);
	pane.setBorder(BorderFactory.createEmptyBorder(11, 11, 11, 11));
	add(pane, BorderLayout.CENTER);

	// ok button
	JPanel buttonPanel = new JPanel(new FlowLayout(FlowLayout.CENTER));
	JButton okButton = new JButton("Ok");
	okButton.addActionListener(new ActionListener() {

		@Override
		public void actionPerformed(ActionEvent e) {
			ok();
		}
	});
	buttonPanel.add(okButton);
	add(buttonPanel, BorderLayout.SOUTH);

	setSize(640, 480);
	setLocationRelativeTo(owner);
}
 
Example 14
Source File: TabPanelPopulation.java    From mars-sim with GNU General Public License v3.0 4 votes vote down vote up
public void initializeUI() {
		uiDone = true;
		
		JPanel titlePane = new JPanel(new FlowLayout(FlowLayout.CENTER));
		topContentPanel.add(titlePane);

		JLabel heading = new JLabel(Msg.getString("TabPanelPopulation.title"), JLabel.CENTER); //$NON-NLS-1$
		heading.setFont(new Font("Serif", Font.BOLD, 16));
		//heading.setForeground(new Color(102, 51, 0)); // dark brown
		titlePane.add(heading);

		// Prepare count spring layout panel.
		WebPanel countPanel = new WebPanel(new SpringLayout());//GridLayout(3, 1, 0, 0));
//		countPanel.setBorder(new MarsPanelBorder());
		topContentPanel.add(countPanel);
		
		// Create population indoor label
		WebLabel populationIndoorHeader = new WebLabel(Msg.getString("TabPanelPopulation.indoor"),
				WebLabel.RIGHT); // $NON-NLS-1$
		countPanel.add(populationIndoorHeader);
		
		populationIndoorCache = settlement.getIndoorPeopleCount();
		populationIndoorLabel = new WebLabel(populationIndoorCache + "", WebLabel.LEFT);
		countPanel.add(populationIndoorLabel);
		
		// Create population capacity label
		WebLabel populationCapacityHeader = new WebLabel(Msg.getString("TabPanelPopulation.capacity"),
				WebLabel.RIGHT); // $NON-NLS-1$
		countPanel.add(populationCapacityHeader);
		
		populationCapacityCache = settlement.getPopulationCapacity();
		populationCapacityLabel = new WebLabel(populationCapacityCache + "", WebLabel.RIGHT);
		countPanel.add(populationCapacityLabel);
		
		// Lay out the spring panel.
		SpringUtilities.makeCompactGrid(countPanel, 2, 2, // rows, cols
				25, 10, // initX, initY
				10, 10); // xPad, yPad
		
        UIManager.getDefaults().put("TitledBorder.titleColor", Color.darkGray);
        Border lowerEtched = BorderFactory.createEtchedBorder(EtchedBorder.LOWERED);
        TitledBorder title = BorderFactory.createTitledBorder(lowerEtched, " " + Msg.getString("TabPanelPopulation.title") + " ");
//      title.setTitleJustification(TitledBorder.RIGHT);
        Font titleFont = UIManager.getFont("TitledBorder.font");
        title.setTitleFont( titleFont.deriveFont(Font.ITALIC + Font.BOLD));
        
		// Create spring layout population display panel
		JPanel populationDisplayPanel = new JPanel(new FlowLayout(FlowLayout.CENTER));
		populationDisplayPanel.setBorder(title);
		topContentPanel.add(populationDisplayPanel);

		// Create scroll panel for population list.
		populationScrollPanel = new JScrollPane();
		populationScrollPanel.setPreferredSize(new Dimension(200, 250));
		populationDisplayPanel.add(populationScrollPanel);

		// Create population list model
		populationListModel = new PopulationListModel(settlement);

		// Create population list
		populationList = new JList<Person>(populationListModel);
		populationList.addMouseListener(this);
		populationScrollPanel.setViewportView(populationList);

		// Create population monitor button
		JButton monitorButton = new JButton(ImageLoader.getIcon(Msg.getString("img.monitor"))); //$NON-NLS-1$
		monitorButton.setMargin(new Insets(1, 1, 1, 1));
		monitorButton.addActionListener(this);
		monitorButton.setToolTipText(Msg.getString("TabPanelPopulation.tooltip.monitor")); //$NON-NLS-1$
		populationDisplayPanel.add(monitorButton);

	}
 
Example 15
Source File: DChoosePkcs11Provider.java    From portecle with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Initialize the dialog's GUI components.
 *
 * @param sOldProvider The provider to display initially
 */
private void initComponents(String sOldProvider)
{
	getContentPane().setLayout(new BorderLayout());

	JLabel jlProvider = new JLabel(RB.getString("DChoosePkcs11Provider.jlProvider.text"));
	m_jcbProvider = new JComboBox<>();
	m_jcbProvider.setToolTipText(RB.getString("DChoosePkcs11Provider.m_jcbProvider.tooltip"));
	jlProvider.setLabelFor(m_jcbProvider);

	Collection<Provider> p11s = ProviderUtil.getPkcs11Providers();

	boolean providersAvailable = !p11s.isEmpty();

	if (!p11s.isEmpty())
	{
		for (Provider prov : p11s)
		{
			String pName = prov.getName();
			m_jcbProvider.addItem(pName);
			if (pName.equals(sOldProvider))
			{
				m_jcbProvider.setSelectedIndex(m_jcbProvider.getItemCount() - 1);
			}
		}
	}
	else
	{
		m_jcbProvider.addItem(RB.getString("DChoosePkcs11Provider.NoPkcs11Providers"));
		m_jcbProvider.setEnabled(false);
	}

	JButton jbOK = getOkButton(false);
	jbOK.setEnabled(providersAvailable);
	JButton jbCancel = getCancelButton();

	JPanel jpButtons = new JPanel(new FlowLayout(FlowLayout.CENTER));
	jpButtons.add(jbOK);
	jpButtons.add(jbCancel);

	JPanel jpProvider = new JPanel(new FlowLayout(FlowLayout.CENTER));
	jpProvider.add(jlProvider);
	jpProvider.add(m_jcbProvider);
	jpProvider.setBorder(new EmptyBorder(5, 5, 5, 5));

	getContentPane().add(jpProvider, BorderLayout.CENTER);
	getContentPane().add(jpButtons, BorderLayout.SOUTH);

	getRootPane().setDefaultButton(providersAvailable ? jbOK : jbCancel);

	initDialog();
}
 
Example 16
Source File: DGetHostPort.java    From portecle with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Initialize the dialog's GUI components.
 *
 * @param iOldHostPort The host+port to display initially
 */
private void initComponents(InetSocketAddress iOldHostPort)
{
	getContentPane().setLayout(new BorderLayout());

	JLabel jlHost = new JLabel(RB.getString("DGetHostPort.jlHost.text"));
	m_jtfHost = new JTextField(15);
	jlHost.setLabelFor(m_jtfHost);

	JLabel jlPort = new JLabel(RB.getString("DGetHostPort.jlPort.text"));
	m_jtfPort = new JTextField(DEFAULT_PORT, 5);
	Document doc = m_jtfPort.getDocument();
	if (doc instanceof AbstractDocument)
	{
		((AbstractDocument) doc).setDocumentFilter(new IntegerDocumentFilter(m_jtfPort.getColumns()));
	}
	if (iOldHostPort != null)
	{
		m_jtfHost.setText(iOldHostPort.getHostName());
		m_jtfPort.setText(String.valueOf(iOldHostPort.getPort()));
	}
	jlPort.setLabelFor(m_jtfPort);

	JPanel jpHostPort = new JPanel(new FlowLayout(FlowLayout.CENTER));
	jpHostPort.add(jlHost);
	jpHostPort.add(m_jtfHost);
	jpHostPort.add(jlPort);
	jpHostPort.add(m_jtfPort);
	jpHostPort.setBorder(new EmptyBorder(5, 5, 5, 5));

	JButton jbOK = getOkButton(false);
	JButton jbCancel = getCancelButton();

	JPanel jpButtons = new JPanel(new FlowLayout(FlowLayout.CENTER));
	jpButtons.add(jbOK);
	jpButtons.add(jbCancel);

	getContentPane().add(jpHostPort, BorderLayout.CENTER);
	getContentPane().add(jpButtons, BorderLayout.SOUTH);

	getRootPane().setDefaultButton(jbOK);

	initDialog();
}
 
Example 17
Source File: CreateMissionWizard.java    From mars-sim with GNU General Public License v3.0 4 votes vote down vote up
/**
	 * Constructor.
	 * @param missionWindow The owner frame.
	 */
	public CreateMissionWizard(MainDesktopPane desktop, MissionWindow missionWindow) {
		// Use ModalInternalFrame constructor
        super("Create Mission Wizard");
        //2016-09-24 Added missionWindow param
        this.missionWindow = missionWindow;
        this.desktop = desktop;
        
		// Set mission data bean.
		missionBean = new MissionDataBean();

		// Create info panel.
		infoPane = new JPanel(new CardLayout());
		infoPane.setBorder(new MarsPanelBorder());

		//setContentPane(infoPane);

		add(infoPane, BorderLayout.CENTER);

		// Create wizard panels list.
		wizardPanels = new ArrayList<WizardPanel>();
		displayPanelIndex = 0;

		// Create initial set of wizard panels.
		typePanel = new TypePanel(this);
		addWizardPanel(typePanel);

        // Note: This panel is added so that next and final buttons are
        // enabled/disabled properly initially.
        addWizardPanel(new StartingSettlementPanel(this));

		// Create bottom button panel.
		JPanel bottomButtonPane = new JPanel(new FlowLayout(FlowLayout.CENTER));
		add(bottomButtonPane, BorderLayout.SOUTH);

		// Create previous button.
		prevButton = new JButton("Previous");
		prevButton.addActionListener(this);
		prevButton.setEnabled(false);
		bottomButtonPane.add(prevButton);

		// Create next button.
		nextButton = new JButton("Next");
		nextButton.addActionListener(this);
		nextButton.setEnabled(false);
		bottomButtonPane.add(nextButton);

		// Create final button.
		finalButton = new JButton("Final");
		finalButton.addActionListener(this);
		finalButton.setEnabled(false);
		bottomButtonPane.add(finalButton);

		// Create cancel button.
		JButton cancelButton = new JButton("Cancel");
		cancelButton.addActionListener(
				new ActionListener() {
        			public void actionPerformed(ActionEvent e) {
        				// Unpause the game loop
//        				Simulation.instance().getMasterClock().setPaused(false, true);
        				// Dispose this dialog.
        				dispose();
        			}
				});
		bottomButtonPane.add(cancelButton);

		// Finish and display wizard.
		//pack();
        setSize(new Dimension(700, 600));
		//setLocationRelativeTo(owner);
		//setResizable(false);
		//setVisible(true);

		// Set the icon
		setIconImage();
		
        // Add to its own tab pane
//        if (desktop.getMainScene() != null)
//        	desktop.add(this);
//        	//desktop.getMainScene().getDesktops().get(1).add(this);
//        else 
        	desktop.add(this);
        
        	
		Dimension desktopSize = desktop.getParent().getSize();
	    Dimension jInternalFrameSize = this.getSize();
	    int width = (desktopSize.width - jInternalFrameSize.width) / 2;
	    int height = (desktopSize.height - jInternalFrameSize.height) / 2;
	    setLocation(width, height);
	    
	    setModal(true);
	    setVisible(true);
	    		
		// Pause the game loop
//		Simulation.instance().getMasterClock().setPaused(true, true);
	}
 
Example 18
Source File: DThrowableDetail.java    From portecle with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Initialize the dialog's GUI components.
 */
private void initComponents()
{
	// Buttons
	JPanel jpButtons = new JPanel(new FlowLayout(FlowLayout.CENTER));

	JButton jbOK = getOkButton(true);
	jpButtons.add(jbOK);

	JButton jbCopy = new JButton(RB.getString("DThrowableDetail.jbCopy.text"));
	jbCopy.setMnemonic(RB.getString("DThrowableDetail.jbCopy.mnemonic").charAt(0));
	jbCopy.setToolTipText(RB.getString("DThrowableDetail.jbCopy.tooltip"));
	jbCopy.addActionListener(new ActionListener()
	{
		@Override
		public void actionPerformed(ActionEvent evt)
		{
			copyPressed();
		}
	});
	jpButtons.add(jbCopy);

	JPanel jpThrowable = new JPanel(new BorderLayout());
	jpThrowable.setBorder(new EmptyBorder(5, 5, 5, 5));

	// Load tree with info on throwable's stack trace
	JTree jtrThrowable = new JTree(createThrowableNodes());
	// Top accommodate node icons with spare space (they are 16 pixels tall)
	jtrThrowable.setRowHeight(18);
	jtrThrowable.getSelectionModel().setSelectionMode(TreeSelectionModel.SINGLE_TREE_SELECTION);
	// Allow tool tips in tree
	ToolTipManager.sharedInstance().registerComponent(jtrThrowable);
	// Custom tree node renderer
	jtrThrowable.setCellRenderer(new ThrowableTreeCellRend());

	// Expand all nodes in tree
	/*
	 * ...then again, not. Too much scary detail. TreeNode topNode = (TreeNode)jtrThrowable.getModel().getRoot();
	 * expandTree(jtrThrowable, new TreePath(topNode));
	 */

	JScrollPane jspThrowable = new JScrollPane(jtrThrowable, ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS,
	    ScrollPaneConstants.HORIZONTAL_SCROLLBAR_ALWAYS);
	jspThrowable.setPreferredSize(new Dimension(500, 250));
	jpThrowable.add(jspThrowable, BorderLayout.CENTER);

	getContentPane().add(jpThrowable, BorderLayout.CENTER);
	getContentPane().add(jpButtons, BorderLayout.SOUTH);

	setTitle(RB.getString("DThrowableDetail.Title"));

	getRootPane().setDefaultButton(jbOK);

	initDialog();

	setResizable(true);
	jbOK.requestFocusInWindow();
}
 
Example 19
Source File: TabPanelCredit.java    From mars-sim with GNU General Public License v3.0 4 votes vote down vote up
public void initializeUI() {
		uiDone = true;
		
		// Prepare credit label panel.
		WebPanel creditLabelPanel = new WebPanel(new FlowLayout(FlowLayout.CENTER));
		topContentPanel.add(creditLabelPanel);

		// Prepare credit label.
		WebLabel creditLabel = new WebLabel(Msg.getString("TabPanelCredit.label"), WebLabel.CENTER); //$NON-NLS-1$
		creditLabel.setFont(new Font("Serif", Font.BOLD, 16));
		//creditLabel.setForeground(new Color(102, 51, 0)); // dark brown
		creditLabelPanel.add(creditLabel);

		// Create scroll panel for the outer table panel.
		WebScrollPane creditScrollPanel = new WebScrollPane();
		creditScrollPanel.setPreferredSize(new Dimension(280, 280));
		centerContentPanel.add(creditScrollPanel);

		// Prepare credit table model.
		CreditTableModel creditTableModel = new CreditTableModel((Settlement) unit);

		// Prepare credit table.
		creditTable = new ZebraJTable(creditTableModel);
		creditScrollPanel.setViewportView(creditTable);
		creditTable.setRowSelectionAllowed(true);
		
		creditTable.setDefaultRenderer(Double.class, new NumberCellRenderer(2, true));
		
		creditTable.getColumnModel().getColumn(0).setPreferredWidth(100);
		creditTable.getColumnModel().getColumn(1).setPreferredWidth(120);
		creditTable.getColumnModel().getColumn(2).setPreferredWidth(50);
		
		// Added the two methods below to make all heatTable columns
		// Resizable automatically when its Panel resizes
		creditTable.setPreferredScrollableViewportSize(new Dimension(225, -1));
		//creditTable.setAutoResizeMode(WebTable.AUTO_RESIZE_ALL_COLUMNS);
		// Added sorting
		creditTable.setAutoCreateRowSorter(true);

		// Align the preference score to the center of the cell
		DefaultTableCellRenderer renderer = new DefaultTableCellRenderer();
		renderer.setHorizontalAlignment(SwingConstants.RIGHT);
		creditTable.getColumnModel().getColumn(0).setCellRenderer(renderer);
//		creditTable.getColumnModel().getColumn(1).setCellRenderer(renderer);
		creditTable.getColumnModel().getColumn(2).setCellRenderer(renderer);
		
		TableStyle.setTableStyle(creditTable);

	}
 
Example 20
Source File: DProviderInfo.java    From portecle with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Initialize the dialog's GUI components.
 */
private void initComponents()
{
	// Buttons
	JPanel jpButtons = new JPanel(new FlowLayout(FlowLayout.CENTER));

	JButton jbOK = getOkButton(true);
	jpButtons.add(jbOK);

	JButton jbCopy = new JButton(RB.getString("DProviderInfo.jbCopy.text"));
	jbCopy.setMnemonic(RB.getString("DProviderInfo.jbCopy.mnemonic").charAt(0));
	jbCopy.setToolTipText(RB.getString("DProviderInfo.jbCopy.tooltip"));
	jbCopy.addActionListener(new ActionListener()
	{
		@Override
		public void actionPerformed(ActionEvent evt)
		{
			copyPressed();
		}
	});

	jpButtons.add(jbCopy);

	JPanel jpProviders = new JPanel(new BorderLayout());
	jpProviders.setBorder(new EmptyBorder(5, 5, 5, 5));

	// Load tree with info on loaded security providers
	JTree jtrProviders = new JTree(createProviderNodes());
	// Top accommodate node icons with spare space (they are 16 pixels tall)
	jtrProviders.setRowHeight(18);
	jtrProviders.getSelectionModel().setSelectionMode(TreeSelectionModel.SINGLE_TREE_SELECTION);
	// Allow tool tips in tree
	ToolTipManager.sharedInstance().registerComponent(jtrProviders);
	// Custom tree node renderer
	jtrProviders.setCellRenderer(new ProviderTreeCellRend());

	JScrollPane jspProviders = new JScrollPane(jtrProviders, ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS,
	    ScrollPaneConstants.HORIZONTAL_SCROLLBAR_ALWAYS);
	jspProviders.setPreferredSize(new Dimension(350, 200));
	jpProviders.add(jspProviders, BorderLayout.CENTER);

	getContentPane().add(jpProviders, BorderLayout.CENTER);
	getContentPane().add(jpButtons, BorderLayout.SOUTH);

	setTitle(RB.getString("DProviderInfo.Title"));

	getRootPane().setDefaultButton(jbOK);

	initDialog();

	setResizable(true);
	jbOK.requestFocusInWindow();
}