Java Code Examples for javax.swing.JFrame.setIconImage()

The following are Jave code examples for showing how to use setIconImage() of the javax.swing.JFrame class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
+ Save this method
Example 1
Project: incubator-netbeans   File: DummyWindowManager.java   View Source Code Vote up 5 votes
protected void topComponentIconChanged(TopComponent tc, Image icon) {
    JFrame f = (JFrame) SwingUtilities.getAncestorOfClass(JFrame.class, tc);

    if (f != null) {
        f.setIconImage(icon);
    }
}
 
Example 2
Project: JAddOn   File: JUtils.java   View Source Code Vote up 5 votes
public static void setIcon(JFrame frame, String icon) {
    try {
        frame.setIconImage(ImageIO.read(JUtils.class.getResourceAsStream(icon)));
    } catch (IOException ex) {
        StaticStandard.logErr(ex, false);
    }
}
 
Example 3
Project: VASSAL-src   File: ApplicationIcons.java   View Source Code Vote up 5 votes
public static void setFor(JFrame w) {
  if (icons == null) return;

  if (setIconImages != null) {
    setIconImages(w);
  }
  else {
    // Load a single image as a fallback and watch in horror as it
    // gets scaled to ridiculous sizes.
    w.setIconImage(icons.get(0));
  }
}
 
Example 4
Project: formatter   File: FormatMain.java   View Source Code Vote up 5 votes
/**
* 
* @Title: init 
* @Description: Component Initialization 
* @param
* @return void 
* @throws
 */
private static void init()
{
    MenuBarView mbv = new MenuBarView();
    JFrame frame = new JFrame(FormatConst.FORMAT_VERSION);
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    frame.setJMenuBar(mbv.getJMenuBar());
    frame.getContentPane().add(FormatView.getView());
    frame.pack();
    frame.setVisible(true);
    frame.setIconImage(FormatUtil.getImage(FormatConst.LOGO));
    FormatUtil.setLocation(frame);
}
 
Example 5
Project: ElectroLight-Intrusion-Detection   File: AppWindow.java   View Source Code Vote up 5 votes
/**
 * Create the main window.
 */
public AppWindow() {
	frmElectrolightIntrusionDetection = new JFrame();
	frmElectrolightIntrusionDetection.setIconImage(Toolkit.getDefaultToolkit().getImage(AppWindow.class.getResource("/javax/swing/plaf/metal/icons/ocean/menu.gif")));
	frmElectrolightIntrusionDetection.setTitle("ElectroLight Intrusion Detection");
	frmElectrolightIntrusionDetection.setBounds(100, 100, 450, 300);
	frmElectrolightIntrusionDetection.setDefaultCloseOperation(JFrame.HIDE_ON_CLOSE);
	
	JTabbedPane tabbedPane = new JTabbedPane(JTabbedPane.TOP);
	frmElectrolightIntrusionDetection.getContentPane().add(tabbedPane, BorderLayout.CENTER);
	
	ScannersGUI scannersGUI = new ScannersGUI();
	tabbedPane.addTab("Scanners", null, scannersGUI, null);
}
 
Example 6
Project: game2048_tetris   File: Main.java   View Source Code Vote up 5 votes
public static void main(String[] args) {
	//新建窗体对象
	frame = new JFrame("2048");
	frame.setIconImage(new ImageIcon(MainPanel.class.getResource("gameicon.png")).getImage());
	//窗体大小
	frame.setSize(460, 680);
	//窗体居中
	frame.setLocationRelativeTo(null);
	//窗体大小不可变
	frame.setResizable(false);
	//默认的关闭操作
	frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
	//新建主面板 对象
	mainPanel = new MainPanel(frame);
	//去掉面板默认布局
	mainPanel.setLayout(new FlowLayout(1, 200, 90));
	//面板背景颜色
	mainPanel.setBackground(new Color(247, 239, 230));
	//把面板添加到窗体中
	frame.add(mainPanel);
	//窗体可见
	frame.setVisible(true);
	//主界面的控制方法
	mainPanel.run();
	frame.addWindowListener(new WindowAdapter() {
		public void windowClosing(WindowEvent e) {
			try {
				mainPanel.getClassicPanel().saveScore();
				mainPanel.getClassicPanel().saveState();
				mainPanel.getDropPanel().updateTopScore();
			} catch (IOException e1) {
				e1.printStackTrace();
			}
		}
	});		
	
}
 
Example 7
Project: sentimental-analyzer   File: Analyzer.java   View Source Code Vote up 5 votes
/**
 * Initialize the contents of the frame.
 */
private void initialize() {
	frame = new JFrame();
	frame.setIconImage(Toolkit.getDefaultToolkit().getImage("E:\\图片\\u=1829416607,2140971604&fm=21&gp=0.jpg"));
	frame.setType(Type.UTILITY);
	frame.setTitle("网络电影评论情感倾向性分类");
	frame.setBounds(100, 100, 639, 412);
	frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
	
	JMenuBar menuBar = new JMenuBar();
	frame.setJMenuBar(menuBar);
	
	JMenu mnNewMenu = new JMenu("数据集自动标注");
	menuBar.add(mnNewMenu);
	
	JMenuItem mntmNewMenuItem_2 = new JMenuItem("自动标注");
	mnNewMenu.add(mntmNewMenuItem_2);
	
	JMenu mnNewMenu_1 = new JMenu("情感分析");
	menuBar.add(mnNewMenu_1);
	
	JMenuItem mntmNewMenuItem_3 = new JMenuItem("朴素贝叶斯算法");
	mnNewMenu_1.add(mntmNewMenuItem_3);
	
	JMenuItem mntmNewMenuItem_4 = new JMenuItem("N-Gram算法");
	mnNewMenu_1.add(mntmNewMenuItem_4);
	
	JMenuItem mntmNewMenuItem_5 = new JMenuItem("支持向量机");
	mnNewMenu_1.add(mntmNewMenuItem_5);
	
	JMenu mnNewMenu_2 = new JMenu("关于");
	menuBar.add(mnNewMenu_2);
	
	JMenuItem mntmNewMenuItem = new JMenuItem("作者");
	mnNewMenu_2.add(mntmNewMenuItem);
	
	JMenuItem mntmNewMenuItem_1 = new JMenuItem("New menu item");
	mnNewMenu_2.add(mntmNewMenuItem_1);
}
 
Example 8
Project: WePush   File: MainWindow.java   View Source Code Vote up 5 votes
public static void main(String[] args) {
    logger.info("main start");

    Init.initTheme();
    Init.initGlobalFont();  //统一设置字体

    frame = new JFrame(ConstantsUI.APP_NAME);
    frame.setIconImage(ConstantsUI.IMAGE_ICON);
    Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize(); //得到屏幕的尺寸
    frame.setBounds((int) (screenSize.width * 0.1), (int) (screenSize.height * 0.08), (int) (screenSize.width * 0.8),
            (int) (screenSize.height * 0.8));

    Dimension preferSize = new Dimension((int) (screenSize.width * 0.8),
            (int) (screenSize.height * 0.8));
    frame.setPreferredSize(preferSize);

    mainWindow = new MainWindow();

    frame.setContentPane(mainWindow.mainPanel);
    frame.setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE);
    frame.pack();
    frame.setVisible(true);

    Init.initOthers();
    Init.initAllTab();

    // 添加事件监听
    AboutListener.addListeners();
    SettingListener.addListeners();
    MsgListener.addListeners();
    MemberListener.addListeners();
    PushListener.addListeners();
    ScheduleListener.addListeners();
    TabListener.addListeners();
    FramListener.addListeners();
}
 
Example 9
Project: poe-ladder-tracker-java   File: GUIError.java   View Source Code Vote up 5 votes
/**
 * Initializes the GUI.
 */
private void initialize(){
	Dimension dim = Toolkit.getDefaultToolkit().getScreenSize();
	
	// error window
	windowError = new JFrame();	
	windowError.setBounds(100, 100, 300, 145);
	windowError.setLocation(dim.width/2-windowError.getSize().width/2, dim.height/2-windowError.getSize().height/2);
	windowError.setResizable(false);
	windowError.setTitle("Ladder Tracker v" + version);
	windowError.setIconImage(new ImageIcon(getClass().getResource("icon.png")).getImage());
	windowError.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
	windowError.getContentPane().setLayout(null);
	
	// button retry
	buttonRetry = new JButton("Retry");
	buttonRetry.setBounds(10, 80, 274, 23);
	buttonRetry.addActionListener(buttonRetryListener);
	windowError.getContentPane().add(buttonRetry);
	
	// error text 
	JTextPane textError = new JTextPane();
	textError.setText(errorMessage);
	textError.setEditable(false);
	textError.setBackground(SystemColor.menu);
	textError.setBounds(10, 21, 274, 39);
	windowError.getContentPane().add(textError);
}
 
Example 10
Project: jmt   File: JSIMMain.java   View Source Code Vote up 4 votes
private void showOptions() {
	JFrame jf = new JFrame("Defaults Editor");
	jf.setIconImage(getIconImage());
	jf.setSize(getSize());
	new DefaultsEditor(jf, DefaultsEditor.JSIM).show();
}
 
Example 11
Project: jreliability   File: ReliabilityViewer.java   View Source Code Vote up 4 votes
/**
 * Constructs and views {@link JFrame} with a given title and a list of {@link ReliabilityFunction}s.
 * 
 * @param title
 *            the title
 * @param reliabilityFunctions
 *            the reliabilityFunctions
 */
public static void view(String title, Map<String, ReliabilityFunction> reliabilityFunctions) {

	try {
		UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
	} catch (Exception e) {
		e.printStackTrace();
	}

	// Setup the aspects for the plot panel
	List<Aspect> aspects = new ArrayList<>();
	aspects.add(new ReliabilityFunctionAspect());
	aspects.add(new DistributionAspect());
	aspects.add(new DensityAspect());
	aspects.add(new FailureRateAspect());
	ReliabilityFunctionPlotPanel reliabilityFunctionPlotPanel = new ReliabilityFunctionPlotPanel(aspects);
	JPanel plotPanel = reliabilityFunctionPlotPanel.get(reliabilityFunctions);

	JPanel measuresPanel = new MeasuresPanel(reliabilityFunctions);

	JFrame frame = new JFrame();

	frame.setTitle(title);
	frame.setIconImage(getImageIcon().getImage());
	frame.setPreferredSize(new Dimension(1000, 500));
	frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

	Container content = frame.getContentPane();
	frame.setLayout(new GridBagLayout());
	GridBagConstraints c = new GridBagConstraints();
	c.ipady = 10;
	c.ipadx = 10;
	c.fill = GridBagConstraints.BOTH;

	c.gridx = 0;
	c.gridy = 5;
	c.weighty = 0.5;
	content.add(measuresPanel, c);
	c.gridx = 1;
	c.gridy = 5;
	c.weightx = 1.0;
	c.weighty = 0.5;
	content.add(plotPanel, c);

	c.gridx = 0;
	c.gridy = 20;
	c.gridwidth = 2;
	c.weighty = 0.0;
	c.fill = GridBagConstraints.HORIZONTAL;
	c.anchor = GridBagConstraints.PAGE_END;
	content.add(new JLabel(" \u00A9 JReliability.org 2008-2017"), c);

	frame.pack();
	frame.setVisible(true);
}
 
Example 12
Project: QN-ACTR-Release   File: ExactWizard.java   View Source Code Vote up 4 votes
private void createSolutionWindow() {
	JTabbedPane jtp = new JTabbedPane();
	JFrame solutionWindow = new JFrame("jMVA Solutions");
	solutionWindow.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
	solutionWindow.getContentPane().add(jtp);
	solutionWindow.setIconImage(this.getIconImage());
	IterationSelector selector = null;
	if (data.isWhatIf()) {
		// Graphic panel (Bertoli Marco)
		jtp.add(new GraphPanel(data));
		selector = new IterationSelector(data);
	}
	ThroughputPanel throughput = new ThroughputPanel(this);
	QueueLenPanel queuelength = new QueueLenPanel(this);
	ResTimePanel restimes = new ResTimePanel(this);
	UtilizationPanel utilizations = new UtilizationPanel(this);
	//Added by ASHANKA START
	//Introducing the new System Power Panel as a Tabbed Pane
	SysPowerPanel systemPower = new SysPowerPanel(this);
	//Added by ASHANKA STOP
	if (selector != null) {
		selector.addSolutionPanel(throughput);
		selector.addSolutionPanel(queuelength);
		selector.addSolutionPanel(restimes);
		selector.addSolutionPanel(utilizations);
		//Added by ASHANKA START
		// for System Power
		selector.addSolutionPanel(systemPower);
		//Added by ASHANKA STOP
		jtp.add(selector);
	} else {
		jtp.add(throughput);
		jtp.add(queuelength);
		jtp.add(restimes);
		jtp.add(utilizations);
		//Added by ASHANKA START
		//for System Power
		jtp.add(systemPower);
		//Added by ASHANKA STOP
	}
	//NEW Dall'Orso 5-5-2005
	SynopsisPanel synPane;
	if (tempFile != null) {
		synPane = new SynopsisPanel(this, tempFile);
	} else {
		synPane = new SynopsisPanel(this);
	}
	jtp.add(synPane);
	//END
	//BoundingBox of main window
	Rectangle rect = this.getBounds();
	solutionWindow.setBounds(rect.x + 20, rect.y + 20, rect.width, rect.height);
	solutionWindow.show();
}
 
Example 13
Project: QN-ACTR-Release   File: JSIMMain.java   View Source Code Vote up 4 votes
private void showOptions() {
	JFrame jf = new JFrame("Defaults Editor");
	jf.setIconImage(getIconImage());
	jf.setSize(getSize());
	new DefaultsEditor(jf, DefaultsEditor.JSIM).show();
}