Java Code Examples for javax.swing.JLabel#LEFT

The following examples show how to use javax.swing.JLabel#LEFT . 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: ReplayListColumnSetupDialog.java    From sc2gears with Apache License 2.0 6 votes vote down vote up
public ColumnDef( final int modelIndex ) {
	this.modelIndex = modelIndex;
	positionLabel = new JLabel( "", JLabel.RIGHT );
	positionLabel.setPreferredSize( new Dimension( 40, 0 ) );
	nameLabel     = new JLabel( ReplaySearch.RESULT_HEADER_NAMES[ modelIndex ], JLabel.LEFT );
	GuiUtils.changeFontToBold( nameLabel );
	
	wrapperBox.add( positionLabel );
	wrapperBox.add( Box.createHorizontalStrut( 10 ) );
	wrapperBox.add( Box.createHorizontalGlue() );
	wrapperBox.add( nameLabel );
	wrapperBox.add( Box.createHorizontalStrut( 20 ) );
	wrapperBox.add( moveUpButton );
	wrapperBox.add( moveDownButton );
	wrapperBox.add( Box.createHorizontalStrut( 20 ) );
	wrapperBox.add( visibleCheckBox );
}
 
Example 2
Source File: TaskTableHeaderRenderer.java    From egdownloader with GNU General Public License v2.0 5 votes vote down vote up
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);
	}
}
 
Example 3
Source File: GroupListCellReader.java    From egdownloader with GNU General Public License v2.0 5 votes vote down vote up
public Component getListCellRendererComponent(JList list, Object value,
		int index, boolean isSelected, boolean cellHasFocus) {
	if (isSelected) {  
           setBackground(Color.BLACK);  
           setForeground(Color.WHITE);  
       } else {  
           // 设置选取与取消选取的前景与背景颜色.  
           setBackground(Color.BLUE);  
           setForeground(Color.DARK_GRAY);  
       }
	return new AJLabel(value.toString(), IconManager.getIcon("folder"), value.toString().equals(ComponentConst.groupName) ? Color.RED : Color.BLUE, JLabel.LEFT);
}
 
Example 4
Source File: InjectedParameterPlaceholderLabel.java    From rapidminer-studio with GNU Affero General Public License v3.0 5 votes vote down vote up
public InjectedParameterPlaceholderLabel(ConnectionParameterModel param) {
	super(new GridBagLayout());
	GridBagConstraints gbc = new GridBagConstraints();
	JLabel icon = new JLabel("", INJECTED_ICON, JLabel.LEFT);
	add(icon, gbc);
	Font font = icon.getFont();
	String bodyRule = "body { font-family: " + font.getFamily() + "; " +
			"font-size: " + font.getSize() + "pt; }";
	((HTMLDocument) editorPane.getDocument()).getStyleSheet().addRule(bodyRule);
	editorPane.setOpaque(false);
	editorPane.setBorder(null);
	editorPane.setEditable(false);
	editorPane.addHyperlinkListener(event -> {
		if (event.getEventType() == HyperlinkEvent.EventType.ACTIVATED && event.getURL() != null) {
			RMUrlHandler.openInBrowser(event.getURL());
		}
	});
	gbc.insets.left = icon.getIconTextGap();
	gbc.weightx = 1;
	gbc.fill = GridBagConstraints.HORIZONTAL;
	add(editorPane, gbc);

	valueProviderChanged = (i, o, n) -> updateText(param);
	valueProviderParameterChanged = c -> {
		while (c.next()) {
			for (ValueProviderParameterModel valueProviderParameterModel : c.getAddedSubList()) {
				valueProviderParameterModel.valueProperty().removeListener(valueProviderChanged);
				valueProviderParameterModel.valueProperty().addListener(valueProviderChanged);
			}
		}
		updateText(param);
	};
	param.injectorNameProperty().addListener((i, o, n) -> registerListener(param));
	registerListener(param);
}
 
Example 5
Source File: JImageComboBox.java    From binnavi with Apache License 2.0 5 votes vote down vote up
public JImageComboBox(final ImageElement[] items, final int labelAlignment) {
  super(items);

  if ((labelAlignment != JLabel.LEFT) && (labelAlignment != JLabel.CENTER)
      && (labelAlignment != JLabel.RIGHT)) {
    throw new IllegalArgumentException("Erorr: Label alignment in invalid.");
  }

  setRenderer(new ComboBoxRenderer(labelAlignment));
}
 
Example 6
Source File: JImageComboBox.java    From binnavi with Apache License 2.0 5 votes vote down vote up
public ComboBoxRenderer(final int alignment) {
  setOpaque(true);
  setHorizontalAlignment(alignment);
  setVerticalAlignment(CENTER);

  if (alignment == JLabel.LEFT) {
    setBorder(new EmptyBorder(0, 5, 0, 0));
  }
}
 
Example 7
Source File: ConstructionSitesPanel.java    From mars-sim with GNU General Public License v3.0 5 votes vote down vote up
/**
         * Constructor.
         * @param site the construction site.
         */
        private ConstructionSitePanel(ConstructionSite site) {
            // Use JPanel constructor
            super();
            
            // Initialize data members.
            this.site = site;
            
            // Set the layout.
            setLayout(new BorderLayout(5, 5));
            
            // Set border
//            setBorder(new MarsPanelBorder());
            
            // Create the status panel.
            statusLabel = new JLabel("Status: ", JLabel.LEFT);
            add(statusLabel, BorderLayout.NORTH);
            
            // Create the progress bar panel.
            JPanel progressBarPanel = new JPanel();
            add(progressBarPanel, BorderLayout.CENTER);
            
            // Prepare work progress bar.
            JProgressBar workBar = new JProgressBar();
            workBarModel = workBar.getModel();
            workBar.setStringPainted(true);
            progressBarPanel.add(workBar);
            
            // Update progress bar.
            update();
            
            // Add tooltip.
            setToolTipText(getToolTipString());
        }
 
Example 8
Source File: ToolAdapterTabbedEditorDialog.java    From snap-desktop with GNU General Public License v3.0 5 votes vote down vote up
private void addTab(JTabbedPane tabControl, String title, JPanel content) {
    JLabel tabText = new JLabel(title, JLabel.LEFT);
    tabText.setPreferredSize(new Dimension(6 * controlHeight, controlHeight));
    TitledBorder titledBorder = BorderFactory.createTitledBorder(title);
    titledBorder.setTitleJustification(TitledBorder.CENTER);
    content.setBorder(titledBorder);
    tabControl.addTab(null, content);
    tabControl.setTabComponentAt(tabControl.getTabCount() - 1, tabText);
}
 
Example 9
Source File: BundleForm.java    From snap-desktop with GNU General Public License v3.0 5 votes vote down vote up
private void addTab(String text, JPanel contents) {
    JLabel tabText = new JLabel(text, JLabel.LEFT);
    Border titledBorder = BorderFactory.createEmptyBorder();
    contents.setBorder(titledBorder);
    this.bundleTabPane.addTab(null, contents);
    this.bundleTabPane.setTabComponentAt(this.bundleTabPane.getTabCount() - 1, tabText);
}
 
Example 10
Source File: ManufacturePanel.java    From mars-sim with GNU General Public License v3.0 4 votes vote down vote up
/**
	 * Constructor
	 * @param process the manufacturing process.
	 * @param showBuilding is the building name shown?
	 * @param processStringWidth the max string width to display for the process name.
	 */
	public ManufacturePanel(ManufactureProcess process, boolean showBuilding, int processStringWidth) {
		// Call WebPanel constructor
		super();

		// Initialize data members.
		this.process = process;

        // Set layout
		if (showBuilding) setLayout(new GridLayout(4, 1, 0, 0));
		else setLayout(new GridLayout(3, 1, 0, 0));

        // Set border
        setBorder(new MarsPanelBorder());

        // Prepare name panel.
        WebPanel namePane = new WebPanel(new FlowLayout(FlowLayout.LEFT, 1, 0));
        add(namePane);

        // Prepare cancel button.
        JButton cancelButton = new JButton(ImageLoader.getIcon("CancelSmall"));
        cancelButton.setMargin(new Insets(0, 0, 0, 0));
        cancelButton.addActionListener(new ActionListener() {
        	public void actionPerformed(ActionEvent event) {
//        		try {
        			getManufactureProcess().getWorkshop().endManufacturingProcess(getManufactureProcess(), true);
//        		}
//        		catch (BuildingException e) {}
	        }
        });
        cancelButton.setToolTipText("Cancel manufacturing process");
        namePane.add(cancelButton);

        // Prepare name label.
        String name = process.getInfo().getName();
        if (name.length() > 0) {
        	String firstLetter = name.substring(0, 1).toUpperCase();
        	name = " " + firstLetter + name.substring(1);
        }
        if (name.length() > processStringWidth) name = name.substring(0, processStringWidth) + "...";
		// Capitalize process names
        JLabel nameLabel = new JLabel(Conversion.capitalize(name), JLabel.CENTER);
        namePane.add(nameLabel);

        if (showBuilding) {
        	// Prepare building name label.
        	String buildingName = process.getWorkshop().getBuilding().getNickName();
        	JLabel buildingNameLabel = new JLabel(buildingName, JLabel.CENTER);
        	add(buildingNameLabel);
        }

        // Prepare work panel.
        WebPanel workPane = new WebPanel(new FlowLayout(FlowLayout.CENTER, 0, 0));
        add(workPane);

        // Prepare work label.
        JLabel workLabel = new JLabel("Work: ", JLabel.LEFT);
        workPane.add(workLabel);

        // Prepare work progress bar.
        JProgressBar workBar = new JProgressBar();
        workBarModel = workBar.getModel();
        workBar.setStringPainted(true);
        workPane.add(workBar);

        // Prepare time panel.
        WebPanel timePane = new WebPanel(new FlowLayout(FlowLayout.CENTER, 0, 0));
        add(timePane);

        // Prepare time label.
        JLabel timeLabel = new JLabel("Time: ", JLabel.LEFT);
        timePane.add(timeLabel);

        // Prepare time progress bar.
        JProgressBar timeBar = new JProgressBar();
        timeBarModel = timeBar.getModel();
        timeBar.setStringPainted(true);
        timePane.add(timeBar);

        // Update progress bars.
        update();

        // Add tooltip.
        setToolTipText(getToolTipString(process.getInfo(), process.getWorkshop().getBuilding()));
	}
 
Example 11
Source File: ActionChooserScreen.java    From chipster with MIT License 4 votes vote down vote up
public ActionChooserScreen(ImportSession importSession) {
	SwingClientApplication.setPlastic3DLookAndFeel(dialog);
	dialog.setPreferredSize(new Dimension(640, 480));
	dialog.setLocationByPlatform(true);

	this.importSession = importSession;

	table = this.getTable();
	JScrollPane scroll = new JScrollPane(table);

	// upper panel
	JLabel titleLabel = new JLabel("<html><p style=" + VisualConstants.HTML_DIALOG_TITLE_STYLE + ">" + TITLE_TEXT + "</p></html>", JLabel.LEFT);
	JLabel descriptionLabel = new JLabel("<html><p>" + INFO_TEXT + "</p></html>", JLabel.LEFT);
	GridBagConstraints c = new GridBagConstraints();
	JPanel upperPanel = new JPanel(new GridBagLayout());
	c.weightx = 1.0;
	c.weighty = 1.0;
	c.fill = GridBagConstraints.HORIZONTAL;
	c.anchor = GridBagConstraints.NORTHWEST;
	c.insets.set(10, 10, 5, 10);
	c.gridx = 0;
	c.gridy = 0;
	upperPanel.add(titleLabel, c);
	c.gridy++;
	upperPanel.add(descriptionLabel, c);
	

	// lower panel
	JPanel buttonPanel = new JPanel();
	okButton = new JButton("  OK  ");
	cancelButton = new JButton("Cancel");
	copyButton = new JButton("Apply first action to all");

	okButton.addActionListener(this);
	cancelButton.addActionListener(this);
	copyButton.addActionListener(this);

	JLabel sameSettingsLabel = new JLabel("<html><p>" + "When using Import tool to import more than one files, only define the contents of the first file and then apply the same settings for the rest of the files." + "</p></html>", JLabel.LEFT);
	sameSettingsLabel.setVerticalTextPosition(JLabel.TOP);
	//sameSettingsLabel.setPreferredSize(new Dimension(550, 40));
	
	sameSettingsCheckBox = new JCheckBox("Define file structure once and apply the same settings to all files");
	sameSettingsCheckBox.setEnabled(true);
	sameSettingsCheckBox.setSelected(true);
	sameSettingsCheckBox.setPreferredSize(new Dimension(550, 40));

	buttonPanel.setLayout(new GridBagLayout());
	GridBagConstraints g = new GridBagConstraints();
	g.anchor = GridBagConstraints.NORTHWEST;
	g.gridx = 0;
	g.gridy = 0;
	g.weightx = 0.0;

	g.insets = new Insets(5, 5, 10, 5);
	buttonPanel.add(copyButton, g);
	g.gridy++;
	buttonPanel.add(sameSettingsCheckBox, g);
	g.insets = new Insets(5, 0, 10, 5);
	g.gridy++;
	g.anchor = GridBagConstraints.EAST;
	buttonPanel.add(cancelButton, g);
	g.gridx++;
	buttonPanel.add(okButton, g);

	dialog.setLayout(new BorderLayout());
	dialog.add(upperPanel, BorderLayout.NORTH);
	dialog.add(scroll, BorderLayout.CENTER);
	dialog.add(buttonPanel, BorderLayout.SOUTH);
	dialog.pack();
	dialog.pack();
	okButton.requestFocusInWindow();
	dialog.setVisible(true);
}
 
Example 12
Source File: StudyDetailPanel.java    From mars-sim with GNU General Public License v3.0 4 votes vote down vote up
/**
 * Constructor
 */
StudyDetailPanel(ScienceWindow scienceWindow) {
	// Use JPanel constructor.
	super();

	setLayout(new BorderLayout());
	setPreferredSize(new Dimension(425, -1));

	JLabel titleLabel = new JLabel(Msg.getString("StudyDetailPanel.details"), JLabel.CENTER); //$NON-NLS-1$
	add(titleLabel, BorderLayout.NORTH);

	Box mainPane = Box.createVerticalBox();
	mainPane.setBorder(new MarsPanelBorder());
	add(mainPane, BorderLayout.CENTER);

	JPanel infoPane = new JPanel(new BorderLayout());//FlowLayout(FlowLayout.LEFT,5,5));//GridLayout(2, 1, 0, 0));
	infoPane.setBorder(new MarsPanelBorder());
	infoPane.setAlignmentX(Component.LEFT_ALIGNMENT);
	mainPane.add(infoPane);

	JPanel topSpringPane = new JPanel(new SpringLayout());//new GridLayout(2, 2, 0, 0));
	infoPane.add(topSpringPane, BorderLayout.NORTH);
	
	scienceHeader = new JLabel(Msg.getString("StudyDetailPanel.science"), JLabel.RIGHT); //$NON-NLS-1$
	scienceFieldLabel = new JLabel("N/A", JLabel.LEFT);
	
	levelHeader = new JLabel(Msg.getString("StudyDetailPanel.level"), JLabel.RIGHT); //$NON-NLS-1$
	levelLabel = new JLabel("N/A", JLabel.LEFT);

	phaseHeader = new JLabel(Msg.getString("StudyDetailPanel.phase"), JLabel.RIGHT); //$NON-NLS-1$
	phaseLabel = new JLabel("N/A", JLabel.LEFT); 

	topicHeader = new JLabel("  " + Msg.getString("StudyDetailPanel.topic") + "    "); //$NON-NLS-1$
	
	topSpringPane.add(scienceHeader);
	topSpringPane.add(scienceFieldLabel);

	topSpringPane.add(levelHeader);
	topSpringPane.add(levelLabel);

	topSpringPane.add(phaseHeader);
	topSpringPane.add(phaseLabel);
	
	WebStyledLabel noneLabel = new WebStyledLabel("{None:i;c(blue);background(grey)}"); // StyleId.styledlabelTag, 
	noneLabel.setStyleId(StyleId.styledlabelShadow); // styledlabelTag

	topicPanel = new WebPanel(new BorderLayout());
	topicPanel.add(topicHeader, BorderLayout.WEST);
	topicPanel.add(noneLabel);
	
	infoPane.add(topicPanel, BorderLayout.CENTER);
	
	// Prepare SpringLayout
	SpringUtilities.makeCompactGrid(topSpringPane,
	                                3, 2, //rows, cols
	                                5, 4,        //initX, initY
	                                30, 3);       //xPad, yPad
	
	primaryResearcherPane = new ResearcherPanel(scienceWindow);
	primaryResearcherPane.setAlignmentX(Component.LEFT_ALIGNMENT);
	mainPane.add(primaryResearcherPane);

	collabResearcherPanes = new ResearcherPanel[3];
	for (int x = 0; x < 3; x++) {
		collabResearcherPanes[x] = new ResearcherPanel(scienceWindow);
		collabResearcherPanes[x].setAlignmentX(Component.LEFT_ALIGNMENT);
		mainPane.add(collabResearcherPanes[x]);
	}

	// Add a vertical glue.
	mainPane.add(Box.createVerticalGlue());
}
 
Example 13
Source File: SalvageTabPanel.java    From mars-sim with GNU General Public License v3.0 4 votes vote down vote up
public void initializeUI() {
uiDone = true;

      Salvagable salvageItem = (Salvagable) unit;
      SalvageInfo salvageInfo = salvageItem.getSalvageInfo();
      
      // Create the salvage header panel.
      JPanel salvageHeaderPanel = new JPanel(new FlowLayout(FlowLayout.CENTER, 0, 10));
      topContentPanel.add(salvageHeaderPanel);
      
      // Create the salvage header label.
      JLabel salvageHeaderLabel = new JLabel(unit.getName() + " has been salvaged.", JLabel.CENTER);
      salvageHeaderPanel.add(salvageHeaderLabel);
      
      // Create the salvage info panel.
      JPanel salvageInfoPanel = new JPanel(new BorderLayout(0, 0));
      topContentPanel.add(salvageInfoPanel);
      
      // Create the time panel.
      JPanel timePanel = new JPanel(new GridLayout(2, 1, 0, 0));
      salvageInfoPanel.add(timePanel, BorderLayout.NORTH);
      
      // Create the start time label.
      String startTimeString = salvageInfo.getStartTime().getDateTimeStamp();
      JLabel startTimeLabel = new JLabel("Start Time: " + startTimeString, JLabel.LEFT);
      timePanel.add(startTimeLabel);
      
      // Create the finish time label.
      MarsClock finishTime = salvageInfo.getFinishTime();
      finishTimeString = "";
      if (finishTime != null) finishTimeString = finishTime.getDateTimeStamp();
      finishTimeLabel = new JLabel("Finish Time: " + finishTimeString, JLabel.LEFT);
      timePanel.add(finishTimeLabel);

      // Create the settlement panel.
      JPanel settlementPanel = new JPanel(new FlowLayout(FlowLayout.LEFT, 0, 0));
      salvageInfoPanel.add(settlementPanel);
      
      // Create the settlement label.
      JLabel settlementLabel = new JLabel("Settlement: ");
      settlementPanel.add(settlementLabel);
      
      // Create the settlement button.
      JButton settlementButton = new JButton(salvageInfo.getSettlement().getName());
      settlementButton.addActionListener(new ActionListener() {
          public void actionPerformed(ActionEvent event) {
              SalvageInfo info = ((Salvagable) getUnit()).getSalvageInfo();
              getDesktop().openUnitWindow(info.getSettlement(), false);
          }
      });
      settlementPanel.add(settlementButton);
      
      // Create the parts panel.
      JPanel partsPanel = new JPanel(new BorderLayout(0, 10));
      partsPanel.setBorder(new MarsPanelBorder());
      topContentPanel.add(partsPanel);
      
      // Create the parts label.
      JLabel partsLabel = new JLabel("Salvaged Parts", JLabel.CENTER);
      partsPanel.add(partsLabel, BorderLayout.NORTH);
      
      // Create the parts table panel.
      JScrollPane partsTablePanel = new JScrollPane();
      partsPanel.add(partsTablePanel, BorderLayout.CENTER);
      
      // Create the parts table.
      partTableModel = new PartTableModel(salvageInfo);
      JTable partsTable = new JTable(partTableModel);
      partsTable.setPreferredScrollableViewportSize(new Dimension(150, 75));
      partsTable.getColumnModel().getColumn(0).setPreferredWidth(100);
      partsTable.getColumnModel().getColumn(1).setPreferredWidth(50);
      partsTable.setCellSelectionEnabled(false);
      partsTable.setDefaultRenderer(Double.class, new NumberCellRenderer(1));
      partsTablePanel.setViewportView(partsTable);
  }
 
Example 14
Source File: AqlViewer.java    From CQL with GNU Affero General Public License v3.0 4 votes vote down vote up
private <X, Y> Component viewAlgebra(float z,
		Algebra<catdata.aql.exp.Ty, catdata.aql.exp.En, catdata.aql.exp.Sym, catdata.aql.exp.Fk, catdata.aql.exp.Att, catdata.aql.exp.Gen, catdata.aql.exp.Sk, X, Y> algebra) {

	JPanel top = new JPanel(new GridBagLayout());
	top.setBorder(BorderFactory.createEmptyBorder());

	JCheckBox simp = new JCheckBox("", false);
	int a = Integer.min(maxrows, algebra.sizeOfBiggest());
	JSlider sl = new JSlider(0, a, Integer.min(32, a));

	JLabel limit = new JLabel("Row limit:", JLabel.RIGHT);

	JLabel lbl = new JLabel("Provenance:", JLabel.RIGHT);
	JLabel ids = new JLabel(
			" " + algebra.size() + " IDs, " + algebra.talg().sks.size() + " nulls, " + z + " seconds.",
			JLabel.LEFT);

	GridBagConstraints gbc = new GridBagConstraints();
	gbc.weightx = 1;
	gbc.fill = GridBagConstraints.HORIZONTAL;

	gbc.anchor = GridBagConstraints.WEST;
	top.add(ids, gbc);

	gbc.anchor = GridBagConstraints.EAST;
	top.add(lbl, gbc);
	gbc.anchor = GridBagConstraints.WEST;
	top.add(simp, gbc);
	gbc.anchor = GridBagConstraints.EAST;
	top.add(limit, gbc);
	gbc.anchor = GridBagConstraints.WEST;
	top.add(sl, gbc);

	JPanel out = new JPanel(new BorderLayout());
	out.setBorder(BorderFactory.createEtchedBorder());

	Map<Pair<Boolean, Integer>, JScrollPane> cache = new THashMap<>();
	viewAlgebraHelper(top, algebra, out, simp, sl, cache);

	sl.addChangeListener((x) -> {
		viewAlgebraHelper(top, algebra, out, simp, sl, cache);
	});
	simp.addChangeListener((x) -> {
		viewAlgebraHelper(top, algebra, out, simp, sl, cache);
	});

	return out;
}
 
Example 15
Source File: FoodProductionPanel.java    From mars-sim with GNU General Public License v3.0 4 votes vote down vote up
/**
	 * Constructor
	 * 
	 * @param process            the foodProduction process.
	 * @param showBuilding       is the building name shown?
	 * @param processStringWidth the max string width to display for the process
	 *                           name.
	 */
	public FoodProductionPanel(FoodProductionProcess process, boolean showBuilding, int processStringWidth) {
		// Call JPanel constructor
		super();

		// Initialize data members.
		this.process = process;

		// Set layout
		if (showBuilding)
			setLayout(new GridLayout(4, 1, 0, 0));
		else
			setLayout(new GridLayout(3, 1, 0, 0));

		// Set border
		setBorder(new MarsPanelBorder());

		// Prepare name panel.
		JPanel namePane = new JPanel(new FlowLayout(FlowLayout.LEFT, 1, 0));
		add(namePane);

		// Prepare cancel button.
		JButton cancelButton = new JButton(ImageLoader.getIcon("CancelSmall"));
		cancelButton.setMargin(new Insets(0, 0, 0, 0));
		cancelButton.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent event) {
//        		try {
				getFoodProductionProcess().getKitchen().endFoodProductionProcess(getFoodProductionProcess(), true);
//        		}
//        		catch (BuildingException e) {}
			}
		});
		cancelButton.setToolTipText("Cancel his Food Production Process");
		namePane.add(cancelButton);

		// Prepare name label.
		String name = process.getInfo().getName();
		if (name.length() > 0) {
			String firstLetter = name.substring(0, 1).toUpperCase();
			name = " " + firstLetter + name.substring(1);
		}
		if (name.length() > processStringWidth)
			name = name.substring(0, processStringWidth) + "...";
		// 2014-11-19 Capitalized process names
		JLabel nameLabel = new JLabel(Conversion.capitalize(name), JLabel.CENTER);
		namePane.add(nameLabel);

		if (showBuilding) {
			// Prepare building name label.
			// 2014-11-19 Changed from getName() to getNickName()
			String buildingName = process.getKitchen().getBuilding().getNickName();
			JLabel buildingNameLabel = new JLabel(buildingName, JLabel.CENTER);
			add(buildingNameLabel);
		}

		// Prepare work panel.
		JPanel workPane = new JPanel(new FlowLayout(FlowLayout.CENTER, 0, 0));
		add(workPane);

		// Prepare work label.
		JLabel workLabel = new JLabel("Work: ", JLabel.LEFT);
		workPane.add(workLabel);

		// Prepare work progress bar.
		JProgressBar workBar = new JProgressBar();
		workBarModel = workBar.getModel();
		workBar.setStringPainted(true);
		workPane.add(workBar);

		// Prepare time panel.
		JPanel timePane = new JPanel(new FlowLayout(FlowLayout.CENTER, 0, 0));
		add(timePane);

		// Prepare time label.
		JLabel timeLabel = new JLabel("Time: ", JLabel.LEFT);
		timePane.add(timeLabel);

		// Prepare time progress bar.
		JProgressBar timeBar = new JProgressBar();
		timeBarModel = timeBar.getModel();
		timeBar.setStringPainted(true);
		timePane.add(timeBar);

		// Update progress bars.
		update();

		// Add tooltip.
		setToolTipText(getToolTipString(process.getInfo(), process.getKitchen().getBuilding()));
	}
 
Example 16
Source File: Boot.java    From MakeLobbiesGreatAgain with MIT License 4 votes vote down vote up
public static void getLocalAddr() throws InterruptedException, PcapNativeException, UnknownHostException, SocketException,
		ClassNotFoundException, InstantiationException, IllegalAccessException, UnsupportedLookAndFeelException {
	if (Settings.getDouble("autoload", 0) == 1) {
		addr = InetAddress.getByName(Settings.get("addr", ""));
		return;
	}

	UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
	final JFrame frame = new JFrame("Network Device");
	frame.setFocusableWindowState(true);

	final JLabel ipLab = new JLabel("Select LAN IP obtained from Network Settings:", JLabel.LEFT);
	final JComboBox<String> lanIP = new JComboBox<String>();
	final JLabel lanLabel = new JLabel("If your device IP isn't in the dropdown, provide it below.");
	final JTextField lanText = new JTextField(Settings.get("addr", ""));

	ArrayList<InetAddress> inets = new ArrayList<InetAddress>();

	for (PcapNetworkInterface i : Pcaps.findAllDevs()) {
		for (PcapAddress x : i.getAddresses()) {
			InetAddress xAddr = x.getAddress();
			if (xAddr != null && x.getNetmask() != null && !xAddr.toString().equals("/0.0.0.0")) {
				NetworkInterface inf = NetworkInterface.getByInetAddress(x.getAddress());
				if (inf != null && inf.isUp() && !inf.isVirtual()) {
					inets.add(xAddr);
					lanIP.addItem((lanIP.getItemCount() + 1) + " - " + inf.getDisplayName() + " ::: " + xAddr.getHostAddress());
					System.out.println("Found: " + lanIP.getItemCount() + " - " + inf.getDisplayName() + " ::: " + xAddr.getHostAddress());
				}
			}
		}
	}

	if (lanIP.getItemCount() == 0) {
		JOptionPane.showMessageDialog(null, "Unable to locate devices.\nPlease try running the program in Admin Mode.\nIf this does not work, you may need to reboot your computer.",
				"Error", JOptionPane.ERROR_MESSAGE);
		System.exit(1);
	}
	lanIP.setFocusable(false);
	final JButton start = new JButton("Start");
	start.addActionListener(e -> {
		try {
			if (lanText.getText().length() >= 7 && !lanText.getText().equals("0.0.0.0")) { // 7 is because the minimum field is 0.0.0.0
				addr = InetAddress.getByName(lanText.getText());
				System.out.println("Using IP from textfield: " + lanText.getText());
			} else {
				addr = inets.get(lanIP.getSelectedIndex());
				System.out.println("Using device from dropdown: " + lanIP.getSelectedItem());
			}
			Settings.set("addr", addr.getHostAddress().replaceAll("/", ""));
			frame.setVisible(false);
			frame.dispose();
		} catch (UnknownHostException e1) {
			e1.printStackTrace();
		}
	});

	frame.setLayout(new GridLayout(5, 1));
	frame.add(ipLab);
	frame.add(lanIP);
	frame.add(lanLabel);
	frame.add(lanText);
	frame.add(start);
	frame.setAlwaysOnTop(true);
	frame.pack();
	frame.setLocationRelativeTo(null);
	frame.setVisible(true);
	frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

	while (frame.isVisible())
		Thread.sleep(10);
}
 
Example 17
Source File: OnlyMessageBox.java    From oim-fx with MIT License 4 votes vote down vote up
private void init(String message, OnlyMessageBox.MessageType messageType, int option) {

      iconMap = new HashMap<OnlyMessageBox.MessageType, Icon>();
      iconMap.put(OnlyMessageBox.MessageType.ERROR, new ImageIcon());
      iconMap.put(OnlyMessageBox.MessageType.INFORMATION, new ImageIcon());
      iconMap.put(OnlyMessageBox.MessageType.QUESTION, new ImageIcon());
      iconMap.put(OnlyMessageBox.MessageType.WARNING, new ImageIcon());

      JPanel buttonPane = new JPanel();
      lbMessage = new JLabel(message, iconMap.get(messageType), JLabel.LEFT);
      btnOK = new JButton("确定");
      btnCancel = new JButton("取消");
      btnYes = new JButton("是");
      btnNo = new JButton("否");
      JButton[] buttons = {btnOK, btnYes, btnNo, btnCancel};
      int[] options = {OK_OPTION, YES_OPTION, NO_OPTION, CANCEL_OPTION};
      final Dimension buttonSize = new Dimension(69, 21);
      int index = 0;
      boolean hasDefaultButton = false;

     
      lbMessage.setIconTextGap(16);
      lbMessage.setHorizontalAlignment(JLabel.LEFT);
      lbMessage.setVerticalAlignment(JLabel.TOP);
      lbMessage.setVerticalTextPosition(JLabel.TOP);
      lbMessage.setBorder(new EmptyBorder(15, 25, 15, 25));
      buttonPane.setLayout(new LineLayout(6, 0, 0, 0, 0, LineLayout.LEADING, LineLayout.LEADING, LineLayout.HORIZONTAL));
      buttonPane.setPreferredSize(new Dimension(-1, 33));
      buttonPane.setBorder(new EmptyBorder(5, 9, 0, 9));
      buttonPane.setBackground(new Color(255, 255, 255, 170));

      for (JButton button : buttons) {
          button.setActionCommand(String.valueOf(options[index]));
          button.setPreferredSize(buttonSize);
          button.setVisible((option & options[index]) != 0);
          button.addActionListener(this);
          buttonPane.add(button, LineLayout.END);
          index++;

          if (!hasDefaultButton && button.isVisible()) {
              getRootPane().setDefaultButton(button);
              hasDefaultButton = true;
          }
      }

      getContentPane().setLayout(new LineLayout(0, 1, 1, 3, 1, LineLayout.LEADING, LineLayout.LEADING, LineLayout.VERTICAL));
      getContentPane().add(lbMessage, LineLayout.MIDDLE_FILL);
      getContentPane().add(buttonPane, LineLayout.END_FILL);
  }
 
Example 18
Source File: GUIFilterConfig.java    From PacketProxy with Apache License 2.0 4 votes vote down vote up
private JComponent createComponent() {
	String[] menu = { "#", I18nString.get("Filter name"), I18nString.get("Filter") };
	int[] menu_width = { 40, 150, 610 };
	boolean[] fixed_map = { true, false, false };
	int[] align_map = { JLabel.RIGHT, JLabel.LEFT, JLabel.LEFT };
	project_model = new ProjectTableModel(menu, 0) {
		private static final long serialVersionUID = 1L;
		@Override
		public boolean isCellEditable(int row, int column) { return false; }
	};
	JPanel panel = new JPanel();

	table = new JTable(project_model);
	tableFixedColumnWidth(table, menu_width, fixed_map);
	tableAssignAlignment(table, align_map);
	//sorter = new TableRowSorter<ProjectTableModel>(project_model);
	//table.setRowSorter(sorter);
	for (int i = 0; i < menu.length; i++) {
		table.getColumn(menu[i]).setPreferredWidth(menu_width[i]);
	}
	((JComponent) table.getDefaultRenderer(Boolean.class)).setOpaque(true);

	JScrollPane scrollpane1 = new JScrollPane(table);
    scrollpane1.setMaximumSize(new Dimension(Short.MAX_VALUE, Short.MAX_VALUE));
    scrollpane1.setBackground(Color.WHITE);

	panel.add(createTableButton());
	panel.add(scrollpane1);
    panel.setLayout(new BoxLayout(panel, BoxLayout.X_AXIS));
    panel.setMaximumSize(new Dimension(Short.MAX_VALUE, Short.MAX_VALUE));
    panel.setBackground(Color.WHITE);
	panel.add(scrollpane1);
	
	//sort_field = new HintTextField("フィルタ文字列");
    //sort_field.getDocument().addDocumentListener(new DocumentListener() {
	//	@Override
	//	public void insertUpdate(DocumentEvent e) {
	//		sortByText(sort_field.getText());
	//	}
	//	@Override
	//	public void removeUpdate(DocumentEvent e) {
	//		sortByText(sort_field.getText());
	//	}
	//	@Override
	//	public void changedUpdate(DocumentEvent e) {
	//		sortByText(sort_field.getText());
	//	}
    //});
    //sort_field.setMaximumSize(new Dimension(Short.MAX_VALUE, sort_field.getPreferredSize().height));
    
    JPanel vpanel = new JPanel();
    vpanel.setLayout(new BoxLayout(vpanel, BoxLayout.Y_AXIS));
    vpanel.setMaximumSize(new Dimension(Short.MAX_VALUE, Short.MAX_VALUE));
    //vpanel.add(sort_field);
    vpanel.add(panel);
	
	return vpanel;
}