當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。