当前位置: 首页>>代码示例>>Java>>正文


Java JTextPane.setPreferredSize方法代码示例

本文整理汇总了Java中javax.swing.JTextPane.setPreferredSize方法的典型用法代码示例。如果您正苦于以下问题:Java JTextPane.setPreferredSize方法的具体用法?Java JTextPane.setPreferredSize怎么用?Java JTextPane.setPreferredSize使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在javax.swing.JTextPane的用法示例。


在下文中一共展示了JTextPane.setPreferredSize方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: LocRecordsView

import javax.swing.JTextPane; //导入方法依赖的package包/类
public LocRecordsView(final Window parent, final ServiceFactory factory) {
	super(parent, Resources.getLabel("LocRecords"), ModalityType.APPLICATION_MODAL);
	final String rawLocRecords = factory.getGeo().getLocRecordsStr();

	final JTextPane text = new JTextPane();
	text.setEditable(true);
	text.setText(rawLocRecords);
	text.setPreferredSize(new Dimension(800, 400));
	getContentPane().add(text, BorderLayout.CENTER);
	final JButton save = new JButton("Save");
	save.addActionListener(e -> {
		final Pair<String, Exception> error = factory.getGeo().parseAndLoadDNSRecords(text.getText());
		text.setText(factory.getGeo().getLocRecordsStr());
		if (StringUtils.isNotEmpty(error.getKey())) {
			JOptionPane.showMessageDialog(LocRecordsView.this, Resources.getLabel("dns.loc.warning", error.getKey()), Resources.getLabel("warning"),
					JOptionPane.WARNING_MESSAGE);
		} else {
			JOptionPane.showMessageDialog(LocRecordsView.this, Resources.getLabel("dns.loc.updated"));
			LocRecordsView.this.dispose();
		}
	});
	getContentPane().add(save, BorderLayout.SOUTH);
	pack();
	setLocationRelativeTo(parent);
	setVisible(true);
}
 
开发者ID:leolewis,项目名称:openvisualtraceroute,代码行数:27,代码来源:LocRecordsView.java

示例2: setHeader

import javax.swing.JTextPane; //导入方法依赖的package包/类
private static void setHeader(JPanel panel) {
  JTextPane header = new JTextPane();
  Insets inset = new Insets(0, 0, 0, 5);
  header.setPreferredSize(new Dimension(80, 15));
  header.setComponentOrientation(ComponentOrientation.RIGHT_TO_LEFT);
  header.setEditable(false);
  header.setText("10:00");
  header.setMargin(inset);
  header.setBackground(Color.lightGray);
  panel.add(header);
}
 
开发者ID:vaclav,项目名称:voicemenu,代码行数:12,代码来源:Style.java

示例3: main

import javax.swing.JTextPane; //导入方法依赖的package包/类
public static void main(String[] args) {
			
	//Creates the JFrame and configures it.
	JFrame window = new JFrame("Hash Generator 1.0");
	window.setSize(670, 110);
	window.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
	window.setLayout(new FlowLayout(FlowLayout.LEFT));
	window.setResizable(false);
	
	//Creates the JPanels.
	JPanel panel = new JPanel();
	window.add(panel);

	//Creates the "Choose a file button."
	JButton chooseFile = new JButton("Choose a file");
	panel.add(chooseFile);
	
	//Creates the file chooser with custom options.
	String userDir = System.getProperty("user.home");
	JFileChooser input = new JFileChooser(userDir +"/");
	Action details = input.getActionMap().get("viewTypeDetails");
	details.actionPerformed(null);
	
	// Creates the output text field.
	JTextPane finalText = new JTextPane();
	finalText.setBorder(BorderFactory.createEmptyBorder());
	finalText.setOpaque(false);
	finalText.setEditable(false);
	finalText.setPreferredSize( new Dimension( 520, 60 ) );
	finalText.setText("MD5: \nSHA1: \nSHA-256: ");
	panel.add(finalText);
	
	//This will make the window appear.
	window.setVisible(true);
	
	//Adds a listener for when the button is clicked, it opens the file chooser.
	chooseFile.addActionListener(new ActionListener() {
		public void actionPerformed(ActionEvent onClick) {
			
			//Opens the file chooser.
			int result = input.showOpenDialog(chooseFile);
			
			//When the file chooser opens, this will save the file and get the checksum.
			if (result == JFileChooser.FILES_ONLY) {
				
					try 
					{
						//Gets the file from the file chooser.
						File finalFile = new File(input.getSelectedFile().getAbsolutePath());
						InputStream is = new FileInputStream(finalFile);
						InputStream is2 = new FileInputStream(finalFile);
						InputStream is3 = new FileInputStream(finalFile);

						//Generate the checksum with the given file.
						md5Final = DigestUtils.md5Hex(is);
						sha1Final = DigestUtils.shaHex(is2);
						sha256Final = DigestUtils.sha256Hex(is3);
						
						//Puts the final output into the text box.
						finalText.setText("MD5: " + md5Final + "\nSHA1: " + sha1Final + "\nSHA-256: " + sha256Final);

					}
					catch(IOException e) 
					{
						e.printStackTrace();
					}
				}
		}
	});
}
 
开发者ID:hyperdefined,项目名称:hash-generator,代码行数:71,代码来源:HashGenerator.java


注:本文中的javax.swing.JTextPane.setPreferredSize方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。